Skip to content

Latest commit

 

History

History
1064 lines (925 loc) · 39.2 KB

SDL_QuartzEvents.m

File metadata and controls

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