annotate src/video/quartz/SDL_QuartzEvents.m @ 388:4e9044b378fd

*** empty log message ***
author Sam Lantinga <slouken@libsdl.org>
date Sat, 01 Jun 2002 19:51:08 +0000
parents f6ffac90895c
children ca655a7a9d80
rev   line source
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
2 SDL - Simple DirectMedia Layer
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
5 This library is free software; you can redistribute it and/or
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
6 modify it under the terms of the GNU Library General Public
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
7 License as published by the Free Software Foundation; either
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
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
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
10 This library is distributed in the hope that it will be useful,
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
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
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
15 You should have received a copy of the GNU Library General Public
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
16 License along with this library; if not, write to the Free
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
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
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
19 Sam Lantinga
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
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 */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
22 #include <sys/time.h>
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #include "SDL_QuartzKeys.h"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
26 static SDLKey keymap[256];
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
27 static unsigned int currentMods = 0; /* Current keyboard modifiers, to track modifier state */
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
28 static int last_virtual_button = 0; /* Last virtual mouse button pressed */
155
2d162219f433 Date: Thu, 16 Aug 2001 21:50:51 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 117
diff changeset
29
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
30 static void QZ_InitOSKeymap (_THIS) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
31 const void *KCHRPtr;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
32 UInt32 state;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
33 UInt32 value;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
34 int i;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
35 int world = SDLK_WORLD_0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
36
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
37 for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
38 keymap[i] = SDLK_UNKNOWN;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
40 /* This keymap is almost exactly the same as the OS 9 one */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
41 keymap[QZ_ESCAPE] = SDLK_ESCAPE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
42 keymap[QZ_F1] = SDLK_F1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
43 keymap[QZ_F2] = SDLK_F2;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
44 keymap[QZ_F3] = SDLK_F3;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
45 keymap[QZ_F4] = SDLK_F4;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
46 keymap[QZ_F5] = SDLK_F5;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
47 keymap[QZ_F6] = SDLK_F6;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
48 keymap[QZ_F7] = SDLK_F7;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
49 keymap[QZ_F8] = SDLK_F8;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
50 keymap[QZ_F9] = SDLK_F9;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
51 keymap[QZ_F10] = SDLK_F10;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
52 keymap[QZ_F11] = SDLK_F11;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
53 keymap[QZ_F12] = SDLK_F12;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
54 keymap[QZ_PRINT] = SDLK_PRINT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
55 keymap[QZ_SCROLLOCK] = SDLK_SCROLLOCK;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
56 keymap[QZ_PAUSE] = SDLK_PAUSE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
57 keymap[QZ_POWER] = SDLK_POWER;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
58 keymap[QZ_BACKQUOTE] = SDLK_BACKQUOTE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
59 keymap[QZ_1] = SDLK_1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
60 keymap[QZ_2] = SDLK_2;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
61 keymap[QZ_3] = SDLK_3;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
62 keymap[QZ_4] = SDLK_4;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
63 keymap[QZ_5] = SDLK_5;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
64 keymap[QZ_6] = SDLK_6;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
65 keymap[QZ_7] = SDLK_7;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
66 keymap[QZ_8] = SDLK_8;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
67 keymap[QZ_9] = SDLK_9;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
68 keymap[QZ_0] = SDLK_0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
69 keymap[QZ_MINUS] = SDLK_MINUS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
70 keymap[QZ_EQUALS] = SDLK_EQUALS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
71 keymap[QZ_BACKSPACE] = SDLK_BACKSPACE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
72 keymap[QZ_INSERT] = SDLK_INSERT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
73 keymap[QZ_HOME] = SDLK_HOME;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
74 keymap[QZ_PAGEUP] = SDLK_PAGEUP;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
75 keymap[QZ_NUMLOCK] = SDLK_NUMLOCK;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
76 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
77 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
78 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
79 keymap[QZ_TAB] = SDLK_TAB;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
80 keymap[QZ_q] = SDLK_q;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
81 keymap[QZ_w] = SDLK_w;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
82 keymap[QZ_e] = SDLK_e;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
83 keymap[QZ_r] = SDLK_r;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
84 keymap[QZ_t] = SDLK_t;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
85 keymap[QZ_y] = SDLK_y;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
86 keymap[QZ_u] = SDLK_u;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
87 keymap[QZ_i] = SDLK_i;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
88 keymap[QZ_o] = SDLK_o;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
89 keymap[QZ_p] = SDLK_p;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
90 keymap[QZ_LEFTBRACKET] = SDLK_LEFTBRACKET;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
91 keymap[QZ_RIGHTBRACKET] = SDLK_RIGHTBRACKET;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
92 keymap[QZ_BACKSLASH] = SDLK_BACKSLASH;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
93 keymap[QZ_DELETE] = SDLK_DELETE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
94 keymap[QZ_END] = SDLK_END;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
95 keymap[QZ_PAGEDOWN] = SDLK_PAGEDOWN;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
96 keymap[QZ_KP7] = SDLK_KP7;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
97 keymap[QZ_KP8] = SDLK_KP8;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
98 keymap[QZ_KP9] = SDLK_KP9;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
99 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
100 keymap[QZ_CAPSLOCK] = SDLK_CAPSLOCK;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
101 keymap[QZ_a] = SDLK_a;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
102 keymap[QZ_s] = SDLK_s;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
103 keymap[QZ_d] = SDLK_d;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
104 keymap[QZ_f] = SDLK_f;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
105 keymap[QZ_g] = SDLK_g;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
106 keymap[QZ_h] = SDLK_h;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
107 keymap[QZ_j] = SDLK_j;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
108 keymap[QZ_k] = SDLK_k;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
109 keymap[QZ_l] = SDLK_l;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
110 keymap[QZ_SEMICOLON] = SDLK_SEMICOLON;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
111 keymap[QZ_QUOTE] = SDLK_QUOTE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
112 keymap[QZ_RETURN] = SDLK_RETURN;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
113 keymap[QZ_KP4] = SDLK_KP4;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
114 keymap[QZ_KP5] = SDLK_KP5;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
115 keymap[QZ_KP6] = SDLK_KP6;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
116 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
117 keymap[QZ_LSHIFT] = SDLK_LSHIFT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
118 keymap[QZ_z] = SDLK_z;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
119 keymap[QZ_x] = SDLK_x;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
120 keymap[QZ_c] = SDLK_c;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
121 keymap[QZ_v] = SDLK_v;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
122 keymap[QZ_b] = SDLK_b;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
123 keymap[QZ_n] = SDLK_n;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
124 keymap[QZ_m] = SDLK_m;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
125 keymap[QZ_COMMA] = SDLK_COMMA;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
126 keymap[QZ_PERIOD] = SDLK_PERIOD;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
127 keymap[QZ_SLASH] = SDLK_SLASH;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
128 keymap[QZ_UP] = SDLK_UP;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
129 keymap[QZ_KP1] = SDLK_KP1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
130 keymap[QZ_KP2] = SDLK_KP2;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
131 keymap[QZ_KP3] = SDLK_KP3;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
132 keymap[QZ_KP_ENTER] = SDLK_KP_ENTER;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
133 keymap[QZ_LCTRL] = SDLK_LCTRL;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
134 keymap[QZ_LALT] = SDLK_LALT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
135 keymap[QZ_LMETA] = SDLK_LMETA;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
136 keymap[QZ_SPACE] = SDLK_SPACE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
137 keymap[QZ_LEFT] = SDLK_LEFT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
138 keymap[QZ_DOWN] = SDLK_DOWN;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
139 keymap[QZ_RIGHT] = SDLK_RIGHT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
140 keymap[QZ_KP0] = SDLK_KP0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
141 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
142 keymap[QZ_IBOOK_ENTER] = SDLK_KP_ENTER;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
143 keymap[QZ_IBOOK_RIGHT] = SDLK_RIGHT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
144 keymap[QZ_IBOOK_DOWN] = SDLK_DOWN;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
145 keymap[QZ_IBOOK_UP] = SDLK_UP;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
146 keymap[QZ_IBOOK_LEFT] = SDLK_LEFT;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
147
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
148 /* Up there we setup a static scancode->keysym map. However, it will not
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
149 * work very well on international keyboard. Hence we now query MacOS
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
150 * for its own keymap to adjust our own mapping table. However, this is
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
151 * bascially only useful for ascii char keys. This is also the reason
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
152 * why we keep the static table, too.
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
153 */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
154
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
155 /* Get a pointer to the systems cached KCHR */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
156 KCHRPtr = (void *)GetScriptManagerVariable(smKCHRCache);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
157 if (KCHRPtr)
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
158 {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
159 /* Loop over all 127 possible scan codes */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
160 for (i = 0; i < 0x7F; i++)
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
161 {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
162 /* We pretend a clean start to begin with (i.e. no dead keys active */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
163 state = 0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
164
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
165 /* Now translate the key code to a key value */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
166 value = KeyTranslate(KCHRPtr, i, &state) & 0xff;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
167
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
168 /* If the state become 0, it was a dead key. We need to translate again,
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
169 passing in the new state, to get the actual key value */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
170 if (state != 0)
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
171 value = KeyTranslate(KCHRPtr, i, &state) & 0xff;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
172
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
173 /* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
174 if (value >= 128) /* Some non-ASCII char, map it to SDLK_WORLD_* */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
175 keymap[i] = world++;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
176 else if (value >= 32) /* non-control ASCII char */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
177 keymap[i] = value;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
178 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
179 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
180
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
181 /* The keypad codes are re-setup here, because the loop above cannot
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
182 * distinguish between a key on the keypad and a regular key. We maybe
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
183 * could get around this problem in another fashion: NSEvent's flags
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
184 * include a "NSNumericPadKeyMask" bit; we could check that and modify
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
185 * the symbol we return on the fly. However, this flag seems to exhibit
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
186 * some weird behaviour related to the num lock key
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
187 */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
188 keymap[QZ_KP0] = SDLK_KP0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
189 keymap[QZ_KP1] = SDLK_KP1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
190 keymap[QZ_KP2] = SDLK_KP2;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
191 keymap[QZ_KP3] = SDLK_KP3;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
192 keymap[QZ_KP4] = SDLK_KP4;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
193 keymap[QZ_KP5] = SDLK_KP5;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
194 keymap[QZ_KP6] = SDLK_KP6;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
195 keymap[QZ_KP7] = SDLK_KP7;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
196 keymap[QZ_KP8] = SDLK_KP8;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
197 keymap[QZ_KP9] = SDLK_KP9;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
198 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
199 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
200 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
201 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
202 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
203 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
204 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
205 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207 static void QZ_DoKey (int state, NSEvent *event) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
209 NSString *chars;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
210 int i;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
211 SDL_keysym key;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
212
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
213 /* An event can contain multiple characters */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
214 /* I'll ignore this fact for now, since there is only one virtual key code per event */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
215 chars = [ event characters ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
216 for (i =0; i < 1 /*[ chars length ] */; i++) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
217
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
218 key.scancode = [ event keyCode ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
219 key.sym = keymap [ key.scancode ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
220 key.unicode = [ chars characterAtIndex:i];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
221 key.mod = KMOD_NONE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
222
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
223 SDL_PrivateKeyboard (state, &key);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
224 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
225 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 static void QZ_DoModifiers (unsigned int newMods) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
229 const int mapping[] = { SDLK_CAPSLOCK, SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA } ;
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
230
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
231 int i;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
232 int bit;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
233 SDL_keysym key;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
235 key.scancode = 0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
236 key.sym = SDLK_UNKNOWN;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
237 key.unicode = 0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
238 key.mod = KMOD_NONE;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
239
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
240 /* Iterate through the bits, testing each against the current modifiers */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
241 for (i = 0, bit = NSAlphaShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
242
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
243 unsigned int currentMask, newMask;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
244
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
245 currentMask = currentMods & bit;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
246 newMask = newMods & bit;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
247
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
248 if ( currentMask &&
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
249 currentMask != newMask ) { /* modifier up event */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
251 key.sym = mapping[i];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
252 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
253 if (bit == NSAlphaShiftKeyMask)
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
254 SDL_PrivateKeyboard (SDL_PRESSED, &key);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
255 SDL_PrivateKeyboard (SDL_RELEASED, &key);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
256 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
257 else
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
258 if ( newMask &&
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
259 currentMask != newMask ) { /* modifier down event */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
260
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
261 key.sym = mapping[i];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
262 SDL_PrivateKeyboard (SDL_PRESSED, &key);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
263 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
264 if (bit == NSAlphaShiftKeyMask)
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
265 SDL_PrivateKeyboard (SDL_RELEASED, &key);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
266 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
267 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
268
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
269 currentMods = newMods;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271
117
aac75d5f7869 Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 47
diff changeset
272 static void QZ_DoActivate (_THIS)
aac75d5f7869 Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 47
diff changeset
273 {
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
274 inForeground = YES;
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
275
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
276 /* Regrab the mouse */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
277 if (currentGrabMode == SDL_GRAB_ON) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
278 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
279 CGAssociateMouseAndMouseCursorPosition (0);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
280 }
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
281
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
282 /* Hide the mouse cursor if inside the app window */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
283 if (!QZ_cursor_visible) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
284 HideCursor ();
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
285 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
286
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
287 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 static void QZ_DoDeactivate (_THIS) {
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
291
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
292 inForeground = NO;
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
293
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
294 /* Ungrab mouse if it is grabbed */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
295 if (currentGrabMode == SDL_GRAB_ON) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
296 CGAssociateMouseAndMouseCursorPosition (1);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
297 }
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
298
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
299 /* Show the mouse cursor */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
300 if (!QZ_cursor_visible) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
301 ShowCursor ();
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
302 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
303
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
304 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306
117
aac75d5f7869 Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 47
diff changeset
307 static void QZ_PumpEvents (_THIS)
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
308 {
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
309 static NSPoint lastMouse;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
310 NSPoint mouse, saveMouse;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
311 Point qdMouse;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
312 CGMouseDelta dx, dy;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
313
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
314 NSDate *distantPast;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
315 NSEvent *event;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
316 NSRect titleBarRect;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
317 NSAutoreleasePool *pool;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
318
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
319 pool = [ [ NSAutoreleasePool alloc ] init ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
320 distantPast = [ NSDate distantPast ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
321
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
322 titleBarRect = NSMakeRect ( 0, SDL_VideoSurface->h, SDL_VideoSurface->w,
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
323 SDL_VideoSurface->h + 22 );
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
324
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
325 if (currentGrabMode != SDL_GRAB_ON) { /* if grabbed, the cursor can't move! (see fallback below) */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
326
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
327 /* 1/2 second after a warp, the mouse cannot move (don't ask me why) */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
328 /* So, approximate motion with CGGetLastMouseDelta, which still works, somehow */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
329 if (! warp_flag) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
330
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
331 GetGlobalMouse (&qdMouse); /* use Carbon since [ NSEvent mouseLocation ] is broken */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
332 mouse = NSMakePoint (qdMouse.h, qdMouse.v);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
333 saveMouse = mouse;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
334
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
335 if (mouse.x != lastMouse.x || mouse.y != lastMouse.y) {
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
336
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
337 QZ_PrivateCGToSDL (this, &mouse);
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
338 if (inForeground) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
339 //printf ("Mouse Loc: (%f, %f)\n", mouse.x, mouse.y);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
340 SDL_PrivateMouseMotion (0, 0, mouse.x, mouse.y);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
341 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
342 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
343 lastMouse = saveMouse;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
344 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
345 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
346
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
347 /* accumulate any mouse events into one SDL mouse event */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
348 dx = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
349 dy = 0;
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
350
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
351 do {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
352
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
353 /* Poll for an event. This will not block */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
354 event = [ NSApp nextEventMatchingMask:NSAnyEventMask
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
355 untilDate:distantPast
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
356 inMode: NSDefaultRunLoopMode dequeue:YES ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
357
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
358 if (event != nil) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
359 unsigned int type;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
360 BOOL isForGameWin;
117
aac75d5f7869 Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 47
diff changeset
361
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
362 #define DO_MOUSE_DOWN(button, sendToWindow) do { \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
363 if ( inForeground ) { \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
364 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
365 } \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
366 else { \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
367 QZ_DoActivate (this); \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
368 } \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
369 [ NSApp sendEvent:event ]; \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
370 } while(0)
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
371
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
372 #define DO_MOUSE_UP(button, sendToWindow) do { \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
373 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
374 !NSPointInRect([event locationInWindow], titleBarRect) ) \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
375 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
376 [ NSApp sendEvent:event ]; \
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
377 } while(0)
158
4382c38dfbee Date: Tue, 21 Aug 2001 03:50:01 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 155
diff changeset
378
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
379 type = [ event type ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
380 isForGameWin = (qz_window == [ event window ]);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
381 switch (type) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
382
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
383 case NSLeftMouseDown:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
384 if ( NSCommandKeyMask & currentMods ) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
385 last_virtual_button = 3;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
386 DO_MOUSE_DOWN (3, 0);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
387 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
388 else if ( NSAlternateKeyMask & currentMods ) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
389 last_virtual_button = 2;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
390 DO_MOUSE_DOWN (2, 0);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
391 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
392 else {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
393 DO_MOUSE_DOWN (1, 1);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
394 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
395 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
396 case NSOtherMouseDown: DO_MOUSE_DOWN (2, 0); break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
397 case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
398 case NSLeftMouseUp:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
399
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
400 if ( last_virtual_button != 0 ) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
401 DO_MOUSE_UP (last_virtual_button, 0);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
402 last_virtual_button = 0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
403 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
404 else {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
405 DO_MOUSE_UP (1, 1);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
406 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
407 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
408 case NSOtherMouseUp: DO_MOUSE_UP (2, 0); break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
409 case NSRightMouseUp: DO_MOUSE_UP (3, 0); break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
410 case NSSystemDefined:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
411 //if ([event subtype] == 7) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
412 // unsigned int buttons; // up to 32 mouse button states!
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
413 // buttons = [ event data2 ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
414 //}
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
415 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
416 case NSLeftMouseDragged:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
417 case NSRightMouseDragged:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
418 case 27:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
419 case NSMouseMoved:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
420 if (currentGrabMode == SDL_GRAB_ON) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
421
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
422 /**
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
423 * If input is grabbed, we'll wing it and try to send some mouse
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
424 * moved events with CGGetLastMouseDelta(). Not optimal, but better
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
425 * than nothing.
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
426 **/
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
427 CGMouseDelta dx1, dy1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
428 CGGetLastMouseDelta (&dx1, &dy1);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
429 dx += dx1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
430 dy += dy1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
431 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
432 else if (warp_flag) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
433
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
434 Uint32 ticks;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
435
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
436 ticks = SDL_GetTicks();
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
437 if (ticks - warp_ticks < 150) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
438
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
439 CGMouseDelta dx1, dy1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
440 CGGetLastMouseDelta (&dx1, &dy1);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
441 dx += dx1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
442 dy += dy1;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
443 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
444 else {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
445
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
446 warp_flag = 0;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
447 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
448 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
449 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
450 case NSScrollWheel:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
451 {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
452 float dy;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
453 dy = [ event deltaY ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
454 if ( dy > 0.0 ) /* Scroll up */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
455 SDL_PrivateMouseButton (SDL_PRESSED, 4, 0, 0);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
456 else /* Scroll down */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
457 SDL_PrivateMouseButton (SDL_PRESSED, 5, 0, 0);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
458 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
459 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
460 case NSKeyUp:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
461 QZ_DoKey (SDL_RELEASED, event);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
462 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
463 case NSKeyDown:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
464 QZ_DoKey (SDL_PRESSED, event);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
465 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
466 case NSFlagsChanged:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
467 QZ_DoModifiers( [ event modifierFlags ] );
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
468 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
469 case NSAppKitDefined:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
470 switch ( [ event subtype ] ) {
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
471 case NSApplicationActivatedEventType:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
472 QZ_DoActivate (this);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
473 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
474 case NSApplicationDeactivatedEventType:
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
475 QZ_DoDeactivate (this);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
476 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
477 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
478 [ NSApp sendEvent:event ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
479 break;
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
480 /* case NSApplicationDefined: break; */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
481 /* case NSPeriodic: break; */
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
482 /* case NSCursorUpdate: break; */
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
483
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
484 default:
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
485 [ NSApp sendEvent:event ];
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
486 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
487 }
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
488 } while (event != nil);
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
489
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
490 /* check for accumulated mouse events */
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
491 if (dx != 0 || dy != 0)
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
492 SDL_PrivateMouseMotion (0, 1, dx, dy);
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
493
388
4e9044b378fd *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
494 [ pool release ];
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
495 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
496