Mercurial > sdl-ios-xcode
annotate src/events/SDL_keyboard.c @ 1673:624e1412fbba SDL-1.3
Keyboard code update in progress
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 10 Jun 2006 09:11:59 +0000 |
parents | eef792d31de8 |
children | 7688a73b25b1 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1283
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
223
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* General keyboard handling code for SDL */ | |
25 | |
1358
c71e05b4dc2e
More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
26 #include "SDL_timer.h" |
0 | 27 #include "SDL_events.h" |
28 #include "SDL_events_c.h" | |
29 #include "SDL_sysevents.h" | |
30 | |
31 | |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
32 /* Global keyboard information */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
33 static int SDL_num_keyboards; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
34 static int SDL_current_keyboard; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
35 static SDL_Keyboard **SDL_keyboards; |
0 | 36 int SDL_TranslateUNICODE = 0; |
37 | |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
38 static const char *SDL_keynames[SDLK_LAST]; /* Array of keycode names */ |
0 | 39 |
40 /* Public functions */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
41 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
42 SDL_KeyboardInit(void) |
0 | 43 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
44 int i; |
0 | 45 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
46 /* Set default mode of UNICODE translation */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
47 SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION); |
0 | 48 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
49 /* Set default keyboard repeat setting */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
50 SDL_EnableKeyRepeat(0, 0); |
0 | 51 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
52 /* Initialize the tables */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
53 for (i = 0; i < SDL_arraysize(SDL_keynames); ++i) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
54 switch (i) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
55 case SDLK_BACKSPACE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
56 SDL_keynames[i] = "backspace"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
57 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
58 case SDLK_TAB: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
59 SDL_keynames[i] = "tab"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
60 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
61 case SDLK_CLEAR: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
62 SDL_keynames[i] = "clear"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
63 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
64 case SDLK_RETURN: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
65 SDL_keynames[i] = "return"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
66 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
67 case SDLK_PAUSE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
68 SDL_keynames[i] = "pause"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
69 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
70 case SDLK_ESCAPE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
71 SDL_keynames[i] = "escape"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
72 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
73 case SDLK_SPACE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
74 SDL_keynames[i] = "space"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
75 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
76 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
77 case SDLK_KP0: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
78 SDL_keynames[i] = "[0]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
79 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
80 case SDLK_KP1: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
81 SDL_keynames[i] = "[1]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
82 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
83 case SDLK_KP2: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
84 SDL_keynames[i] = "[2]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
85 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
86 case SDLK_KP3: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
87 SDL_keynames[i] = "[3]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
88 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
89 case SDLK_KP4: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
90 SDL_keynames[i] = "[4]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
91 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
92 case SDLK_KP5: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
93 SDL_keynames[i] = "[5]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
94 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
95 case SDLK_KP6: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
96 SDL_keynames[i] = "[6]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
97 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
98 case SDLK_KP7: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
99 SDL_keynames[i] = "[7]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
100 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
101 case SDLK_KP8: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
102 SDL_keynames[i] = "[8]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
103 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
104 case SDLK_KP9: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
105 SDL_keynames[i] = "[9]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
106 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
107 case SDLK_KP_PERIOD: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
108 SDL_keynames[i] = "[.]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
109 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
110 case SDLK_KP_DIVIDE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
111 SDL_keynames[i] = "[/]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
112 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
113 case SDLK_KP_MULTIPLY: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
114 SDL_keynames[i] = "[*]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
115 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
116 case SDLK_KP_MINUS: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
117 SDL_keynames[i] = "[-]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
118 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
119 case SDLK_KP_PLUS: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
120 SDL_keynames[i] = "[+]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
121 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
122 case SDLK_KP_ENTER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
123 SDL_keynames[i] = "enter"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
124 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
125 case SDLK_KP_EQUALS: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
126 SDL_keynames[i] = "equals"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
127 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
128 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
129 case SDLK_UP: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
130 SDL_keynames[i] = "up"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
131 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
132 case SDLK_DOWN: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
133 SDL_keynames[i] = "down"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
134 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
135 case SDLK_RIGHT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
136 SDL_keynames[i] = "right"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
137 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
138 case SDLK_LEFT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
139 SDL_keynames[i] = "left"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
140 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
141 case SDLK_DOWN: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
142 SDL_keynames[i] = "down"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
143 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
144 case SDLK_INSERT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
145 SDL_keynames[i] = "insert"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
146 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
147 case SDLK_HOME: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
148 SDL_keynames[i] = "home"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
149 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
150 case SDLK_END: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
151 SDL_keynames[i] = "end"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
152 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
153 case SDLK_PAGEUP: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
154 SDL_keynames[i] = "page up"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
155 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
156 case SDLK_PAGEDOWN: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
157 SDL_keynames[i] = "page down"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
158 break; |
0 | 159 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
160 case SDLK_F1: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
161 SDL_keynames[i] = "f1"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
162 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
163 case SDLK_F2: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
164 SDL_keynames[i] = "f2"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
165 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
166 case SDLK_F3: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
167 SDL_keynames[i] = "f3"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
168 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
169 case SDLK_F4: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
170 SDL_keynames[i] = "f4"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
171 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
172 case SDLK_F5: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
173 SDL_keynames[i] = "f5"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
174 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
175 case SDLK_F6: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
176 SDL_keynames[i] = "f6"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
177 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
178 case SDLK_F7: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
179 SDL_keynames[i] = "f7"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
180 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
181 case SDLK_F8: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
182 SDL_keynames[i] = "f8"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
183 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
184 case SDLK_F9: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
185 SDL_keynames[i] = "f9"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
186 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
187 case SDLK_F10: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
188 SDL_keynames[i] = "f10"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
189 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
190 case SDLK_F11: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
191 SDL_keynames[i] = "f11"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
192 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
193 case SDLK_F12: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
194 SDL_keynames[i] = "f12"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
195 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
196 case SDLK_F13: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
197 SDL_keynames[i] = "f13"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
198 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
199 case SDLK_F14: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
200 SDL_keynames[i] = "f14"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
201 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
202 case SDLK_F15: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
203 SDL_keynames[i] = "f15"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
204 break; |
0 | 205 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
206 case SDLK_NUMLOCK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
207 SDL_keynames[i] = "numlock"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
208 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
209 case SDLK_CAPSLOCK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
210 SDL_keynames[i] = "caps lock"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
211 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
212 case SDLK_SCROLLOCK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
213 SDL_keynames[i] = "scroll lock"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
214 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
215 case SDLK_RSHIFT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
216 SDL_keynames[i] = "right shift"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
217 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
218 case SDLK_LSHIFT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
219 SDL_keynames[i] = "left shift"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
220 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
221 case SDLK_RCTRL: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
222 SDL_keynames[i] = "right ctrl"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
223 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
224 case SDLK_LCTRL: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
225 SDL_keynames[i] = "left ctrl"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
226 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
227 case SDLK_RALT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
228 SDL_keynames[i] = "right alt"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
229 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
230 case SDLK_LALT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
231 SDL_keynames[i] = "left alt"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
232 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
233 case SDLK_RMETA: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
234 SDL_keynames[i] = "right meta"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
235 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
236 case SDLK_LMETA: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
237 SDL_keynames[i] = "left meta"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
238 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
239 case SDLK_LSUPER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
240 SDL_keynames[i] = "left super"; /* "Windows" keys */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
241 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
242 case SDLK_RSUPER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
243 SDL_keynames[i] = "right super"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
244 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
245 case SDLK_MODE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
246 SDL_keynames[i] = "alt gr"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
247 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
248 case SDLK_COMPOSE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
249 SDL_keynames[i] = "compose"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
250 break; |
0 | 251 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
252 case SDLK_HELP: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
253 SDL_keynames[i] = "help"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
254 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
255 case SDLK_PRINT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
256 SDL_keynames[i] = "print screen"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
257 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
258 case SDLK_SYSREQ: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
259 SDL_keynames[i] = "sys req"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
260 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
261 case SDLK_BREAK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
262 SDL_keynames[i] = "break"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
263 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
264 case SDLK_MENU: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
265 SDL_keynames[i] = "menu"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
266 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
267 case SDLK_POWER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
268 SDL_keynames[i] = "power"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
269 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
270 case SDLK_EURO: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
271 SDL_keynames[i] = "euro"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
272 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
273 case SDLK_UNDO: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
274 SDL_keynames[i] = "undo"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
275 break; |
0 | 276 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
277 default: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
278 SDL_keynames[i] = NULL; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
279 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
280 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
281 } |
0 | 282 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
283 /* Done. Whew. */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
284 return (0); |
0 | 285 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
286 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
287 SDL_Keyboard * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
288 SDL_GetKeyboard(int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
289 { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
290 if (index < 0 || index >= SDL_num_keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
291 return NULL; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
292 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
293 return SDL_keyboards[index]; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
294 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
295 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
296 int |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
297 SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
298 { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
299 SDL_Keyboard **keyboards; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
300 SDL_Cursor *cursor; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
301 int selected_keyboard; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
302 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
303 /* Add the keyboard to the list of keyboards */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
304 if (index < 0 || index >= SDL_num_keyboards || SDL_keyboards[index]) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
305 keyboards = |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
306 (SDL_Keyboard **) SDL_realloc(SDL_keyboards, |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
307 (SDL_num_keyboards + |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
308 1) * sizeof(*keyboards)); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
309 if (!keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
310 SDL_OutOfMemory(); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
311 return -1; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
312 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
313 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
314 SDL_keyboards = keyboards; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
315 index = SDL_num_keyboards++; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
316 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
317 SDL_keyboards[index] = |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
318 (SDL_Keyboard *) SDL_malloc(sizeof(*SDL_keyboards[index])); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
319 if (!SDL_keyboards[index]) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
320 SDL_OutOfMemory(); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
321 return -1; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
322 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
323 *SDL_keyboards[index] = *keyboard; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
324 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
325 return index; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
326 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
327 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
328 void |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
329 SDL_DelKeyboard(int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
330 { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
331 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
332 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
333 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
334 return; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
335 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
336 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
337 if (keyboard->FreeKeyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
338 keyboard->FreeKeyboard(keyboard); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
339 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
340 SDL_free(keyboard); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
341 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
342 SDL_keyboards[index] = NULL; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
343 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
344 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
345 void |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
346 SDL_ResetKeyboard(int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
347 { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
348 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
349 SDL_keysym keysym; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
350 SDLKey key; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
351 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
352 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
353 return; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
354 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
355 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
356 SDL_memset(&keysym, 0, (sizeof keysym)); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
357 for (key = SDLK_FIRST; key < SDLK_LAST; ++key) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
358 if (keyboard->keystate[key] == SDL_PRESSED) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
359 keysym.sym = key; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
360 SDL_SendKeyboardKey(index, SDL_RELEASED, &keysym); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
361 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
362 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
363 keyboard->keyrepeat.timestamp = 0; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
364 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
365 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
366 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
367 SDL_KeyboardQuit(void) |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
1021
diff
changeset
|
368 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
369 int i; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
370 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
371 for (i = 0; i < SDL_num_keyboards; ++i) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
372 SDL_DelKeyboard(i); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
373 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
374 SDL_num_keyboards = 0; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
375 SDL_current_keyboard = 0; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
376 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
377 if (SDL_keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
378 SDL_free(SDL_keyboards); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
379 SDL_keyboards = NULL; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
380 } |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
1021
diff
changeset
|
381 } |
0 | 382 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
383 int |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
384 SDL_GetNumKeyboards(void) |
0 | 385 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
386 return SDL_num_keyboards; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
387 } |
0 | 388 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
389 int |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
390 SDL_SelectKeyboard(int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
391 { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
392 if (index >= 0 && index < SDL_num_keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
393 SDL_current_keyboard = index; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
394 } |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
395 return SDL_current_keyboard; |
0 | 396 } |
397 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
398 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
399 SDL_EnableUNICODE(int enable) |
0 | 400 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
401 int old_mode; |
0 | 402 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
403 old_mode = SDL_TranslateUNICODE; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
404 if (enable >= 0) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
405 SDL_TranslateUNICODE = enable; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
406 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
407 return (old_mode); |
0 | 408 } |
409 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
410 Uint8 * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
411 SDL_GetKeyState(int *numkeys) |
0 | 412 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
413 if (numkeys != (int *) 0) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
414 *numkeys = SDLK_LAST; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
415 return (SDL_KeyState); |
0 | 416 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
417 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
418 SDLMod |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
419 SDL_GetModState(void) |
0 | 420 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
421 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
422 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
423 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
424 return KMOD_NONE; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
425 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
426 return keyboard->modstate; |
0 | 427 } |
428 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
429 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
430 SDL_SetModState(SDLMod modstate) |
0 | 431 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
432 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
433 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
434 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
435 return; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
436 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
437 keyboard->modstate = modstate; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
438 } |
0 | 439 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
440 const char * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
441 SDL_GetKeyName(SDLKey key) |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
442 { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
443 const char *keyname; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
444 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
445 keyname = keynames[key]; |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
446 if (keyname == NULL) { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
447 if (key < 256) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
448 static char temp[4]; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
449 FIXME:Convert to UTF - 8 keyname = temp; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
450 } else { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
451 keyname = "unknown key"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
452 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
453 } |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
454 return keyname; |
0 | 455 } |
456 | |
457 /* These are global for SDL_eventloop.c */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
458 int |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
459 SDL_SendKeyboardKey(int index, Uint8 state, const SDL_keysym * keysym) |
0 | 460 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
461 SDL_Event event; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
462 int posted, repeatable; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
463 Uint16 modstate; |
0 | 464 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
465 SDL_memset(&event, 0, sizeof(event)); |
0 | 466 |
467 #if 0 | |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
468 printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym), |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
469 state == SDL_PRESSED ? "pressed" : "released"); |
0 | 470 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
471 /* Set up the keysym */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
472 modstate = (Uint16) SDL_ModState; |
0 | 473 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
474 repeatable = 0; |
0 | 475 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
476 if (state == SDL_PRESSED) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
477 keysym->mod = (SDLMod) modstate; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
478 switch (keysym->sym) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
479 case SDLK_UNKNOWN: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
480 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
481 case SDLK_NUMLOCK: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
482 modstate ^= KMOD_NUM; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
483 if (!(modstate & KMOD_NUM)) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
484 state = SDL_RELEASED; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
485 keysym->mod = (SDLMod) modstate; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
486 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
487 case SDLK_CAPSLOCK: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
488 modstate ^= KMOD_CAPS; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
489 if (!(modstate & KMOD_CAPS)) |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
490 state = SDL_RELEASED; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
491 keysym->mod = (SDLMod) modstate; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
492 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
493 case SDLK_LCTRL: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
494 modstate |= KMOD_LCTRL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
495 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
496 case SDLK_RCTRL: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
497 modstate |= KMOD_RCTRL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
498 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
499 case SDLK_LSHIFT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
500 modstate |= KMOD_LSHIFT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
501 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
502 case SDLK_RSHIFT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
503 modstate |= KMOD_RSHIFT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
504 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
505 case SDLK_LALT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
506 modstate |= KMOD_LALT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
507 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
508 case SDLK_RALT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
509 modstate |= KMOD_RALT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
510 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
511 case SDLK_LMETA: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
512 modstate |= KMOD_LMETA; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
513 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
514 case SDLK_RMETA: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
515 modstate |= KMOD_RMETA; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
516 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
517 case SDLK_MODE: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
518 modstate |= KMOD_MODE; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
519 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
520 default: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
521 repeatable = 1; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
522 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
523 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
524 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
525 switch (keysym->sym) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
526 case SDLK_UNKNOWN: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
527 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
528 case SDLK_NUMLOCK: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
529 case SDLK_CAPSLOCK: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
530 /* Only send keydown events */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
531 return (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
532 case SDLK_LCTRL: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
533 modstate &= ~KMOD_LCTRL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
534 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
535 case SDLK_RCTRL: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
536 modstate &= ~KMOD_RCTRL; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
537 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
538 case SDLK_LSHIFT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
539 modstate &= ~KMOD_LSHIFT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
540 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
541 case SDLK_RSHIFT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
542 modstate &= ~KMOD_RSHIFT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
543 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
544 case SDLK_LALT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
545 modstate &= ~KMOD_LALT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
546 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
547 case SDLK_RALT: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
548 modstate &= ~KMOD_RALT; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
549 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
550 case SDLK_LMETA: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
551 modstate &= ~KMOD_LMETA; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
552 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
553 case SDLK_RMETA: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
554 modstate &= ~KMOD_RMETA; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
555 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
556 case SDLK_MODE: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
557 modstate &= ~KMOD_MODE; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
558 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
559 default: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
560 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
561 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
562 keysym->mod = (SDLMod) modstate; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
563 } |
0 | 564 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
565 /* Figure out what type of event this is */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
566 switch (state) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
567 case SDL_PRESSED: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
568 event.type = SDL_KEYDOWN; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
569 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
570 case SDL_RELEASED: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
571 event.type = SDL_KEYUP; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
572 /* |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
573 * jk 991215 - Added |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
574 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
575 if (SDL_KeyRepeat.timestamp && |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
576 SDL_KeyRepeat.evt.key.keysym.sym == keysym->sym) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
577 SDL_KeyRepeat.timestamp = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
578 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
579 break; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
580 default: |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
581 /* Invalid state -- bail */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
582 return (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
583 } |
0 | 584 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
585 if (keysym->sym != SDLK_UNKNOWN) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
586 /* Drop events that don't change state */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
587 if (SDL_KeyState[keysym->sym] == state) { |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
588 #if 0 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
589 printf("Keyboard event didn't change state - dropped!\n"); |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
590 #endif |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
591 return (0); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
592 } |
0 | 593 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
594 /* Update internal keyboard state */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
595 SDL_ModState = (SDLMod) modstate; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
596 SDL_KeyState[keysym->sym] = state; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
597 } |
0 | 598 |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
599 /* Post the event, if desired */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
600 posted = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
601 if (SDL_ProcessEvents[event.type] == SDL_ENABLE) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
602 event.key.state = state; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
603 event.key.keysym = *keysym; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
604 /* |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
605 * jk 991215 - Added |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
606 */ |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
607 if (repeatable && (SDL_KeyRepeat.delay != 0)) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
608 SDL_KeyRepeat.evt = event; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
609 SDL_KeyRepeat.firsttime = 1; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
610 SDL_KeyRepeat.timestamp = SDL_GetTicks(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
611 } |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
612 if ((SDL_EventOK == NULL) || SDL_EventOK(&event)) { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
613 posted = 1; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
614 SDL_PushEvent(&event); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
615 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
616 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
617 return (posted); |
0 | 618 } |
619 | |
620 /* | |
621 * jk 991215 - Added | |
622 */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
623 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
624 SDL_CheckKeyRepeat(void) |
0 | 625 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
626 if (SDL_KeyRepeat.timestamp) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
627 Uint32 now, interval; |
0 | 628 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
629 now = SDL_GetTicks(); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
630 interval = (now - SDL_KeyRepeat.timestamp); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
631 if (SDL_KeyRepeat.firsttime) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
632 if (interval > (Uint32) SDL_KeyRepeat.delay) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
633 SDL_KeyRepeat.timestamp = now; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
634 SDL_KeyRepeat.firsttime = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
635 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
636 } else { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
637 if (interval > (Uint32) SDL_KeyRepeat.interval) { |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
638 SDL_KeyRepeat.timestamp = now; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
639 if ((SDL_EventOK == NULL) |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
640 || SDL_EventOK(&SDL_KeyRepeat.evt)) { |
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
641 SDL_PushEvent(&SDL_KeyRepeat.evt); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
642 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
643 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
644 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
645 } |
0 | 646 } |
647 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
648 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
649 SDL_EnableKeyRepeat(int delay, int interval) |
0 | 650 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
651 if ((delay < 0) || (interval < 0)) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
652 SDL_SetError("keyboard repeat value less than zero"); |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
653 return (-1); |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
654 } |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
655 SDL_KeyRepeat.firsttime = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
656 SDL_KeyRepeat.delay = delay; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
657 SDL_KeyRepeat.interval = interval; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
658 SDL_KeyRepeat.timestamp = 0; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
659 return (0); |
0 | 660 } |
661 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
662 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
663 SDL_GetKeyRepeat(int *delay, int *interval) |
1507 | 664 { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
665 *delay = SDL_KeyRepeat.delay; |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
666 *interval = SDL_KeyRepeat.interval; |
1507 | 667 } |
668 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1659
diff
changeset
|
669 /* vi: set ts=4 sw=4 expandtab: */ |