Mercurial > sdl-ios-xcode
annotate src/video/quartz/SDL_QuartzEvents.m @ 624:fb78cadbfeb8
More-than-three mouse button support for Quartz target.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 27 May 2003 07:33:11 +0000 |
parents | bf816ce70144 |
children | 52864d66d168 |
rev | line source |
---|---|
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
1 /* |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
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 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
7 License as published by the Free Software Foundation; either |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
9 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
13 Library General Public License for more details. |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
14 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
16 License along with this library; if not, write to the Free |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
18 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
19 Sam Lantinga |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
20 slouken@libsdl.org |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
21 */ |
511
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
22 #include <stdlib.h> // For getenv() |
555 | 23 #include <IOKit/IOMessage.h> // For wake from sleep detection |
24 #include <IOKit/pwr_mgt/IOPMLib.h> // For wake from sleep detection | |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
25 #include "SDL_QuartzKeys.h" |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
26 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
27 static void QZ_InitOSKeymap (_THIS) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
28 const void *KCHRPtr; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
29 UInt32 state; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
30 UInt32 value; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
31 int i; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
32 int world = SDLK_WORLD_0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
33 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
34 for ( i=0; i<SDL_TABLESIZE(keymap); ++i ) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
35 keymap[i] = SDLK_UNKNOWN; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
36 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
37 /* This keymap is almost exactly the same as the OS 9 one */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
38 keymap[QZ_ESCAPE] = SDLK_ESCAPE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
39 keymap[QZ_F1] = SDLK_F1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
40 keymap[QZ_F2] = SDLK_F2; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
41 keymap[QZ_F3] = SDLK_F3; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
42 keymap[QZ_F4] = SDLK_F4; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
43 keymap[QZ_F5] = SDLK_F5; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
44 keymap[QZ_F6] = SDLK_F6; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
45 keymap[QZ_F7] = SDLK_F7; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
46 keymap[QZ_F8] = SDLK_F8; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
47 keymap[QZ_F9] = SDLK_F9; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
48 keymap[QZ_F10] = SDLK_F10; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
49 keymap[QZ_F11] = SDLK_F11; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
50 keymap[QZ_F12] = SDLK_F12; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
51 keymap[QZ_PRINT] = SDLK_PRINT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
52 keymap[QZ_SCROLLOCK] = SDLK_SCROLLOCK; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
53 keymap[QZ_PAUSE] = SDLK_PAUSE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
54 keymap[QZ_POWER] = SDLK_POWER; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
55 keymap[QZ_BACKQUOTE] = SDLK_BACKQUOTE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
56 keymap[QZ_1] = SDLK_1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
57 keymap[QZ_2] = SDLK_2; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
58 keymap[QZ_3] = SDLK_3; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
59 keymap[QZ_4] = SDLK_4; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
60 keymap[QZ_5] = SDLK_5; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
61 keymap[QZ_6] = SDLK_6; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
62 keymap[QZ_7] = SDLK_7; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
63 keymap[QZ_8] = SDLK_8; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
64 keymap[QZ_9] = SDLK_9; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
65 keymap[QZ_0] = SDLK_0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
66 keymap[QZ_MINUS] = SDLK_MINUS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
67 keymap[QZ_EQUALS] = SDLK_EQUALS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
68 keymap[QZ_BACKSPACE] = SDLK_BACKSPACE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
69 keymap[QZ_INSERT] = SDLK_INSERT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
70 keymap[QZ_HOME] = SDLK_HOME; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
71 keymap[QZ_PAGEUP] = SDLK_PAGEUP; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
72 keymap[QZ_NUMLOCK] = SDLK_NUMLOCK; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
73 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
74 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
75 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
76 keymap[QZ_TAB] = SDLK_TAB; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
77 keymap[QZ_q] = SDLK_q; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
78 keymap[QZ_w] = SDLK_w; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
79 keymap[QZ_e] = SDLK_e; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
80 keymap[QZ_r] = SDLK_r; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
81 keymap[QZ_t] = SDLK_t; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
82 keymap[QZ_y] = SDLK_y; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
83 keymap[QZ_u] = SDLK_u; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
84 keymap[QZ_i] = SDLK_i; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
85 keymap[QZ_o] = SDLK_o; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
86 keymap[QZ_p] = SDLK_p; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
87 keymap[QZ_LEFTBRACKET] = SDLK_LEFTBRACKET; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
88 keymap[QZ_RIGHTBRACKET] = SDLK_RIGHTBRACKET; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
89 keymap[QZ_BACKSLASH] = SDLK_BACKSLASH; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
90 keymap[QZ_DELETE] = SDLK_DELETE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
91 keymap[QZ_END] = SDLK_END; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
92 keymap[QZ_PAGEDOWN] = SDLK_PAGEDOWN; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
93 keymap[QZ_KP7] = SDLK_KP7; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
94 keymap[QZ_KP8] = SDLK_KP8; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
95 keymap[QZ_KP9] = SDLK_KP9; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
96 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
97 keymap[QZ_CAPSLOCK] = SDLK_CAPSLOCK; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
98 keymap[QZ_a] = SDLK_a; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
99 keymap[QZ_s] = SDLK_s; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
100 keymap[QZ_d] = SDLK_d; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
101 keymap[QZ_f] = SDLK_f; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
102 keymap[QZ_g] = SDLK_g; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
103 keymap[QZ_h] = SDLK_h; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
104 keymap[QZ_j] = SDLK_j; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
105 keymap[QZ_k] = SDLK_k; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
106 keymap[QZ_l] = SDLK_l; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
107 keymap[QZ_SEMICOLON] = SDLK_SEMICOLON; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
108 keymap[QZ_QUOTE] = SDLK_QUOTE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
109 keymap[QZ_RETURN] = SDLK_RETURN; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
110 keymap[QZ_KP4] = SDLK_KP4; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
111 keymap[QZ_KP5] = SDLK_KP5; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
112 keymap[QZ_KP6] = SDLK_KP6; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
113 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
114 keymap[QZ_LSHIFT] = SDLK_LSHIFT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
115 keymap[QZ_z] = SDLK_z; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
116 keymap[QZ_x] = SDLK_x; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
117 keymap[QZ_c] = SDLK_c; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
118 keymap[QZ_v] = SDLK_v; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
119 keymap[QZ_b] = SDLK_b; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
120 keymap[QZ_n] = SDLK_n; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
121 keymap[QZ_m] = SDLK_m; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
122 keymap[QZ_COMMA] = SDLK_COMMA; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
123 keymap[QZ_PERIOD] = SDLK_PERIOD; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
124 keymap[QZ_SLASH] = SDLK_SLASH; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
125 keymap[QZ_UP] = SDLK_UP; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
126 keymap[QZ_KP1] = SDLK_KP1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
127 keymap[QZ_KP2] = SDLK_KP2; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
128 keymap[QZ_KP3] = SDLK_KP3; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
129 keymap[QZ_KP_ENTER] = SDLK_KP_ENTER; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
130 keymap[QZ_LCTRL] = SDLK_LCTRL; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
131 keymap[QZ_LALT] = SDLK_LALT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
132 keymap[QZ_LMETA] = SDLK_LMETA; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
133 keymap[QZ_SPACE] = SDLK_SPACE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
134 keymap[QZ_LEFT] = SDLK_LEFT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
135 keymap[QZ_DOWN] = SDLK_DOWN; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
136 keymap[QZ_RIGHT] = SDLK_RIGHT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
137 keymap[QZ_KP0] = SDLK_KP0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
138 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
139 keymap[QZ_IBOOK_ENTER] = SDLK_KP_ENTER; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
140 keymap[QZ_IBOOK_RIGHT] = SDLK_RIGHT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
141 keymap[QZ_IBOOK_DOWN] = SDLK_DOWN; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
142 keymap[QZ_IBOOK_UP] = SDLK_UP; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
143 keymap[QZ_IBOOK_LEFT] = SDLK_LEFT; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
144 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
145 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
146 Up there we setup a static scancode->keysym map. However, it will not |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
147 work very well on international keyboard. Hence we now query MacOS |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
148 for its own keymap to adjust our own mapping table. However, this is |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
149 basically only useful for ascii char keys. This is also the reason |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
150 why we keep the static table, too. |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
151 */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
152 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
153 /* Get a pointer to the systems cached KCHR */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
154 KCHRPtr = (void *)GetScriptManagerVariable(smKCHRCache); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
155 if (KCHRPtr) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
156 { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
157 /* Loop over all 127 possible scan codes */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
158 for (i = 0; i < 0x7F; i++) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
159 { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
160 /* We pretend a clean start to begin with (i.e. no dead keys active */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
161 state = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
162 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
163 /* Now translate the key code to a key value */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
164 value = KeyTranslate(KCHRPtr, i, &state) & 0xff; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
165 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
166 /* If the state become 0, it was a dead key. We need to translate again, |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
167 passing in the new state, to get the actual key value */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
168 if (state != 0) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
169 value = KeyTranslate(KCHRPtr, i, &state) & 0xff; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
170 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
171 /* Now we should have an ascii value, or 0. Try to figure out to which SDL symbol it maps */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
172 if (value >= 128) /* Some non-ASCII char, map it to SDLK_WORLD_* */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
173 keymap[i] = world++; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
174 else if (value >= 32) /* non-control ASCII char */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
175 keymap[i] = value; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
176 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
177 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
178 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
179 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
180 The keypad codes are re-setup here, because the loop above cannot |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
181 distinguish between a key on the keypad and a regular key. We maybe |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
182 could get around this problem in another fashion: NSEvent's flags |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
183 include a "NSNumericPadKeyMask" bit; we could check that and modify |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
184 the symbol we return on the fly. However, this flag seems to exhibit |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
185 some weird behaviour related to the num lock key |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
186 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
187 keymap[QZ_KP0] = SDLK_KP0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
188 keymap[QZ_KP1] = SDLK_KP1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
189 keymap[QZ_KP2] = SDLK_KP2; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
190 keymap[QZ_KP3] = SDLK_KP3; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
191 keymap[QZ_KP4] = SDLK_KP4; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
192 keymap[QZ_KP5] = SDLK_KP5; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
193 keymap[QZ_KP6] = SDLK_KP6; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
194 keymap[QZ_KP7] = SDLK_KP7; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
195 keymap[QZ_KP8] = SDLK_KP8; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
196 keymap[QZ_KP9] = SDLK_KP9; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
197 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
198 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
199 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
200 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
201 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
202 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
203 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
|
204 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
205 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
206 static void QZ_DoKey (_THIS, int state, NSEvent *event) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
207 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
208 NSString *chars; |
561
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
209 unsigned int numChars; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
210 SDL_keysym key; |
561
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
211 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
212 /* |
561
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
213 A key event can contain multiple characters, |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
214 or no characters at all. In most cases, it |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
215 will contain a single character. If it contains |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
216 0 characters, we'll use 0 as the unicode. If it |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
217 contains multiple characters, we'll use 0 as |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
218 the scancode/keysym. |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
219 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
220 chars = [ event characters ]; |
561
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
221 numChars = [ chars length ]; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
222 |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
223 if (numChars == 1) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
224 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
225 key.scancode = [ event keyCode ]; |
561
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
226 key.sym = keymap [ key.scancode ]; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
227 key.unicode = [ chars characterAtIndex:0 ]; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
228 key.mod = KMOD_NONE; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
229 |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
230 SDL_PrivateKeyboard (state, &key); |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
231 } |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
232 else if (numChars == 0) { |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
233 |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
234 key.scancode = [ event keyCode ]; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
235 key.sym = keymap [ key.scancode ]; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
236 key.unicode = 0; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
237 key.mod = KMOD_NONE; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
238 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
239 SDL_PrivateKeyboard (state, &key); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
240 } |
561
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
241 else /* (numChars > 1) */ { |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
242 |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
243 int i; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
244 for (i = 0; i < numChars; i++) { |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
245 |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
246 key.scancode = 0; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
247 key.sym = 0; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
248 key.unicode = [ chars characterAtIndex:i]; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
249 key.mod = KMOD_NONE; |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
250 |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
251 SDL_PrivateKeyboard (state, &key); |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
252 } |
4bcf7dd06c47
Date: Sat, 14 Dec 2002 13:33:05 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
555
diff
changeset
|
253 } |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
254 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
255 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
256 static void QZ_DoModifiers (_THIS, unsigned int newMods) { |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
257 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
258 const int mapping[] = { SDLK_CAPSLOCK, SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, SDLK_LMETA } ; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
259 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
260 int i; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
261 int bit; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
262 SDL_keysym key; |
172
37e3ca9254c7
Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
263 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
264 key.scancode = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
265 key.sym = SDLK_UNKNOWN; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
266 key.unicode = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
267 key.mod = KMOD_NONE; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
268 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
269 /* Iterate through the bits, testing each against the current modifiers */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
270 for (i = 0, bit = NSAlphaShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1, ++i) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
271 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
272 unsigned int currentMask, newMask; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
273 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
274 currentMask = current_mods & bit; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
275 newMask = newMods & bit; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
276 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
277 if ( currentMask && |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
278 currentMask != newMask ) { /* modifier up event */ |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
279 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
280 key.sym = mapping[i]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
281 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
282 if (bit == NSAlphaShiftKeyMask) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
283 SDL_PrivateKeyboard (SDL_PRESSED, &key); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
284 SDL_PrivateKeyboard (SDL_RELEASED, &key); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
285 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
286 else if ( newMask && |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
287 currentMask != newMask ) { /* modifier down event */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
288 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
289 key.sym = mapping[i]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
290 SDL_PrivateKeyboard (SDL_PRESSED, &key); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
291 /* If this was Caps Lock, we need some additional voodoo to make SDL happy */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
292 if (bit == NSAlphaShiftKeyMask) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
293 SDL_PrivateKeyboard (SDL_RELEASED, &key); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
294 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
295 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
296 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
297 current_mods = newMods; |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
298 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
299 |
117
aac75d5f7869
Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
47
diff
changeset
|
300 static void QZ_DoActivate (_THIS) |
aac75d5f7869
Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
47
diff
changeset
|
301 { |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
302 in_foreground = YES; |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
303 |
615
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
304 /* Hide the cursor if it was hidden by SDL_ShowCursor() */ |
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
305 if (!cursor_visible && !cursor_hidden) { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
306 HideCursor (); |
615
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
307 cursor_hidden = YES; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
308 } |
172
37e3ca9254c7
Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
309 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
310 /* Regrab input, only if it was previously grabbed */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
311 if ( current_grab_mode == SDL_GRAB_ON ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
312 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
313 /* Restore cursor location if input was grabbed */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
314 QZ_PrivateWarpCursor (this, cursor_loc.x, cursor_loc.y); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
315 QZ_ChangeGrabState (this, QZ_ENABLE_GRAB); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
316 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
317 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
318 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
319 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
320 |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
321 static void QZ_DoDeactivate (_THIS) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
322 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
323 in_foreground = NO; |
168
e92aa316c517
Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents:
158
diff
changeset
|
324 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
325 /* Get the current cursor location, for restore on activate */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
326 cursor_loc = [ NSEvent mouseLocation ]; /* global coordinates */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
327 if (qz_window) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
328 QZ_PrivateGlobalToLocal (this, &cursor_loc); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
329 QZ_PrivateCocoaToSDL (this, &cursor_loc); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
330 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
331 /* Reassociate mouse and cursor */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
332 CGAssociateMouseAndMouseCursorPosition (1); |
172
37e3ca9254c7
Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
168
diff
changeset
|
333 |
615
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
334 /* Show the cursor if it was hidden by SDL_ShowCursor() */ |
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
335 if (!cursor_visible && cursor_hidden) { |
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
336 ShowCursor (); |
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
337 cursor_hidden = NO; |
7ec821f3cbd0
Date: Thu, 17 Apr 2003 23:27:34 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
563
diff
changeset
|
338 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
339 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
340 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); |
47
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
341 } |
45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff
changeset
|
342 |
555 | 343 void QZ_SleepNotificationHandler (void * refcon, |
344 io_service_t service, | |
345 natural_t messageType, | |
346 void * messageArgument ) | |
347 { | |
348 SDL_VideoDevice *this = (SDL_VideoDevice*)refcon; | |
349 | |
350 switch(messageType) | |
351 { | |
352 case kIOMessageSystemWillSleep: | |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
353 IOAllowPowerChange(power_connection, (long) messageArgument); |
555 | 354 break; |
355 case kIOMessageCanSystemSleep: | |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
356 IOAllowPowerChange(power_connection, (long) messageArgument); |
555 | 357 break; |
358 case kIOMessageSystemHasPoweredOn: | |
359 /* awake */ | |
360 SDL_PrivateExpose(); | |
361 break; | |
362 } | |
363 } | |
364 | |
365 static void QZ_RegisterForSleepNotifications (_THIS) | |
366 { | |
367 CFRunLoopSourceRef rls; | |
368 IONotificationPortRef thePortRef; | |
369 io_object_t notifier; | |
370 | |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
371 power_connection = IORegisterForSystemPower (this, &thePortRef, QZ_SleepNotificationHandler, ¬ifier); |
555 | 372 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
373 if (power_connection == 0) |
555 | 374 NSLog(@"SDL: QZ_SleepNotificationHandler() IORegisterForSystemPower failed."); |
375 | |
376 rls = IONotificationPortGetRunLoopSource (thePortRef); | |
377 CFRunLoopAddSource (CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode); | |
378 CFRelease (rls); | |
379 } | |
380 | |
624
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
381 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
382 // Try to map Quartz mouse buttons to SDL's lingo... |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
383 static int QZ_OtherMouseButtonToSDL(int button) |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
384 { |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
385 switch (button) |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
386 { |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
387 case 0: |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
388 return(SDL_BUTTON_LEFT); // 1 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
389 case 1: |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
390 return(SDL_BUTTON_RIGHT); // 3 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
391 case 2: |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
392 return(SDL_BUTTON_MIDDLE); // 2 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
393 } |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
394 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
395 // >= 3: skip 4 & 5, since those are the SDL mousewheel buttons. |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
396 return(button + 3); |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
397 } |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
398 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
399 |
117
aac75d5f7869
Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
47
diff
changeset
|
400 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
|
401 { |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
402 int firstMouseEvent; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
403 CGMouseDelta dx, dy; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
404 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
405 NSDate *distantPast; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
406 NSEvent *event; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
407 NSRect winRect; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
408 NSRect titleBarRect; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
409 NSAutoreleasePool *pool; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
410 |
619
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
411 /* Update activity every five seconds to prevent screensaver. --ryan. */ |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
412 static Uint32 screensaverTicks = 0; |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
413 Uint32 nowTicks = SDL_GetTicks(); |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
414 if ((nowTicks - screensaverTicks) > 5000) |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
415 { |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
416 UpdateSystemActivity(UsrActivity); |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
417 screensaverTicks = nowTicks; |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
418 } |
bf816ce70144
Disable MacOS X screensaver for duration of application run by triggering a
Ryan C. Gordon <icculus@icculus.org>
parents:
615
diff
changeset
|
419 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
420 pool = [ [ NSAutoreleasePool alloc ] init ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
421 distantPast = [ NSDate distantPast ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
422 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
423 winRect = NSMakeRect (0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h); |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
424 titleBarRect = NSMakeRect (0, SDL_VideoSurface->h, SDL_VideoSurface->w, |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
425 SDL_VideoSurface->h + 22); |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
426 |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
427 /* send the first mouse event in absolute coordinates */ |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
428 firstMouseEvent = 1; |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
429 |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
430 /* accumulate any additional mouse moved events into one SDL mouse event */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
431 dx = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
432 dy = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
433 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
434 do { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
435 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
436 /* Poll for an event. This will not block */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
437 event = [ NSApp nextEventMatchingMask:NSAnyEventMask |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
438 untilDate:distantPast |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
439 inMode: NSDefaultRunLoopMode dequeue:YES ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
440 if (event != nil) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
441 |
624
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
442 int button; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
443 unsigned int type; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
444 BOOL isForGameWin; |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
445 BOOL isInGameWin; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
446 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
447 #define DO_MOUSE_DOWN(button) do { \ |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
448 if ( in_foreground ) { \ |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
449 if ( isInGameWin ) { \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
450 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
451 expect_mouse_up |= 1<<button; \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
452 } \ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
453 } \ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
454 else { \ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
455 QZ_DoActivate (this); \ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
456 } \ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
457 [ NSApp sendEvent:event ]; \ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
458 } while(0) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
459 |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
460 #define DO_MOUSE_UP(button) do { \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
461 if ( expect_mouse_up & (1<<button) ) { \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
462 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
463 expect_mouse_up &= ~(1<<button); \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
464 } \ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
465 [ NSApp sendEvent:event ]; \ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
466 } while(0) |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
467 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
468 type = [ event type ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
469 isForGameWin = (qz_window == [ event window ]); |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
470 isInGameWin = NSPointInRect([event locationInWindow], winRect); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
471 switch (type) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
472 case NSLeftMouseDown: |
511
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
473 if ( getenv("SDL_HAS3BUTTONMOUSE") ) { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
474 DO_MOUSE_DOWN (SDL_BUTTON_LEFT); |
511
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
475 } else { |
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
476 if ( NSCommandKeyMask & current_mods ) { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
477 last_virtual_button = SDL_BUTTON_RIGHT; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
478 DO_MOUSE_DOWN (SDL_BUTTON_RIGHT); |
511
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
479 } |
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
480 else if ( NSAlternateKeyMask & current_mods ) { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
481 last_virtual_button = SDL_BUTTON_MIDDLE; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
482 DO_MOUSE_DOWN (SDL_BUTTON_MIDDLE); |
511
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
483 } |
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
484 else { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
485 DO_MOUSE_DOWN (SDL_BUTTON_LEFT); |
511
79c189f5bd76
Added an environment variable SDL_HAS3BUTTONMOUSE for Quartz
Sam Lantinga <slouken@libsdl.org>
parents:
502
diff
changeset
|
486 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
487 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
488 break; |
624
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
489 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
490 case NSLeftMouseUp: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
491 if ( last_virtual_button != 0 ) { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
492 DO_MOUSE_UP (last_virtual_button); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
493 last_virtual_button = 0; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
494 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
495 else { |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
496 DO_MOUSE_UP (SDL_BUTTON_LEFT); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
497 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
498 break; |
624
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
499 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
500 case NSOtherMouseDown: |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
501 case NSRightMouseDown: |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
502 button = QZ_OtherMouseButtonToSDL([ event buttonNumber ]); |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
503 DO_MOUSE_DOWN (button); |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
504 break; |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
505 |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
506 case NSOtherMouseUp: |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
507 case NSRightMouseUp: |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
508 button = QZ_OtherMouseButtonToSDL([ event buttonNumber ]); |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
509 DO_MOUSE_UP (button); |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
510 break; |
fb78cadbfeb8
More-than-three mouse button support for Quartz target.
Ryan C. Gordon <icculus@icculus.org>
parents:
619
diff
changeset
|
511 |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
512 case NSSystemDefined: |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
513 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
514 Future: up to 32 "mouse" buttons can be handled. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
515 if ([event subtype] == 7) { |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
516 unsigned int buttons; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
517 buttons = [ event data2 ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
518 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
519 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
520 case NSLeftMouseDragged: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
521 case NSRightMouseDragged: |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
522 case NSOtherMouseDragged: /* usually middle mouse dragged */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
523 case NSMouseMoved: |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
524 if ( grab_state == QZ_INVISIBLE_GRAB ) { |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
525 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
526 /* |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
527 If input is grabbed+hidden, the cursor doesn't move, |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
528 so we have to call the lowlevel window server |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
529 function. This is less accurate but works OK. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
530 */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
531 CGMouseDelta dx1, dy1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
532 CGGetLastMouseDelta (&dx1, &dy1); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
533 dx += dx1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
534 dy += dy1; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
535 } |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
536 else if (firstMouseEvent) { |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
537 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
538 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
539 Get the first mouse event in a possible |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
540 sequence of mouse moved events. Since we |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
541 use absolute coordinates, this serves to |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
542 compensate any inaccuracy in deltas, and |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
543 provides the first known mouse position, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
544 since everything after this uses deltas |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
545 */ |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
546 NSPoint p = [ event locationInWindow ]; |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
547 QZ_PrivateCocoaToSDL (this, &p); |
454
c4338ecf45f9
Fixed mouse motion on MacOS X (recently broken)
Sam Lantinga <slouken@libsdl.org>
parents:
435
diff
changeset
|
548 SDL_PrivateMouseMotion (0, 0, p.x, p.y); |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
549 firstMouseEvent = 0; |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
550 } |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
551 else { |
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
552 |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
553 /* |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
554 Get the amount moved since the last drag or move event, |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
555 add it on for one big move event at the end. |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
556 */ |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
557 dx += [ event deltaX ]; |
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
558 dy += [ event deltaY ]; |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
559 } |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
560 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
561 /* |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
562 Handle grab input+cursor visible by warping the cursor back |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
563 into the game window. This still generates a mouse moved event, |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
564 but not as a result of the warp (so it's in the right direction). |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
565 */ |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
566 if ( grab_state == QZ_VISIBLE_GRAB && |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
567 !isInGameWin ) { |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
568 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
569 NSPoint p = [ event locationInWindow ]; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
570 QZ_PrivateCocoaToSDL (this, &p); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
571 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
572 if ( p.x < 0.0 ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
573 p.x = 0.0; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
574 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
575 if ( p.y < 0.0 ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
576 p.y = 0.0; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
577 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
578 if ( p.x >= winRect.size.width ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
579 p.x = winRect.size.width-1; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
580 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
581 if ( p.y >= winRect.size.height ) |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
582 p.y = winRect.size.height-1; |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
583 |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
584 QZ_PrivateWarpCursor (this, p.x, p.y); |
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
585 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
586 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
587 case NSScrollWheel: |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
588 if ( isInGameWin ) { |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
589 float dy; |
502
80a3d09bab29
Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
590 Uint8 button; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
591 dy = [ event deltaY ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
592 if ( dy > 0.0 ) /* Scroll up */ |
502
80a3d09bab29
Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
593 button = SDL_BUTTON_WHEELUP; |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
594 else /* Scroll down */ |
502
80a3d09bab29
Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
595 button = SDL_BUTTON_WHEELDOWN; |
563
04dcaf3da918
Massive Quartz input enhancements from Darrell Walisser. His email:
Ryan C. Gordon <icculus@icculus.org>
parents:
561
diff
changeset
|
596 /* For now, wheel is sent as a quick down+up */ |
502
80a3d09bab29
Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
597 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); |
80a3d09bab29
Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
598 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
599 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
600 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
601 case NSKeyUp: |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
602 QZ_DoKey (this, SDL_RELEASED, event); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
603 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
604 case NSKeyDown: |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
605 QZ_DoKey (this, SDL_PRESSED, event); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
606 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
607 case NSFlagsChanged: |
501
74262d2647ca
Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents:
454
diff
changeset
|
608 QZ_DoModifiers(this, [ event modifierFlags ] ); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
609 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
610 case NSAppKitDefined: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
611 switch ( [ event subtype ] ) { |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
612 case NSApplicationActivatedEventType: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
613 QZ_DoActivate (this); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
614 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
615 case NSApplicationDeactivatedEventType: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
616 QZ_DoDeactivate (this); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
617 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
618 } |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
619 [ NSApp sendEvent:event ]; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
620 break; |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
621 /* case NSApplicationDefined: break; */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
622 /* case NSPeriodic: break; */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
623 /* case NSCursorUpdate: break; */ |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
624 default: |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
625 [ NSApp sendEvent:event ]; |
272
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
626 } |
d1447a846d80
Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
627 } |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
628 } while (event != nil); |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
629 |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
630 /* handle accumulated mouse moved events */ |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
631 if (dx != 0 || dy != 0) |
435
140798e1e7a6
Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents:
390
diff
changeset
|
632 SDL_PrivateMouseMotion (0, 1, dx, dy); |
390
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
633 |
19e73568a75c
Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents:
389
diff
changeset
|
634 [ pool release ]; |
502
80a3d09bab29
Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents:
501
diff
changeset
|
635 } |