annotate src/video/quartz/SDL_QuartzEvents.m @ 502:80a3d09bab29

Fixed mouse wheel events on MacOS X
author Sam Lantinga <slouken@libsdl.org>
date Sat, 05 Oct 2002 05:11:20 +0000
parents 74262d2647ca
children 79c189f5bd76
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 */
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22 #include "SDL_QuartzKeys.h"
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
24 static void QZ_InitOSKeymap (_THIS) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
25 const void *KCHRPtr;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
26 UInt32 state;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
27 UInt32 value;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
28 int i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
29 int world = SDLK_WORLD_0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
30
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
31 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
32 keymap[i] = SDLK_UNKNOWN;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
34 /* 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
35 keymap[QZ_ESCAPE] = SDLK_ESCAPE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
36 keymap[QZ_F1] = SDLK_F1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
37 keymap[QZ_F2] = SDLK_F2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
38 keymap[QZ_F3] = SDLK_F3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
39 keymap[QZ_F4] = SDLK_F4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
40 keymap[QZ_F5] = SDLK_F5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
41 keymap[QZ_F6] = SDLK_F6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
42 keymap[QZ_F7] = SDLK_F7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
43 keymap[QZ_F8] = SDLK_F8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
44 keymap[QZ_F9] = SDLK_F9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
45 keymap[QZ_F10] = SDLK_F10;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
46 keymap[QZ_F11] = SDLK_F11;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
47 keymap[QZ_F12] = SDLK_F12;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
48 keymap[QZ_PRINT] = SDLK_PRINT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
49 keymap[QZ_SCROLLOCK] = SDLK_SCROLLOCK;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
50 keymap[QZ_PAUSE] = SDLK_PAUSE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
51 keymap[QZ_POWER] = SDLK_POWER;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
52 keymap[QZ_BACKQUOTE] = SDLK_BACKQUOTE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
53 keymap[QZ_1] = SDLK_1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
54 keymap[QZ_2] = SDLK_2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
55 keymap[QZ_3] = SDLK_3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
56 keymap[QZ_4] = SDLK_4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
57 keymap[QZ_5] = SDLK_5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
58 keymap[QZ_6] = SDLK_6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
59 keymap[QZ_7] = SDLK_7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
60 keymap[QZ_8] = SDLK_8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
61 keymap[QZ_9] = SDLK_9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
62 keymap[QZ_0] = SDLK_0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
63 keymap[QZ_MINUS] = SDLK_MINUS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
64 keymap[QZ_EQUALS] = SDLK_EQUALS;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
65 keymap[QZ_BACKSPACE] = SDLK_BACKSPACE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
66 keymap[QZ_INSERT] = SDLK_INSERT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
67 keymap[QZ_HOME] = SDLK_HOME;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
68 keymap[QZ_PAGEUP] = SDLK_PAGEUP;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
69 keymap[QZ_NUMLOCK] = SDLK_NUMLOCK;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
70 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
71 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
72 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
73 keymap[QZ_TAB] = SDLK_TAB;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
74 keymap[QZ_q] = SDLK_q;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
75 keymap[QZ_w] = SDLK_w;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
76 keymap[QZ_e] = SDLK_e;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
77 keymap[QZ_r] = SDLK_r;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
78 keymap[QZ_t] = SDLK_t;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
79 keymap[QZ_y] = SDLK_y;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
80 keymap[QZ_u] = SDLK_u;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
81 keymap[QZ_i] = SDLK_i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
82 keymap[QZ_o] = SDLK_o;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
83 keymap[QZ_p] = SDLK_p;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
84 keymap[QZ_LEFTBRACKET] = SDLK_LEFTBRACKET;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
85 keymap[QZ_RIGHTBRACKET] = SDLK_RIGHTBRACKET;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
86 keymap[QZ_BACKSLASH] = SDLK_BACKSLASH;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
87 keymap[QZ_DELETE] = SDLK_DELETE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
88 keymap[QZ_END] = SDLK_END;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
89 keymap[QZ_PAGEDOWN] = SDLK_PAGEDOWN;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
90 keymap[QZ_KP7] = SDLK_KP7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
91 keymap[QZ_KP8] = SDLK_KP8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
92 keymap[QZ_KP9] = SDLK_KP9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
93 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
94 keymap[QZ_CAPSLOCK] = SDLK_CAPSLOCK;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
95 keymap[QZ_a] = SDLK_a;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
96 keymap[QZ_s] = SDLK_s;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
97 keymap[QZ_d] = SDLK_d;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
98 keymap[QZ_f] = SDLK_f;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
99 keymap[QZ_g] = SDLK_g;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
100 keymap[QZ_h] = SDLK_h;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
101 keymap[QZ_j] = SDLK_j;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
102 keymap[QZ_k] = SDLK_k;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
103 keymap[QZ_l] = SDLK_l;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
104 keymap[QZ_SEMICOLON] = SDLK_SEMICOLON;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
105 keymap[QZ_QUOTE] = SDLK_QUOTE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
106 keymap[QZ_RETURN] = SDLK_RETURN;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
107 keymap[QZ_KP4] = SDLK_KP4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
108 keymap[QZ_KP5] = SDLK_KP5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
109 keymap[QZ_KP6] = SDLK_KP6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
110 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
111 keymap[QZ_LSHIFT] = SDLK_LSHIFT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
112 keymap[QZ_z] = SDLK_z;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
113 keymap[QZ_x] = SDLK_x;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
114 keymap[QZ_c] = SDLK_c;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
115 keymap[QZ_v] = SDLK_v;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
116 keymap[QZ_b] = SDLK_b;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
117 keymap[QZ_n] = SDLK_n;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
118 keymap[QZ_m] = SDLK_m;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
119 keymap[QZ_COMMA] = SDLK_COMMA;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
120 keymap[QZ_PERIOD] = SDLK_PERIOD;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
121 keymap[QZ_SLASH] = SDLK_SLASH;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
122 keymap[QZ_UP] = SDLK_UP;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
123 keymap[QZ_KP1] = SDLK_KP1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
124 keymap[QZ_KP2] = SDLK_KP2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
125 keymap[QZ_KP3] = SDLK_KP3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
126 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
127 keymap[QZ_LCTRL] = SDLK_LCTRL;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
128 keymap[QZ_LALT] = SDLK_LALT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
129 keymap[QZ_LMETA] = SDLK_LMETA;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
130 keymap[QZ_SPACE] = SDLK_SPACE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
131 keymap[QZ_LEFT] = SDLK_LEFT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
132 keymap[QZ_DOWN] = SDLK_DOWN;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
133 keymap[QZ_RIGHT] = SDLK_RIGHT;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
134 keymap[QZ_KP0] = SDLK_KP0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
135 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
136 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
137 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
138 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
139 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
140 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
141
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
142 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
143 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
144 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
145 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
146 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
147 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
148 */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
149
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
150 /* 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
151 KCHRPtr = (void *)GetScriptManagerVariable(smKCHRCache);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
152 if (KCHRPtr)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
153 {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
154 /* 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
155 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
156 {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
157 /* 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
158 state = 0;
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 /* 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
161 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
162
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
163 /* 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
164 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
165 if (state != 0)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
166 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
167
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
168 /* 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
169 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
170 keymap[i] = world++;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
171 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
172 keymap[i] = value;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
173 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
174 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
175
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
176 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
177 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
178 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
179 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
180 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
181 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
182 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
183 */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
184 keymap[QZ_KP0] = SDLK_KP0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
185 keymap[QZ_KP1] = SDLK_KP1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
186 keymap[QZ_KP2] = SDLK_KP2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
187 keymap[QZ_KP3] = SDLK_KP3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
188 keymap[QZ_KP4] = SDLK_KP4;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
189 keymap[QZ_KP5] = SDLK_KP5;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
190 keymap[QZ_KP6] = SDLK_KP6;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
191 keymap[QZ_KP7] = SDLK_KP7;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
192 keymap[QZ_KP8] = SDLK_KP8;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
193 keymap[QZ_KP9] = SDLK_KP9;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
194 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
195 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
196 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
197 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
198 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
199 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
200 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
201 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
203 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
204
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
205 NSString *chars;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
206 int i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
207 SDL_keysym key;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
208
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
209 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
210 An event can contain multiple characters
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
211 I'll ignore this fact for now, since there
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
212 is only one virtual key code per event, so
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
213 no good way to handle this.
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
214 */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
215 chars = [ event characters ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
216 for (i =0; i < 1 /*[ chars length ] */; i++) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
217
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
218 key.scancode = [ event keyCode ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
219 key.sym = keymap [ key.scancode ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
220 key.unicode = [ chars characterAtIndex:i];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
221 key.mod = KMOD_NONE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
222
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
223 SDL_PrivateKeyboard (state, &key);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
224 }
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
225 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
227 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
228
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
229 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
230
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
231 int i;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
232 int bit;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
233 SDL_keysym key;
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
234
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
235 key.scancode = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
236 key.sym = SDLK_UNKNOWN;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
237 key.unicode = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
238 key.mod = KMOD_NONE;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
239
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
240 /* 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
241 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
242
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
243 unsigned int currentMask, newMask;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
244
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
245 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
246 newMask = newMods & bit;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
248 if ( currentMask &&
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
249 currentMask != newMask ) { /* modifier up event */
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
251 key.sym = mapping[i];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
252 /* 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
253 if (bit == NSAlphaShiftKeyMask)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
254 SDL_PrivateKeyboard (SDL_PRESSED, &key);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
255 SDL_PrivateKeyboard (SDL_RELEASED, &key);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
256 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
257 else if ( newMask &&
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
258 currentMask != newMask ) { /* modifier down event */
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 key.sym = mapping[i];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
261 SDL_PrivateKeyboard (SDL_PRESSED, &key);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
262 /* 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
263 if (bit == NSAlphaShiftKeyMask)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
264 SDL_PrivateKeyboard (SDL_RELEASED, &key);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
265 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
266 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
267
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
268 current_mods = newMods;
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270
117
aac75d5f7869 Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 47
diff changeset
271 static void QZ_DoActivate (_THIS)
aac75d5f7869 Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 47
diff changeset
272 {
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
273 in_foreground = YES;
168
e92aa316c517 Added Max's patches for building MacOS X apps on command line
Sam Lantinga <slouken@libsdl.org>
parents: 158
diff changeset
274
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
275 /* Regrab the mouse, only if it was previously grabbed */
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
276 if ( current_grab_mode == SDL_GRAB_ON ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
277 QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
278 CGAssociateMouseAndMouseCursorPosition (0);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
279 }
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
280
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
281 /* Hide the mouse cursor if inside the app window */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
282 if (!QZ_cursor_visible) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
283 HideCursor ();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
284 }
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 SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
47
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
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 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
290
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
291 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
292
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
293 /* Ungrab mouse if it is grabbed */
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
294 if ( current_grab_mode == SDL_GRAB_ON ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
295 CGAssociateMouseAndMouseCursorPosition (1);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
296 }
172
37e3ca9254c7 Date: Sat, 8 Sep 2001 04:42:23 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 168
diff changeset
297
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
298 /* Show the mouse cursor */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
299 if (!QZ_cursor_visible) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
300 ShowCursor ();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
301 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
302
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
303 SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
47
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 }
45b1c4303f87 Added initial support for Quartz video (thanks Darrell!)
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305
117
aac75d5f7869 Fixed fullscreen mouse events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 47
diff changeset
306 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
307 {
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
308 int firstMouseEvent;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
309 CGMouseDelta dx, dy;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
310
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
311 NSDate *distantPast;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
312 NSEvent *event;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
313 NSRect winRect;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
314 NSRect titleBarRect;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
315 NSAutoreleasePool *pool;
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 pool = [ [ NSAutoreleasePool alloc ] init ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
318 distantPast = [ NSDate distantPast ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
319
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
320 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
321 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
322 SDL_VideoSurface->h + 22);
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
323
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
324 /* 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
325 firstMouseEvent = 1;
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
326
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
327 /* 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
328 dx = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
329 dy = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
330
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
331 do {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
332
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
333 /* 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
334 event = [ NSApp nextEventMatchingMask:NSAnyEventMask
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
335 untilDate:distantPast
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
336 inMode: NSDefaultRunLoopMode dequeue:YES ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
337
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
338 if (event != nil) {
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 unsigned int type;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
341 BOOL isForGameWin;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
342
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
343 #define DO_MOUSE_DOWN(button, sendToWindow) do { \
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
344 if ( in_foreground ) { \
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
345 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
346 NSPointInRect([event locationInWindow], winRect) ) \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
347 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
348 } \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
349 else { \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
350 QZ_DoActivate (this); \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
351 } \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
352 [ NSApp sendEvent:event ]; \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
353 } while(0)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
354
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
355 #define DO_MOUSE_UP(button, sendToWindow) do { \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
356 if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
357 !NSPointInRect([event locationInWindow], titleBarRect) ) \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
358 SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
359 [ NSApp sendEvent:event ]; \
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
360 } while(0)
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
361
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
362 type = [ event type ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
363 isForGameWin = (qz_window == [ event window ]);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
364 switch (type) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
365
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
366 case NSLeftMouseDown:
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
367 if ( NSCommandKeyMask & current_mods ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
368 last_virtual_button = 3;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
369 DO_MOUSE_DOWN (3, 0);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
370 }
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
371 else if ( NSAlternateKeyMask & current_mods ) {
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
372 last_virtual_button = 2;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
373 DO_MOUSE_DOWN (2, 0);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
374 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
375 else {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
376 DO_MOUSE_DOWN (1, 1);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
377 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
378 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
379 case NSOtherMouseDown: DO_MOUSE_DOWN (2, 0); break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
380 case NSRightMouseDown: DO_MOUSE_DOWN (3, 0); break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
381 case NSLeftMouseUp:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
382 if ( last_virtual_button != 0 ) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
383 DO_MOUSE_UP (last_virtual_button, 0);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
384 last_virtual_button = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
385 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
386 else {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
387 DO_MOUSE_UP (1, 1);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
388 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
389 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
390 case NSOtherMouseUp: DO_MOUSE_UP (2, 0); break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
391 case NSRightMouseUp: DO_MOUSE_UP (3, 0); break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
392 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
393 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
394 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
395 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
396 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
397 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
398 */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
399 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
400 case NSLeftMouseDragged:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
401 case NSRightMouseDragged:
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
402 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
403 case NSMouseMoved:
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
404 if (current_grab_mode == SDL_GRAB_ON) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
405
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
406 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
407 If input is grabbed, the cursor doesn't move,
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
408 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
409 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
410 */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
411 CGMouseDelta dx1, dy1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
412 CGGetLastMouseDelta (&dx1, &dy1);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
413 dx += dx1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
414 dy += dy1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
415 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
416 else if (warp_flag) {
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
417
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
418 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
419 If we just warped the mouse, the cursor is frozen for a while.
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
420 So we have to use the lowlevel function until it
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
421 unfreezes. This really helps apps that continuously
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
422 warp the mouse to keep it in the game window. Developers should
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
423 really use GrabInput, but our GrabInput freezes the HW cursor,
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
424 which doesn't cut it for some apps.
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
425 */
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
426 Uint32 ticks;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
427
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
428 ticks = SDL_GetTicks();
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
429 if (ticks - warp_ticks < 150) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
430
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
431 CGMouseDelta dx1, dy1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
432 CGGetLastMouseDelta (&dx1, &dy1);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
433 dx += dx1;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
434 dy += dy1;
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 else {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
437
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
438 warp_flag = 0;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
439 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
440 }
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
441 else if (firstMouseEvent) {
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
442
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
443 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
444 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
445 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
446 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
447 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
448 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
449 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
450 */
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
451 NSPoint p = [ event locationInWindow ];
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
452 QZ_PrivateCocoaToSDL(this, &p);
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
453
454
c4338ecf45f9 Fixed mouse motion on MacOS X (recently broken)
Sam Lantinga <slouken@libsdl.org>
parents: 435
diff changeset
454 SDL_PrivateMouseMotion (0, 0, p.x, p.y);
c4338ecf45f9 Fixed mouse motion on MacOS X (recently broken)
Sam Lantinga <slouken@libsdl.org>
parents: 435
diff changeset
455
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
456 firstMouseEvent = 0;
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
457 }
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
458 else {
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
459
501
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
460 /*
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
461 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
462 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
463 */
74262d2647ca Lots of cleanups by Darrell, added the ability to resize Cocoa windows.
Sam Lantinga <slouken@libsdl.org>
parents: 454
diff changeset
464 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
465 dy += [ event deltaY ];
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
466 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
467 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
468 case NSScrollWheel:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
469 if (NSPointInRect([ event locationInWindow ], winRect)) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
470 float dy;
502
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
471 Uint8 button;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
472 dy = [ event deltaY ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
473 if ( dy > 0.0 ) /* Scroll up */
502
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
474 button = SDL_BUTTON_WHEELUP;
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
475 else /* Scroll down */
502
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
476 button = SDL_BUTTON_WHEELDOWN;
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
477 /* For now, wheel is sent as a quick down+up */
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
478 SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0);
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
479 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
480 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
481 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
482 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
483 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
484 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
485 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
486 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
487 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
488 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
489 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
490 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
491 case NSAppKitDefined:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
492 switch ( [ event subtype ] ) {
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
493 case NSApplicationActivatedEventType:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
494 QZ_DoActivate (this);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
495 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
496 case NSApplicationDeactivatedEventType:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
497 QZ_DoDeactivate (this);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
498 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
499 }
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
500 [ NSApp sendEvent:event ];
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
501 break;
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
502 /* case NSApplicationDefined: break; */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
503 /* case NSPeriodic: break; */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
504 /* case NSCursorUpdate: break; */
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
505 default:
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
506 [ NSApp sendEvent:event ];
272
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
507 }
d1447a846d80 Date: Sat, 19 Jan 2002 17:24:32 -0500 (EST)
Sam Lantinga <slouken@libsdl.org>
parents: 252
diff changeset
508 }
390
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
509 } while (event != nil);
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
510
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
511 /* 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
512 if (dx != 0 || dy != 0)
435
140798e1e7a6 Darrell's fix for Quartz mouse motion
Sam Lantinga <slouken@libsdl.org>
parents: 390
diff changeset
513 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
514
19e73568a75c Date: Sat, 1 Jun 2002 17:56:45 -0500
Sam Lantinga <slouken@libsdl.org>
parents: 389
diff changeset
515 [ pool release ];
502
80a3d09bab29 Fixed mouse wheel events on MacOS X
Sam Lantinga <slouken@libsdl.org>
parents: 501
diff changeset
516 }