annotate src/video/quartz/SDL_QuartzEvents.m @ 47:45b1c4303f87

Added initial support for Quartz video (thanks Darrell!)
author Sam Lantinga <slouken@lokigames.com>
date Thu, 07 Jun 2001 14:28:11 +0000
parents
children aac75d5f7869
rev   line source
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
13 Library General Public License for more details.
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
16 License along with this library; if not, write to the Free
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
20 slouken@devolution.com
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #include "SDL_QuartzKeys.h"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 static void QZ_InitOSKeymap (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 int i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 keymap[i] = SDLK_UNKNOWN;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 // This keymap is almost exactly the same as the OS 9 one
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 keymap[QZ_ESCAPE] = SDLK_ESCAPE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 keymap[QZ_F1] = SDLK_F1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 keymap[QZ_F2] = SDLK_F2;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35 keymap[QZ_F3] = SDLK_F3;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36 keymap[QZ_F4] = SDLK_F4;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 keymap[QZ_F5] = SDLK_F5;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 keymap[QZ_F6] = SDLK_F6;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 keymap[QZ_F7] = SDLK_F7;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40 keymap[QZ_F8] = SDLK_F8;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 keymap[QZ_F9] = SDLK_F9;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
42 keymap[QZ_F10] = SDLK_F10;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
43 keymap[QZ_F11] = SDLK_F11;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
44 keymap[QZ_F12] = SDLK_F12;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 keymap[QZ_PRINT] = SDLK_PRINT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 keymap[QZ_SCROLLOCK] = SDLK_SCROLLOCK;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 keymap[QZ_PAUSE] = SDLK_PAUSE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 keymap[QZ_POWER] = SDLK_POWER;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 keymap[QZ_BACKQUOTE] = SDLK_BACKQUOTE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 keymap[QZ_1] = SDLK_1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 keymap[QZ_2] = SDLK_2;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 keymap[QZ_3] = SDLK_3;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 keymap[QZ_4] = SDLK_4;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 keymap[QZ_5] = SDLK_5;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 keymap[QZ_6] = SDLK_6;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 keymap[QZ_7] = SDLK_7;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 keymap[QZ_8] = SDLK_8;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 keymap[QZ_9] = SDLK_9;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 keymap[QZ_0] = SDLK_0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 keymap[QZ_MINUS] = SDLK_MINUS;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 keymap[QZ_EQUALS] = SDLK_EQUALS;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 keymap[QZ_BACKSPACE] = SDLK_BACKSPACE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 keymap[QZ_INSERT] = SDLK_INSERT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 keymap[QZ_HOME] = SDLK_HOME;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 keymap[QZ_PAGEUP] = SDLK_PAGEUP;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 keymap[QZ_NUMLOCK] = SDLK_NUMLOCK;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 keymap[QZ_KP_EQUALS] = SDLK_KP_EQUALS;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 keymap[QZ_KP_DIVIDE] = SDLK_KP_DIVIDE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 keymap[QZ_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 keymap[QZ_TAB] = SDLK_TAB;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 keymap[QZ_q] = SDLK_q;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 keymap[QZ_w] = SDLK_w;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 keymap[QZ_e] = SDLK_e;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 keymap[QZ_r] = SDLK_r;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 keymap[QZ_t] = SDLK_t;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 keymap[QZ_y] = SDLK_y;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 keymap[QZ_u] = SDLK_u;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 keymap[QZ_i] = SDLK_i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 keymap[QZ_o] = SDLK_o;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 keymap[QZ_p] = SDLK_p;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 keymap[QZ_LEFTBRACKET] = SDLK_LEFTBRACKET;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 keymap[QZ_RIGHTBRACKET] = SDLK_RIGHTBRACKET;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 keymap[QZ_BACKSLASH] = SDLK_BACKSLASH;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 keymap[QZ_DELETE] = SDLK_DELETE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 keymap[QZ_END] = SDLK_END;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 keymap[QZ_PAGEDOWN] = SDLK_PAGEDOWN;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 keymap[QZ_KP7] = SDLK_KP7;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 keymap[QZ_KP8] = SDLK_KP8;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 keymap[QZ_KP9] = SDLK_KP9;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 keymap[QZ_KP_MINUS] = SDLK_KP_MINUS;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 keymap[QZ_CAPSLOCK] = SDLK_CAPSLOCK;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 keymap[QZ_a] = SDLK_a;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 keymap[QZ_s] = SDLK_s;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 keymap[QZ_d] = SDLK_d;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 keymap[QZ_f] = SDLK_f;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 keymap[QZ_g] = SDLK_g;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 keymap[QZ_h] = SDLK_h;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 keymap[QZ_j] = SDLK_j;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 keymap[QZ_k] = SDLK_k;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 keymap[QZ_l] = SDLK_l;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 keymap[QZ_SEMICOLON] = SDLK_SEMICOLON;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 keymap[QZ_QUOTE] = SDLK_QUOTE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 keymap[QZ_RETURN] = SDLK_RETURN;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 keymap[QZ_KP4] = SDLK_KP4;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 keymap[QZ_KP5] = SDLK_KP5;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 keymap[QZ_KP6] = SDLK_KP6;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 keymap[QZ_KP_PLUS] = SDLK_KP_PLUS;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 keymap[QZ_LSHIFT] = SDLK_LSHIFT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 keymap[QZ_z] = SDLK_z;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 keymap[QZ_x] = SDLK_x;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 keymap[QZ_c] = SDLK_c;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 keymap[QZ_v] = SDLK_v;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 keymap[QZ_b] = SDLK_b;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 keymap[QZ_n] = SDLK_n;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 keymap[QZ_m] = SDLK_m;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 keymap[QZ_COMMA] = SDLK_COMMA;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 keymap[QZ_PERIOD] = SDLK_PERIOD;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 keymap[QZ_SLASH] = SDLK_SLASH;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 keymap[QZ_UP] = SDLK_UP;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 keymap[QZ_KP1] = SDLK_KP1;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 keymap[QZ_KP2] = SDLK_KP2;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 keymap[QZ_KP3] = SDLK_KP3;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 keymap[QZ_KP_ENTER] = SDLK_KP_ENTER;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 keymap[QZ_LCTRL] = SDLK_LCTRL;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 keymap[QZ_LALT] = SDLK_LALT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 keymap[QZ_LMETA] = SDLK_LMETA;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 keymap[QZ_SPACE] = SDLK_SPACE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 keymap[QZ_LEFT] = SDLK_LEFT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 keymap[QZ_DOWN] = SDLK_DOWN;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 keymap[QZ_RIGHT] = SDLK_RIGHT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 keymap[QZ_KP0] = SDLK_KP0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 keymap[QZ_KP_PERIOD] = SDLK_KP_PERIOD;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 keymap[QZ_IBOOK_ENTER] = SDLK_KP_ENTER;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 keymap[QZ_IBOOK_RIGHT] = SDLK_RIGHT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 keymap[QZ_IBOOK_DOWN] = SDLK_DOWN;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 keymap[QZ_IBOOK_UP] = SDLK_UP;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 keymap[QZ_IBOOK_LEFT] = SDLK_LEFT;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 static void QZ_DoKey (int state, NSEvent *event) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 NSString *chars;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 int i;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 SDL_keysym key;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 /* An event can contain multiple characters */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 /* I'll ignore this fact for now, since there is only one virtual key code per event */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 chars = [ event characters ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 for (i =0; i < 1 /*[ chars length ] */; i++) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 key.scancode = [ event keyCode ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 key.sym = keymap [ key.scancode ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 key.unicode = [ chars characterAtIndex:i];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 key.mod = KMOD_NONE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 SDL_PrivateKeyboard (state, &key);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 static void QZ_DoModifiers (unsigned int newMods) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 const int offset = 18;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 const int mapping[] = { SDLK_LSHIFT, SDLK_LCTRL, SDLK_LALT, 0, SDLK_LMETA } ;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 int bit;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 SDL_keysym key;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 key.scancode = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 key.sym = SDLK_UNKNOWN;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 key.unicode = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 key.mod = KMOD_NONE;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 /* Iterate through the bits, testing each against the current modifiers */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 for (bit = NSShiftKeyMask; bit <= NSCommandKeyMask; bit <<= 1) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 unsigned int currentMask, newMask;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 currentMask = currentMods & bit;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 newMask = newMods & bit;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 if ( currentMask &&
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 currentMask != newMask ) { /* modifier up event */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 key.sym = mapping[ currentMask >> offset ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 SDL_PrivateKeyboard (SDL_RELEASED, &key);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 else
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 if ( newMask &&
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 currentMask != newMask ) { /* modifier down event */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 key.sym = mapping [ newMask >> offset ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 SDL_PrivateKeyboard (SDL_PRESSED, &key);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 currentMods = newMods;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 static void QZ_DoActivate (_THIS, NSPoint p) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 inForeground = YES;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 /* Regrab the mouse */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203 if (currentGrabMode == SDL_GRAB_ON) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 CGAssociateMouseAndMouseCursorPosition (0);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 static void QZ_DoDeactivate (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 inForeground = NO;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
214
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 /* Ungrab mouse if it is grabbed */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 if (currentGrabMode == SDL_GRAB_ON) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 CGAssociateMouseAndMouseCursorPosition (1);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
223 static void QZ_PumpEvents (_THIS) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
224
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
225 NSDate *distantPast = [ NSDate distantPast ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 //NSAutoreleasePool *pool;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228 //pool = [ [ NSAutoreleasePool alloc ] init ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
230 NSEvent *event;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
231 NSRect winRect;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232 NSRect titleBarRect;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234 winRect = NSMakeRect (0, 0, SDL_VideoSurface->w + 1, SDL_VideoSurface->h + 1);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
235 titleBarRect = NSMakeRect ( 0, SDL_VideoSurface->h, SDL_VideoSurface->w,
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
236 SDL_VideoSurface->h + 22 );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
237
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
238 do {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
240 /* Poll for an event. This will not block */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241 event = [ NSApp nextEventMatchingMask:NSAnyEventMask
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 untilDate:distantPast
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243 inMode: NSDefaultRunLoopMode dequeue:YES ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 if (event != nil) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 unsigned int type;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 NSPoint p;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 type = [ event type ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250 p = [ event locationInWindow ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 #define DO_MOUSE_DOWN(button, sendToWindow) \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 if ( inForeground ) { \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 if ( NSPointInRect(p,winRect)) \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255 SDL_PrivateMouseButton (SDL_PRESSED, button, p.x, SDL_VideoSurface->h - p.y); \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 else if (sendToWindow) \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 [ window sendEvent:event ]; \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 } \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 else { \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 QZ_DoActivate (this, p); \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263 #define DO_MOUSE_UP(button, sendToWindow) \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 if ( ! NSPointInRect (p, titleBarRect) ) \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265 SDL_PrivateMouseButton (SDL_RELEASED, button, p.x, SDL_VideoSurface->h - p.y); \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 if (sendToWindow) \
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267 [ window sendEvent:event ]
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269 switch ( type) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 case NSLeftMouseDown:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 if ( NSCommandKeyMask & currentMods ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 DO_MOUSE_DOWN (3, 0);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 else if ( NSAlternateKeyMask & currentMods ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 DO_MOUSE_DOWN (2, 0);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 DO_MOUSE_DOWN (1, 1);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 case 25: DO_MOUSE_DOWN (2, 0); break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 case NSLeftMouseUp:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
285 if ( NSCommandKeyMask & currentMods ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 DO_MOUSE_UP (3, 0);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 else if ( NSAlternateKeyMask & currentMods ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 DO_MOUSE_UP (2, 0);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 else
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 DO_MOUSE_UP (1, 1);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 case 26: DO_MOUSE_UP (2, 0); break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 case NSRightMouseUp: DO_MOUSE_UP (3, 0); break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296 case NSSystemDefined:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 //if ([event subtype] == 7) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 // unsigned int buttons; // up to 32 mouse button states!
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 // buttons = [ event data2 ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 //}
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 case NSLeftMouseDragged:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 case NSRightMouseDragged:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 case 27:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 SDL_PrivateMouseMotion (SDL_PRESSED, 0, p.x, SDL_VideoSurface->h - p.y);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 case NSMouseMoved:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308 {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309 static int moves = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 if ( (moves % 10) == 0 ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 SDL_PrivateMouseMotion (SDL_RELEASED, 0, p.x, SDL_VideoSurface->h - p.y);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 moves = 0;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315 else {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
316 CGMouseDelta dx, dy;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
317 CGGetLastMouseDelta (&dx, &dy);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318 SDL_PrivateMouseMotion (SDL_RELEASED, 1, dx, dy);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
319 moves++;
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 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
322 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
323 case NSScrollWheel:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324 {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 if (NSPointInRect(p, winRect)) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 float dy;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327 dy = [ event deltaY ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 if ( dy > 0.0 ) /* Scroll up */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329 SDL_PrivateMouseButton (SDL_PRESSED, 4, p.x, SDL_VideoSurface->h - p.y);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330 else /* Scroll down */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331 SDL_PrivateMouseButton (SDL_PRESSED, 5, p.x, SDL_VideoSurface->h - p.y);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
335 case NSKeyUp:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 QZ_DoKey (SDL_RELEASED, event);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338 case NSKeyDown:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339 QZ_DoKey (SDL_PRESSED, event);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 case NSFlagsChanged:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
342 QZ_DoModifiers( [ event modifierFlags ] );
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
343 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344 case NSMouseEntered: break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345 case NSMouseExited: break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
346 case NSAppKitDefined:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
347 switch ( [ event subtype ] ) {
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
348 case NSApplicationActivatedEventType:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
349 QZ_DoActivate (this, p);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
351 case NSApplicationDeactivatedEventType:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352 QZ_DoDeactivate (this);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
354 case NSWindowMovedEventType:
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355 [ window sendEvent:event ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
356 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358 break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
359 case NSApplicationDefined: break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360 case NSPeriodic: break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 case NSCursorUpdate: break;
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
364 // [ pool release ];
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
365
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
366 } while (event != nil);
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
367 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
368