annotate src/video/quartz/SDL_QuartzEvents.m @ 1905:36d52b1f0504

Prefer the D3D renderer over GDI, at least for testing. Added support for the SDL_VIDEO_RENDERER environment variable to pick the desired render driver. Implemented WritePixels support for the D3D renderer.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 14 Jul 2006 08:22:45 +0000
parents c121d94672cb
children
rev   line source
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
2 SDL - Simple DirectMedia Layer
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
3 Copyright (C) 1997-2003 Sam Lantinga
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
5 This library is free software; you can redistribute it and/or
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
6 modify it under the terms of the GNU Library General Public
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
7 License as published by the Free Software Foundation; either
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
8 version 2 of the License, or (at your option) any later version.
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
10 This library is distributed in the hope that it will be useful,
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
13 Library General Public License for more details.
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
15 You should have received a copy of the GNU Library General Public
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
16 License along with this library; if not, write to the Free
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
19 Sam Lantinga
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
20 slouken@libsdl.org
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1403
376665398b25 Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
22 #include "SDL_config.h"
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
23
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
24 #include "SDL_QuartzVideo.h"
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
25
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
26 #include <IOKit/IOMessage.h> /* For wake from sleep detection */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
27 #include <IOKit/pwr_mgt/IOPMLib.h> /* For wake from sleep detection */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include "SDL_QuartzKeys.h"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
30 /*
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
31 * In Panther, this header defines device dependent masks for
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
32 * right side keys. These definitions only exist in Panther, but
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
33 * the header seems to exist at least in Jaguar and probably earlier
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
34 * versions of the OS, so this should't break anything.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
35 */
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
36 #include <IOKit/hidsystem/IOLLEvent.h>
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
37 /*
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
38 * These are not defined before Panther. To keep the code compiling
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
39 * on systems without these, I will define if they don't exist.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
40 */
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
41 #ifndef NX_DEVICERCTLKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
42 #define NX_DEVICELCTLKEYMASK 0x00000001
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
43 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
44 #ifndef NX_DEVICELSHIFTKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
45 #define NX_DEVICELSHIFTKEYMASK 0x00000002
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
46 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
47 #ifndef NX_DEVICERSHIFTKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
48 #define NX_DEVICERSHIFTKEYMASK 0x00000004
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
49 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
50 #ifndef NX_DEVICELCMDKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
51 #define NX_DEVICELCMDKEYMASK 0x00000008
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
52 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
53 #ifndef NX_DEVICERCMDKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
54 #define NX_DEVICERCMDKEYMASK 0x00000010
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
55 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
56 #ifndef NX_DEVICELALTKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
57 #define NX_DEVICELALTKEYMASK 0x00000020
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
58 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
59 #ifndef NX_DEVICERALTKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
60 #define NX_DEVICERALTKEYMASK 0x00000040
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
61 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
62 #ifndef NX_DEVICERCTLKEYMASK
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
63 #define NX_DEVICERCTLKEYMASK 0x00002000
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
64 #endif
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
65
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
66 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
67 QZ_InitOSKeymap (_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
68 {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
69 const void *KCHRPtr;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
70 UInt32 state;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
71 UInt32 value;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
72 int i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
73 int world = SDLK_WORLD_0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
74
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
75 for (i = 0; i < SDL_TABLESIZE (keymap); ++i)
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
76 keymap[i] = SDLK_UNKNOWN;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
78 /* This keymap is almost exactly the same as the OS 9 one */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
79 keymap[QZ_ESCAPE] = SDLK_ESCAPE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
80 keymap[QZ_F1] = SDLK_F1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
81 keymap[QZ_F2] = SDLK_F2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
82 keymap[QZ_F3] = SDLK_F3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
83 keymap[QZ_F4] = SDLK_F4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
84 keymap[QZ_F5] = SDLK_F5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
85 keymap[QZ_F6] = SDLK_F6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
86 keymap[QZ_F7] = SDLK_F7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
87 keymap[QZ_F8] = SDLK_F8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
88 keymap[QZ_F9] = SDLK_F9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
89 keymap[QZ_F10] = SDLK_F10;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
90 keymap[QZ_F11] = SDLK_F11;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
91 keymap[QZ_F12] = SDLK_F12;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
92 keymap[QZ_PRINT] = SDLK_PRINT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
93 keymap[QZ_SCROLLOCK] = SDLK_SCROLLOCK;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
94 keymap[QZ_PAUSE] = SDLK_PAUSE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
95 keymap[QZ_POWER] = SDLK_POWER;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
96 keymap[QZ_BACKQUOTE] = SDLK_BACKQUOTE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
97 keymap[QZ_1] = SDLK_1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
98 keymap[QZ_2] = SDLK_2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
99 keymap[QZ_3] = SDLK_3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
100 keymap[QZ_4] = SDLK_4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
101 keymap[QZ_5] = SDLK_5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
102 keymap[QZ_6] = SDLK_6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
103 keymap[QZ_7] = SDLK_7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
104 keymap[QZ_8] = SDLK_8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
105 keymap[QZ_9] = SDLK_9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
106 keymap[QZ_0] = SDLK_0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
107 keymap[QZ_MINUS] = SDLK_MINUS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
108 keymap[QZ_EQUALS] = SDLK_EQUALS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
109 keymap[QZ_BACKSPACE] = SDLK_BACKSPACE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
110 keymap[QZ_INSERT] = SDLK_INSERT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
111 keymap[QZ_HOME] = SDLK_HOME;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
112 keymap[QZ_PAGEUP] = SDLK_PAGEUP;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
113 keymap[QZ_NUMLOCK] = SDLK_NUMLOCK;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
114 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
115 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
116 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
117 keymap[QZ_TAB] = SDLK_TAB;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
118 keymap[QZ_q] = SDLK_q;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
119 keymap[QZ_w] = SDLK_w;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
120 keymap[QZ_e] = SDLK_e;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
121 keymap[QZ_r] = SDLK_r;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
122 keymap[QZ_t] = SDLK_t;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
123 keymap[QZ_y] = SDLK_y;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
124 keymap[QZ_u] = SDLK_u;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
125 keymap[QZ_i] = SDLK_i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
126 keymap[QZ_o] = SDLK_o;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
127 keymap[QZ_p] = SDLK_p;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
128 keymap[QZ_LEFTBRACKET] = SDLK_LEFTBRACKET;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
129 keymap[QZ_RIGHTBRACKET] = SDLK_RIGHTBRACKET;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
130 keymap[QZ_BACKSLASH] = SDLK_BACKSLASH;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
131 keymap[QZ_DELETE] = SDLK_DELETE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
132 keymap[QZ_END] = SDLK_END;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
133 keymap[QZ_PAGEDOWN] = SDLK_PAGEDOWN;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
134 keymap[QZ_KP7] = SDLK_KP7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
135 keymap[QZ_KP8] = SDLK_KP8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
136 keymap[QZ_KP9] = SDLK_KP9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
137 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
138 keymap[QZ_CAPSLOCK] = SDLK_CAPSLOCK;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
139 keymap[QZ_a] = SDLK_a;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
140 keymap[QZ_s] = SDLK_s;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
141 keymap[QZ_d] = SDLK_d;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
142 keymap[QZ_f] = SDLK_f;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
143 keymap[QZ_g] = SDLK_g;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
144 keymap[QZ_h] = SDLK_h;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
145 keymap[QZ_j] = SDLK_j;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
146 keymap[QZ_k] = SDLK_k;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
147 keymap[QZ_l] = SDLK_l;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
148 keymap[QZ_SEMICOLON] = SDLK_SEMICOLON;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
149 keymap[QZ_QUOTE] = SDLK_QUOTE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
150 keymap[QZ_RETURN] = SDLK_RETURN;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
151 keymap[QZ_KP4] = SDLK_KP4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
152 keymap[QZ_KP5] = SDLK_KP5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
153 keymap[QZ_KP6] = SDLK_KP6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
154 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
155 keymap[QZ_LSHIFT] = SDLK_LSHIFT;
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
156 keymap[QZ_RSHIFT] = SDLK_RSHIFT;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
157 keymap[QZ_z] = SDLK_z;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
158 keymap[QZ_x] = SDLK_x;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
159 keymap[QZ_c] = SDLK_c;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
160 keymap[QZ_v] = SDLK_v;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
161 keymap[QZ_b] = SDLK_b;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
162 keymap[QZ_n] = SDLK_n;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
163 keymap[QZ_m] = SDLK_m;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
164 keymap[QZ_COMMA] = SDLK_COMMA;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
165 keymap[QZ_PERIOD] = SDLK_PERIOD;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
166 keymap[QZ_SLASH] = SDLK_SLASH;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
167 keymap[QZ_UP] = SDLK_UP;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
168 keymap[QZ_KP1] = SDLK_KP1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
169 keymap[QZ_KP2] = SDLK_KP2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
170 keymap[QZ_KP3] = SDLK_KP3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
171 keymap[QZ_KP_ENTER] = SDLK_KP_ENTER;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
172 keymap[QZ_LCTRL] = SDLK_LCTRL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
173 keymap[QZ_LALT] = SDLK_LALT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
174 keymap[QZ_LMETA] = SDLK_LMETA;
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
175 keymap[QZ_RCTRL] = SDLK_RCTRL;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
176 keymap[QZ_RALT] = SDLK_RALT;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
177 keymap[QZ_RMETA] = SDLK_RMETA;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
178 keymap[QZ_SPACE] = SDLK_SPACE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
179 keymap[QZ_LEFT] = SDLK_LEFT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
180 keymap[QZ_DOWN] = SDLK_DOWN;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
181 keymap[QZ_RIGHT] = SDLK_RIGHT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
182 keymap[QZ_KP0] = SDLK_KP0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
183 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
184 keymap[QZ_IBOOK_ENTER] = SDLK_KP_ENTER;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
185 keymap[QZ_IBOOK_RIGHT] = SDLK_RIGHT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
186 keymap[QZ_IBOOK_DOWN] = SDLK_DOWN;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
187 keymap[QZ_IBOOK_UP] = SDLK_UP;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
188 keymap[QZ_IBOOK_LEFT] = SDLK_LEFT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
189
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
190 /*
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
191 Up there we setup a static scancode->keysym map. However, it will not
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
192 work very well on international keyboard. Hence we now query MacOS
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
193 for its own keymap to adjust our own mapping table. However, this is
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
194 basically only useful for ascii char keys. This is also the reason
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
195 why we keep the static table, too.
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
196 */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
197
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
198 /* Get a pointer to the systems cached KCHR */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
199 KCHRPtr = (void *) GetScriptManagerVariable (smKCHRCache);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
200 if (KCHRPtr) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
201 /* Loop over all 127 possible scan codes */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
202 for (i = 0; i < 0x7F; i++) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
203 /* We pretend a clean start to begin with (i.e. no dead keys active */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
204 state = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
205
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
206 /* Now translate the key code to a key value */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
207 value = KeyTranslate (KCHRPtr, i, &state) & 0xff;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
208
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
209 /* If the state become 0, it was a dead key. We need to translate again,
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
210 passing in the new state, to get the actual key value */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
211 if (state != 0)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
212 value = KeyTranslate (KCHRPtr, i, &state) & 0xff;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
213
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
214 /* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
215 if (value >= 128) /* Some non-ASCII char, map it to SDLK_WORLD_* */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
216 keymap[i] = world++;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
217 else if (value >= 32) /* non-control ASCII char */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
218 keymap[i] = value;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
219 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
220 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
221
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
222 /*
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
223 The keypad codes are re-setup here, because the loop above cannot
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
224 distinguish between a key on the keypad and a regular key. We maybe
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
225 could get around this problem in another fashion: NSEvent's flags
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
226 include a "NSNumericPadKeyMask" bit; we could check that and modify
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
227 the symbol we return on the fly. However, this flag seems to exhibit
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
228 some weird behaviour related to the num lock key
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
229 */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
230 keymap[QZ_KP0] = SDLK_KP0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
231 keymap[QZ_KP1] = SDLK_KP1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
232 keymap[QZ_KP2] = SDLK_KP2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
233 keymap[QZ_KP3] = SDLK_KP3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
234 keymap[QZ_KP4] = SDLK_KP4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
235 keymap[QZ_KP5] = SDLK_KP5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
236 keymap[QZ_KP6] = SDLK_KP6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
237 keymap[QZ_KP7] = SDLK_KP7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
238 keymap[QZ_KP8] = SDLK_KP8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
239 keymap[QZ_KP9] = SDLK_KP9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
240 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
241 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
242 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
243 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
244 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
245 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
246 keymap[QZ_KP_ENTER] = SDLK_KP_ENTER;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
249 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
250 QZ_DoKey (_THIS, int state, NSEvent * event)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
251 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
253 NSString *chars;
561
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
254 unsigned int numChars;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
255 SDL_keysym key;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
256
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
257 /*
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
258 A key event can contain multiple characters,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
259 or no characters at all. In most cases, it
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
260 will contain a single character. If it contains
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
261 0 characters, we'll use 0 as the unicode. If it
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
262 contains multiple characters, we'll use 0 as
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
263 the scancode/keysym.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
264 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
265 chars =[event characters];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
266 numChars =[chars length];
561
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
267
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
268 if (numChars == 1) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
269
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
270 key.scancode =[event keyCode];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
271 key.sym = keymap[key.scancode];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
272 key.unicode =[chars characterAtIndex:0];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
273 key.mod = KMOD_NONE;
1876
406b8325ee34 Fixed bug #147
Sam Lantinga <slouken@libsdl.org>
parents: 1629
diff changeset
274
406b8325ee34 Fixed bug #147
Sam Lantinga <slouken@libsdl.org>
parents: 1629
diff changeset
275 SDL_PrivateKeyboard (state, &key);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
276 } else if (numChars == 0) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
277
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
278 key.scancode =[event keyCode];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
279 key.sym = keymap[key.scancode];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
280 key.unicode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
281 key.mod = KMOD_NONE;
561
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
282
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
283 SDL_PrivateKeyboard (state, &key);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
284 } else { /* (numChars > 1) */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
285
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
286
561
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
287 int i;
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
288 for (i = 0; i < numChars; i++) {
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
289
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
290 key.scancode = 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
291 key.sym = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
292 key.unicode =[chars characterAtIndex:i];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
293 key.mod = KMOD_NONE;
561
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
294
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
295 SDL_PrivateKeyboard (state, &key);
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
296 }
4bcf7dd06c47 Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 555
diff changeset
297 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
298
1338
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1213
diff changeset
299 if (SDL_getenv ("SDL_ENABLEAPPEVENTS"))
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
300 [NSApp sendEvent:event];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
303 /* This is the original behavior, before support was added for
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
304 * differentiating between left and right versions of the keys.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
305 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
306 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
307 QZ_DoUnsidedModifiers (_THIS, unsigned int newMods)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
308 {
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
310 const int mapping[] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
311 { SDLK_CAPSLOCK, SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA };
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
312
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
313 int i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
314 int bit;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
315 SDL_keysym key;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
316
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
317 key.scancode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
318 key.sym = SDLK_UNKNOWN;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
319 key.unicode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
320 key.mod = KMOD_NONE;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
321
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
322 /* Iterate through the bits, testing each against the current modifiers */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
323 for (i = 0, bit = NSAlphaShiftKeyMask; bit <= NSCommandKeyMask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
324 bit <<= 1, ++i) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
325
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
326 unsigned int currentMask, newMask;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
327
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
328 currentMask = current_mods & bit;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
329 newMask = newMods & bit;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
331 if (currentMask && currentMask != newMask) { /* modifier up event */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
333 key.sym = mapping[i];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
334 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
335 if (bit == NSAlphaShiftKeyMask)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
336 SDL_PrivateKeyboard (SDL_PRESSED, &key);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
337 SDL_PrivateKeyboard (SDL_RELEASED, &key);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
338 } else if (newMask && currentMask != newMask) { /* modifier down event */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
339
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
340 key.sym = mapping[i];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
341 SDL_PrivateKeyboard (SDL_PRESSED, &key);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
342 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
343 if (bit == NSAlphaShiftKeyMask)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
344 SDL_PrivateKeyboard (SDL_RELEASED, &key);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
345 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
346 }
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
347 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
348
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
349 /* This is a helper function for QZ_HandleModifierSide. This
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
350 * function reverts back to behavior before the distinction between
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
351 * sides was made.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
352 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
353 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
354 QZ_HandleNonDeviceModifier (_THIS, unsigned int device_independent_mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
355 unsigned int newMods, unsigned int key_sym)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
356 {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
357 unsigned int currentMask, newMask;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
358 SDL_keysym key;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
359
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
360 key.scancode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
361 key.sym = key_sym;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
362 key.unicode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
363 key.mod = KMOD_NONE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
364
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
365 /* Isolate just the bits we care about in the depedent bits so we can
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
366 * figure out what changed
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
367 */
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
368 currentMask = current_mods & device_independent_mask;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
369 newMask = newMods & device_independent_mask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
370
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
371 if (currentMask && currentMask != newMask) { /* modifier up event */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
372 SDL_PrivateKeyboard (SDL_RELEASED, &key);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
373 } else if (newMask && currentMask != newMask) { /* modifier down event */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
374 SDL_PrivateKeyboard (SDL_PRESSED, &key);
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
375 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
376 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
377
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
378 /* This is a helper function for QZ_HandleModifierSide.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
379 * This function sets the actual SDL_PrivateKeyboard event.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
380 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
381 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
382 QZ_HandleModifierOneSide (_THIS, unsigned int newMods,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
383 unsigned int key_sym,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
384 unsigned int sided_device_dependent_mask)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
385 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
386
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
387 SDL_keysym key;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
388 unsigned int current_dep_mask, new_dep_mask;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
389
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
390 key.scancode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
391 key.sym = key_sym;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
392 key.unicode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
393 key.mod = KMOD_NONE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
394
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
395 /* Isolate just the bits we care about in the depedent bits so we can
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
396 * figure out what changed
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
397 */
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
398 current_dep_mask = current_mods & sided_device_dependent_mask;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
399 new_dep_mask = newMods & sided_device_dependent_mask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
400
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
401 /* We now know that this side bit flipped. But we don't know if
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
402 * it went pressed to released or released to pressed, so we must
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
403 * find out which it is.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
404 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
405 if (new_dep_mask && current_dep_mask != new_dep_mask) {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
406 /* Modifier down event */
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
407 SDL_PrivateKeyboard (SDL_PRESSED, &key);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
408 } else { /* Modifier up event */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
409
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
410 SDL_PrivateKeyboard (SDL_RELEASED, &key);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
411 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
412 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
413
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
414 /* This is a helper function for QZ_DoSidedModifiers.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
415 * This function will figure out if the modifier key is the left or right side,
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
416 * e.g. left-shift vs right-shift.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
417 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
418 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
419 QZ_HandleModifierSide (_THIS, int device_independent_mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
420 unsigned int newMods,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
421 unsigned int left_key_sym,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
422 unsigned int right_key_sym,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
423 unsigned int left_device_dependent_mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
424 unsigned int right_device_dependent_mask)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
425 {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
426 unsigned int device_dependent_mask = 0;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
427 unsigned int diff_mod = 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
428
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
429 device_dependent_mask =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
430 left_device_dependent_mask | right_device_dependent_mask;
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
431 /* On the basis that the device independent mask is set, but there are
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
432 * no device dependent flags set, we'll assume that we can't detect this
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
433 * keyboard and revert to the unsided behavior.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
434 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
435 if ((device_dependent_mask & newMods) == 0) {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
436 /* Revert to the old behavior */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
437 QZ_HandleNonDeviceModifier (this, device_independent_mask, newMods,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
438 left_key_sym);
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
439 return;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
440 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
441
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
442 /* XOR the previous state against the new state to see if there's a change */
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
443 diff_mod = (device_dependent_mask & current_mods)
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
444 ^ (device_dependent_mask & newMods);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
445
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
446 if (diff_mod) {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
447 /* A change in state was found. Isolate the left and right bits
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
448 * to handle them separately just in case the values can simulataneously
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
449 * change or if the bits don't both exist.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
450 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
451 if (left_device_dependent_mask & diff_mod) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
452 QZ_HandleModifierOneSide (this, newMods, left_key_sym,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
453 left_device_dependent_mask);
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
454 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
455 if (right_device_dependent_mask & diff_mod) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
456 QZ_HandleModifierOneSide (this, newMods, right_key_sym,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
457 right_device_dependent_mask);
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
458 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
459 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
460 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
461
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
462 /* This is a helper function for QZ_DoSidedModifiers.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
463 * This function will release a key press in the case that
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
464 * it is clear that the modifier has been released (i.e. one side
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
465 * can't still be down).
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
466 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
467 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
468 QZ_ReleaseModifierSide (_THIS,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
469 unsigned int device_independent_mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
470 unsigned int newMods,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
471 unsigned int left_key_sym,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
472 unsigned int right_key_sym,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
473 unsigned int left_device_dependent_mask,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
474 unsigned int right_device_dependent_mask)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
475 {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
476 unsigned int device_dependent_mask = 0;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
477 SDL_keysym key;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
478
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
479 key.scancode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
480 key.sym = SDLK_UNKNOWN;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
481 key.unicode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
482 key.mod = KMOD_NONE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
483
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
484 device_dependent_mask =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
485 left_device_dependent_mask | right_device_dependent_mask;
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
486 /* On the basis that the device independent mask is set, but there are
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
487 * no device dependent flags set, we'll assume that we can't detect this
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
488 * keyboard and revert to the unsided behavior.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
489 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
490 if ((device_dependent_mask & current_mods) == 0) {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
491 /* In this case, we can't detect the keyboard, so use the left side
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
492 * to represent both, and release it.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
493 */
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
494 key.sym = left_key_sym;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
495 SDL_PrivateKeyboard (SDL_RELEASED, &key);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
496
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
497 return;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
498 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
499
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
500
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
501 /*
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
502 * This could have been done in an if-else case because at this point,
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
503 * we know that all keys have been released when calling this function.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
504 * But I'm being paranoid so I want to handle each separately,
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
505 * so I hope this doesn't cause other problems.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
506 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
507 if (left_device_dependent_mask & current_mods) {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
508 key.sym = left_key_sym;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
509 SDL_PrivateKeyboard (SDL_RELEASED, &key);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
510 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
511 if (right_device_dependent_mask & current_mods) {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
512 key.sym = right_key_sym;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
513 SDL_PrivateKeyboard (SDL_RELEASED, &key);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
514 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
515 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
516
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
517 /* This is a helper function for QZ_DoSidedModifiers.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
518 * This function handles the CapsLock case.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
519 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
520 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
521 QZ_HandleCapsLock (_THIS, unsigned int newMods)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
522 {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
523 unsigned int currentMask, newMask;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
524 SDL_keysym key;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
525
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
526 key.scancode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
527 key.sym = SDLK_CAPSLOCK;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
528 key.unicode = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
529 key.mod = KMOD_NONE;
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
530
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
531 currentMask = current_mods & NSAlphaShiftKeyMask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
532 newMask = newMods & NSAlphaShiftKeyMask;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
533
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
534 if (currentMask && currentMask != newMask) { /* modifier up event */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
535 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
536 SDL_PrivateKeyboard (SDL_PRESSED, &key);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
537 SDL_PrivateKeyboard (SDL_RELEASED, &key);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
538 } else if (newMask && currentMask != newMask) { /* modifier down event */
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
539 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
540 SDL_PrivateKeyboard (SDL_PRESSED, &key);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
541 SDL_PrivateKeyboard (SDL_RELEASED, &key);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
542 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
543 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
544
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
545 /* This function will handle the modifier keys and also determine the
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
546 * correct side of the key.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
547 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
548 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
549 QZ_DoSidedModifiers (_THIS, unsigned int newMods)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
550 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
551 /* Set up arrays for the key syms for the left and right side. */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
552 const unsigned int left_mapping[] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
553 { SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
554 const unsigned int right_mapping[] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
555 { SDLK_RSHIFT, SDLK_RCTRL, SDLK_RALT, SDLK_RMETA };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
556 /* Set up arrays for the device dependent masks with indices that
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
557 * correspond to the _mapping arrays
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
558 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
559 const unsigned int left_device_mapping[] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
560 { NX_DEVICELSHIFTKEYMASK, NX_DEVICELCTLKEYMASK, NX_DEVICELALTKEYMASK,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
561 NX_DEVICELCMDKEYMASK
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
562 };
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
563 const unsigned int right_device_mapping[] =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
564 { NX_DEVICERSHIFTKEYMASK, NX_DEVICERCTLKEYMASK, NX_DEVICERALTKEYMASK,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
565 NX_DEVICERCMDKEYMASK
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
566 };
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
567
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
568 unsigned int i;
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
569 unsigned int bit;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
570
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
571 /* Handle CAPSLOCK separately because it doesn't have a left/right side */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
572 QZ_HandleCapsLock (this, newMods);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
573
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
574 /* Iterate through the bits, testing each against the current modifiers */
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
575 for (i = 0, bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
576
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
577 unsigned int currentMask, newMask;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
578
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
579 currentMask = current_mods & bit;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
580 newMask = newMods & bit;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
581
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
582 /* If the bit is set, we must always examine it because the left
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
583 * and right side keys may alternate or both may be pressed.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
584 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
585 if (newMask) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
586 QZ_HandleModifierSide (this, bit, newMods,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
587 left_mapping[i],
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
588 right_mapping[i],
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
589 left_device_mapping[i],
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
590 right_device_mapping[i]);
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
591 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
592 /* If the state changed from pressed to unpressed, we must examine
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
593 * the device dependent bits to release the correct keys.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
594 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
595 else if (currentMask && currentMask != newMask) { /* modifier up event */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
596 QZ_ReleaseModifierSide (this, bit, newMods,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
597 left_mapping[i],
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
598 right_mapping[i],
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
599 left_device_mapping[i],
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
600 right_device_mapping[i]);
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
601 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
602 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
603 }
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
604
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
605 /* This function is called to handle the modifiers.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
606 * It will try to distinguish between the left side and right side
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
607 * of the keyboard for those modifiers that qualify if the
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
608 * operating system version supports it. Otherwise, the code
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
609 * will not try to make the distinction.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
610 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
611 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
612 QZ_DoModifiers (_THIS, unsigned int newMods)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
613 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
614
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
615 if (current_mods == newMods)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
616 return;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
617
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
618 /*
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
619 * Starting with Panther (10.3.0), the ability to distinguish between
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
620 * left side and right side modifiers is available.
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
621 */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
622 if (system_version >= 0x1030) {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
623 QZ_DoSidedModifiers (this, newMods);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
624 } else {
934
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
625 QZ_DoUnsidedModifiers (this, newMods);
af585d6efec8 Date: Thu, 17 Jun 2004 11:38:51 -0700 (PDT)
Sam Lantinga <slouken@libsdl.org>
parents: 898
diff changeset
626 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
627
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
628 current_mods = newMods;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
629 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
630
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
631 static void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
632 QZ_GetMouseLocation (_THIS, NSPoint * p)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
633 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
634 *p =[NSEvent mouseLocation]; /* global coordinates */
782
dbc5905402b0 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 779
diff changeset
635 if (qz_window)
dbc5905402b0 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 779
diff changeset
636 QZ_PrivateGlobalToLocal (this, p);
dbc5905402b0 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 779
diff changeset
637 QZ_PrivateCocoaToSDL (this, p);
dbc5905402b0 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 779
diff changeset
638 }
dbc5905402b0 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 779
diff changeset
639
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
640 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
641 QZ_DoActivate (_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
642 {
1629
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1560
diff changeset
643
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
644 SDL_PrivateAppActive (1,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
645 SDL_APPINPUTFOCUS | (QZ_IsMouseInWindow (this) ?
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
646 SDL_APPMOUSEFOCUS : 0));
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
647
615
7ec821f3cbd0 Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 563
diff changeset
648 /* Hide the cursor if it was hidden by SDL_ShowCursor() */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
649 if (!cursor_should_be_visible)
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
650 QZ_HideMouse (this);
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
651
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
652 /* Regrab input, only if it was previously grabbed */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
653 if (current_grab_mode == SDL_GRAB_ON) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
654
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
655 /* Restore cursor location if input was grabbed */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
656 QZ_PrivateWarpCursor (this, cursor_loc.x, cursor_loc.y);
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
657 QZ_ChangeGrabState (this, QZ_ENABLE_GRAB);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
658 } else {
1560
34b9e479047e Keep mouse cursor state sane on focus change in Quartz driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1487
diff changeset
659 /* Update SDL's mouse location */
34b9e479047e Keep mouse cursor state sane on focus change in Quartz driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1487
diff changeset
660 NSPoint p;
34b9e479047e Keep mouse cursor state sane on focus change in Quartz driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1487
diff changeset
661 QZ_GetMouseLocation (this, &p);
34b9e479047e Keep mouse cursor state sane on focus change in Quartz driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1487
diff changeset
662 SDL_PrivateMouseMotion (0, 0, p.x, p.y);
34b9e479047e Keep mouse cursor state sane on focus change in Quartz driver.
Ryan C. Gordon <icculus@icculus.org>
parents: 1487
diff changeset
663 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
664 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
665
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
666 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
667 QZ_DoDeactivate (_THIS)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
668 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
669
1629
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1560
diff changeset
670 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS | SDL_APPMOUSEFOCUS);
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
671
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
672 /* Get the current cursor location, for restore on activate */
782
dbc5905402b0 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 779
diff changeset
673 QZ_GetMouseLocation (this, &cursor_loc);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
674
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
675 /* Reassociate mouse and cursor */
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
676 CGAssociateMouseAndMouseCursorPosition (1);
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
677
615
7ec821f3cbd0 Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 563
diff changeset
678 /* Show the cursor if it was hidden by SDL_ShowCursor() */
761
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
679 if (!cursor_should_be_visible)
c5b2b6d2d1fe Date: Wed, 31 Dec 2003 21:55:30 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 683
diff changeset
680 QZ_ShowMouse (this);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
681 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
682
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
683 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
684 QZ_SleepNotificationHandler (void *refcon,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
685 io_service_t service,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
686 natural_t messageType, void *messageArgument)
555
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
687 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
688 SDL_VideoDevice *this = (SDL_VideoDevice *) refcon;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
689
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
690 switch (messageType) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
691 case kIOMessageSystemWillSleep:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
692 IOAllowPowerChange (power_connection, (long) messageArgument);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
693 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
694 case kIOMessageCanSystemSleep:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
695 IOAllowPowerChange (power_connection, (long) messageArgument);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
696 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
697 case kIOMessageSystemHasPoweredOn:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
698 /* awake */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
699 SDL_PrivateExpose ();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
700 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
701 }
555
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
702 }
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
703
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
704 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
705 QZ_RegisterForSleepNotifications (_THIS)
555
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
706 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
707 CFRunLoopSourceRef rls;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
708 IONotificationPortRef thePortRef;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
709 io_object_t notifier;
555
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
710
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
711 power_connection =
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
712 IORegisterForSystemPower (this, &thePortRef,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
713 QZ_SleepNotificationHandler, &notifier);
555
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
714
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
715 if (power_connection == 0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
716 NSLog
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
717 (@"SDL: QZ_SleepNotificationHandler() IORegisterForSystemPower failed.");
555
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
718
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
719 rls = IONotificationPortGetRunLoopSource (thePortRef);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
720 CFRunLoopAddSource (CFRunLoopGetCurrent (), rls, kCFRunLoopDefaultMode);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
721 CFRelease (rls);
555
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
722 }
2536446a92de From: Darrell Walisser
Sam Lantinga <slouken@libsdl.org>
parents: 511
diff changeset
723
624
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
724
1487
dc6b59e925a2 Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
725 /* Try to map Quartz mouse buttons to SDL's lingo... */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
726 static int
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
727 QZ_OtherMouseButtonToSDL (int button)
624
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
728 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
729 switch (button) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
730 case 0:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
731 return (SDL_BUTTON_LEFT); /* 1 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
732 case 1:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
733 return (SDL_BUTTON_RIGHT); /* 3 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
734 case 2:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
735 return (SDL_BUTTON_MIDDLE); /* 2 */
624
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
736 }
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
737
1487
dc6b59e925a2 Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
738 /* >= 3: skip 4 & 5, since those are the SDL mousewheel buttons. */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
739 return (button + 3);
624
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
740 }
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
741
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
742
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
743 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
744 QZ_PumpEvents (_THIS)
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
745 {
1487
dc6b59e925a2 Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
746 static Uint32 screensaverTicks = 0;
dc6b59e925a2 Cleaning up warnings on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
747 Uint32 nowTicks;
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
748 int firstMouseEvent;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
749 CGMouseDelta dx, dy;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
750
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
751 NSDate *distantPast;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
752 NSEvent *event;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
753 NSRect winRect;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
754 NSAutoreleasePool *pool;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
755
1213
8eb191652834 Quartz target shouldn't crash if an event thread is used.
Ryan C. Gordon <icculus@icculus.org>
parents: 1212
diff changeset
756 if (!SDL_VideoSurface)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
757 return; /* don't do anything if there's no screen surface. */
1213
8eb191652834 Quartz target shouldn't crash if an event thread is used.
Ryan C. Gordon <icculus@icculus.org>
parents: 1212
diff changeset
758
619
bf816ce70144 Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents: 615
diff changeset
759 /* Update activity every five seconds to prevent screensaver. --ryan. */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
760 nowTicks = SDL_GetTicks ();
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
761 if ((nowTicks - screensaverTicks) > 5000) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
762 UpdateSystemActivity (UsrActivity);
619
bf816ce70144 Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents: 615
diff changeset
763 screensaverTicks = nowTicks;
bf816ce70144 Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents: 615
diff changeset
764 }
bf816ce70144 Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents: 615
diff changeset
765
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
766 pool =[[NSAutoreleasePool alloc] init];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
767 distantPast =[NSDate distantPast];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
768
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
769 winRect = NSMakeRect (0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
770
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
771 /* send the first mouse event in absolute coordinates */
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
772 firstMouseEvent = 1;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
773
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
774 /* accumulate any additional mouse moved events into one SDL mouse event */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
775 dx = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
776 dy = 0;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
777
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
778 do {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
779
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
780 /* Poll for an event. This will not block */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
781 event =[NSApp nextEventMatchingMask: NSAnyEventMask untilDate: distantPast inMode: NSDefaultRunLoopMode dequeue:YES];
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
782 if (event != nil) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
783
624
fb78cadbfeb8 More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents: 619
diff changeset
784 int button;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
785 unsigned int type;
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
786 BOOL isInGameWin;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
787
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
788 #define DO_MOUSE_DOWN(button) do { \
1629
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1560
diff changeset
789 if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) { \
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1560
diff changeset
790 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
ef4a796e7f24 Fixed bug #55
Sam Lantinga <slouken@libsdl.org>
parents: 1560
diff changeset
791 expect_mouse_up |= 1<<button; \
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
792 } \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
793 [ NSApp sendEvent:event ]; \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
794 } while(0)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
795
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
796 #define DO_MOUSE_UP(button) do { \
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
797 if ( expect_mouse_up & (1<<button) ) { \
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
798 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
799 expect_mouse_up &= ~(1<<button); \
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
800 } \
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
801 [ NSApp sendEvent:event ]; \
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
802 } while(0)
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
803
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
804 type =[event type];
779
68c8da837fc0 Date: Tue, 6 Jan 2004 21:54:02 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 761
diff changeset
805 isInGameWin = QZ_IsMouseInWindow (this);
782
dbc5905402b0 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 779
diff changeset
806
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
807 QZ_DoModifiers (this,[event modifierFlags]);
816
428f688f2ad2 Date: Fri, 13 Feb 2004 17:03:16 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 782
diff changeset
808
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
809 switch (type) {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
810 case NSLeftMouseDown:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
811 if (SDL_getenv ("SDL_HAS3BUTTONMOUSE")) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
812 DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
813 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
814 if (NSCommandKeyMask & current_mods) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
815 last_virtual_button = SDL_BUTTON_RIGHT;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
816 DO_MOUSE_DOWN (SDL_BUTTON_RIGHT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
817 } else if (NSAlternateKeyMask & current_mods) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
818 last_virtual_button = SDL_BUTTON_MIDDLE;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
819 DO_MOUSE_DOWN (SDL_BUTTON_MIDDLE);
511
79c189f5bd76 Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents: 502
diff changeset
820 } else {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
821 DO_MOUSE_DOWN (SDL_BUTTON_LEFT);
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
822 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
823 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
824 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
825
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
826 case NSLeftMouseUp:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
827 if (last_virtual_button != 0) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
828 DO_MOUSE_UP (last_virtual_button);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
829 last_virtual_button = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
830 } else {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
831 DO_MOUSE_UP (SDL_BUTTON_LEFT);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
832 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
833 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
834
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
835 case NSOtherMouseDown:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
836 case NSRightMouseDown:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
837 button = QZ_OtherMouseButtonToSDL ([event buttonNumber]);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
838 DO_MOUSE_DOWN (button);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
839 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
840
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
841 case NSOtherMouseUp:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
842 case NSRightMouseUp:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
843 button = QZ_OtherMouseButtonToSDL ([event buttonNumber]);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
844 DO_MOUSE_UP (button);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
845 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
846
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
847 case NSSystemDefined:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
848 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
849 Future: up to 32 "mouse" buttons can be handled.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
850 if ([event subtype] == 7) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
851 unsigned int buttons;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
852 buttons = [ event data2 ];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
853 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
854 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
855 case NSLeftMouseDragged:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
856 case NSRightMouseDragged:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
857 case NSOtherMouseDragged: /* usually middle mouse dragged */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
858 case NSMouseMoved:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
859 if (grab_state == QZ_INVISIBLE_GRAB) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
860
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
861 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
862 If input is grabbed+hidden, the cursor doesn't move,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
863 so we have to call the lowlevel window server
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
864 function. This is less accurate but works OK.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
865 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
866 CGMouseDelta dx1, dy1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
867 CGGetLastMouseDelta (&dx1, &dy1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
868 dx += dx1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
869 dy += dy1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
870 } else if (firstMouseEvent) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
871
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
872 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
873 Get the first mouse event in a possible
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
874 sequence of mouse moved events. Since we
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
875 use absolute coordinates, this serves to
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
876 compensate any inaccuracy in deltas, and
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
877 provides the first known mouse position,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
878 since everything after this uses deltas
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
879 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
880 NSPoint p;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
881 QZ_GetMouseLocation (this, &p);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
882 SDL_PrivateMouseMotion (0, 0, p.x, p.y);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
883 firstMouseEvent = 0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
884 } else {
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
885
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
886 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
887 Get the amount moved since the last drag or move event,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
888 add it on for one big move event at the end.
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
889 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
890 dx +=[event deltaX];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
891 dy +=[event deltaY];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
892 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
893
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
894 /*
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
895 Handle grab input+cursor visible by warping the cursor back
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
896 into the game window. This still generates a mouse moved event,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
897 but not as a result of the warp (so it's in the right direction).
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
898 */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
899 if (grab_state == QZ_VISIBLE_GRAB && !isInGameWin) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
900
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
901 NSPoint p;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
902 QZ_GetMouseLocation (this, &p);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
903
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
904 if (p.x < 0.0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
905 p.x = 0.0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
906
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
907 if (p.y < 0.0)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
908 p.y = 0.0;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
909
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
910 if (p.x >= winRect.size.width)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
911 p.x = winRect.size.width - 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
912
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
913 if (p.y >= winRect.size.height)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
914 p.y = winRect.size.height - 1;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
915
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
916 QZ_PrivateWarpCursor (this, p.x, p.y);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
917 } else if (!isInGameWin
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
918 && (SDL_GetAppState () & SDL_APPMOUSEFOCUS)) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
919
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
920 SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
921 if (grab_state == QZ_INVISIBLE_GRAB)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
922 /*The cursor has left the window even though it is
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
923 disassociated from the mouse (and therefore
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
924 shouldn't move): this can happen with Wacom
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
925 tablets, and it effectively breaks the grab, since
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
926 mouse down events now go to background
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
927 applications. The only possibility to avoid this
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
928 seems to be talking to the tablet driver
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
929 (AppleEvents) to constrain its mapped area to the
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
930 window, which may not be worth the effort. For
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
931 now, handle the condition more gracefully than
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
932 before by reassociating cursor and mouse until the
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
933 cursor enters the window again, making it obvious
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
934 to the user that the grab is broken. */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
935 CGAssociateMouseAndMouseCursorPosition (1);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
936 if (!cursor_should_be_visible)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
937 QZ_ShowMouse (this);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
938 } else if (isInGameWin
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
939 && (SDL_GetAppState () &
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
940 (SDL_APPMOUSEFOCUS | SDL_APPINPUTFOCUS)) ==
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
941 SDL_APPINPUTFOCUS) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
942
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
943 SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
944 if (!cursor_should_be_visible)
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
945 QZ_HideMouse (this);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
946 if (grab_state == QZ_INVISIBLE_GRAB) { /*see comment above */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
947 QZ_PrivateWarpCursor (this,
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
948 SDL_VideoSurface->w /
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
949 2, SDL_VideoSurface->h / 2);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
950 CGAssociateMouseAndMouseCursorPosition (0);
563
04dcaf3da918 Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents: 561
diff changeset
951 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
952 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
953 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
954 case NSScrollWheel:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
955 if (isInGameWin) {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
956 float dy, dx;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
957 Uint8 button;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
958 dy =[event deltaY];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
959 dx =[event deltaX];
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
960 if (dy > 0.0 || dx > 0.0) /* Scroll up */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
961 button = SDL_BUTTON_WHEELUP;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
962 else /* Scroll down */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
963 button = SDL_BUTTON_WHEELDOWN;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
964 /* For now, wheel is sent as a quick down+up */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
965 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
966 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
967 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
968 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
969 case NSKeyUp:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
970 QZ_DoKey (this, SDL_RELEASED, event);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
971 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
972 case NSKeyDown:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
973 QZ_DoKey (this, SDL_PRESSED, event);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
974 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
975 case NSFlagsChanged:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
976 break;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
977 /* case NSAppKitDefined: break; */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
978 /* case NSApplicationDefined: break; */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
979 /* case NSPeriodic: break; */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
980 /* case NSCursorUpdate: break; */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
981 default:
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
982 [NSApp sendEvent:event];
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
983 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
984 }
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
985 }
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
986 while (event != nil);
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
987
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
988 /* handle accumulated mouse moved events */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
989 if (dx != 0 || dy != 0)
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
990 SDL_PrivateMouseMotion (0, 1, dx, dy);
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
991
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
992 [pool release];
502
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
993 }
1212
7663bb0f52c7 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1050
diff changeset
994
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
995 void
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1876
diff changeset
996 QZ_UpdateMouse (_THIS)
1212
7663bb0f52c7 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1050
diff changeset
997 {
7663bb0f52c7 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1050
diff changeset
998 NSPoint p;
7663bb0f52c7 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1050
diff changeset
999 QZ_GetMouseLocation (this, &p);
7663bb0f52c7 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1050
diff changeset
1000 SDL_PrivateAppActive (QZ_IsMouseInWindow (this), SDL_APPMOUSEFOCUS);
7663bb0f52c7 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1050
diff changeset
1001 SDL_PrivateMouseMotion (0, 0, p.x, p.y);
7663bb0f52c7 To: sdl@libsdl.org
Ryan C. Gordon <icculus@icculus.org>
parents: 1050
diff changeset
1002 }