Mercurial > sdl-ios-xcode
annotate src/events/SDL_keyboard.c @ 1724:6c63fc2bd986 SDL-1.3
Proof of concept done - Win32 GDI implementation mostly complete.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 06 Jul 2006 07:17:11 +0000 |
parents | 5daa04d862f1 |
children | 875c3cf1a12c |
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 */ |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
33 int SDL_TranslateUNICODE = 0; |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
34 static int SDL_num_keyboards; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
35 static int SDL_current_keyboard; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
36 static SDL_Keyboard **SDL_keyboards; |
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 /* Initialize the tables */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
50 for (i = 0; i < SDL_arraysize(SDL_keynames); ++i) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
51 switch (i) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
52 case SDLK_BACKSPACE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
53 SDL_keynames[i] = "backspace"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
54 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
55 case SDLK_TAB: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
56 SDL_keynames[i] = "tab"; |
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_CLEAR: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
59 SDL_keynames[i] = "clear"; |
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_RETURN: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
62 SDL_keynames[i] = "return"; |
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_PAUSE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
65 SDL_keynames[i] = "pause"; |
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_ESCAPE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
68 SDL_keynames[i] = "escape"; |
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_SPACE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
71 SDL_keynames[i] = "space"; |
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 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
74 case SDLK_KP0: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
75 SDL_keynames[i] = "[0]"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
76 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
77 case SDLK_KP1: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
78 SDL_keynames[i] = "[1]"; |
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_KP2: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
81 SDL_keynames[i] = "[2]"; |
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_KP3: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
84 SDL_keynames[i] = "[3]"; |
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_KP4: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
87 SDL_keynames[i] = "[4]"; |
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_KP5: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
90 SDL_keynames[i] = "[5]"; |
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_KP6: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
93 SDL_keynames[i] = "[6]"; |
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_KP7: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
96 SDL_keynames[i] = "[7]"; |
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_KP8: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
99 SDL_keynames[i] = "[8]"; |
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_KP9: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
102 SDL_keynames[i] = "[9]"; |
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_KP_PERIOD: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
105 SDL_keynames[i] = "[.]"; |
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_DIVIDE: |
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_MULTIPLY: |
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_MINUS: |
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_PLUS: |
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_ENTER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
120 SDL_keynames[i] = "enter"; |
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_EQUALS: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
123 SDL_keynames[i] = "equals"; |
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 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
126 case SDLK_UP: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
127 SDL_keynames[i] = "up"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
128 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
129 case SDLK_DOWN: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
130 SDL_keynames[i] = "down"; |
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_RIGHT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
133 SDL_keynames[i] = "right"; |
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_LEFT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
136 SDL_keynames[i] = "left"; |
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_INSERT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
139 SDL_keynames[i] = "insert"; |
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_HOME: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
142 SDL_keynames[i] = "home"; |
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_END: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
145 SDL_keynames[i] = "end"; |
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_PAGEUP: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
148 SDL_keynames[i] = "page up"; |
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_PAGEDOWN: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
151 SDL_keynames[i] = "page down"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
152 break; |
0 | 153 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
154 case SDLK_F1: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
155 SDL_keynames[i] = "f1"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
156 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
157 case SDLK_F2: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
158 SDL_keynames[i] = "f2"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
159 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
160 case SDLK_F3: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
161 SDL_keynames[i] = "f3"; |
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_F4: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
164 SDL_keynames[i] = "f4"; |
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_F5: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
167 SDL_keynames[i] = "f5"; |
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_F6: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
170 SDL_keynames[i] = "f6"; |
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_F7: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
173 SDL_keynames[i] = "f7"; |
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_F8: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
176 SDL_keynames[i] = "f8"; |
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_F9: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
179 SDL_keynames[i] = "f9"; |
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_F10: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
182 SDL_keynames[i] = "f10"; |
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_F11: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
185 SDL_keynames[i] = "f11"; |
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_F12: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
188 SDL_keynames[i] = "f12"; |
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_F13: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
191 SDL_keynames[i] = "f13"; |
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_F14: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
194 SDL_keynames[i] = "f14"; |
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_F15: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
197 SDL_keynames[i] = "f15"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
198 break; |
0 | 199 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
200 case SDLK_NUMLOCK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
201 SDL_keynames[i] = "numlock"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
202 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
203 case SDLK_CAPSLOCK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
204 SDL_keynames[i] = "caps lock"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
205 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
206 case SDLK_SCROLLOCK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
207 SDL_keynames[i] = "scroll lock"; |
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_RSHIFT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
210 SDL_keynames[i] = "right shift"; |
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_LSHIFT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
213 SDL_keynames[i] = "left shift"; |
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_RCTRL: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
216 SDL_keynames[i] = "right ctrl"; |
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_LCTRL: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
219 SDL_keynames[i] = "left ctrl"; |
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_RALT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
222 SDL_keynames[i] = "right alt"; |
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_LALT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
225 SDL_keynames[i] = "left alt"; |
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_RMETA: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
228 SDL_keynames[i] = "right meta"; |
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_LMETA: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
231 SDL_keynames[i] = "left meta"; |
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_LSUPER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
234 SDL_keynames[i] = "left super"; /* "Windows" keys */ |
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_RSUPER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
237 SDL_keynames[i] = "right super"; |
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_MODE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
240 SDL_keynames[i] = "alt gr"; |
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_COMPOSE: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
243 SDL_keynames[i] = "compose"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
244 break; |
0 | 245 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
246 case SDLK_HELP: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
247 SDL_keynames[i] = "help"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
248 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
249 case SDLK_PRINT: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
250 SDL_keynames[i] = "print screen"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
251 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
252 case SDLK_SYSREQ: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
253 SDL_keynames[i] = "sys req"; |
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_BREAK: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
256 SDL_keynames[i] = "break"; |
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_MENU: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
259 SDL_keynames[i] = "menu"; |
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_POWER: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
262 SDL_keynames[i] = "power"; |
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_EURO: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
265 SDL_keynames[i] = "euro"; |
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_UNDO: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
268 SDL_keynames[i] = "undo"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
269 break; |
0 | 270 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
271 default: |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
272 SDL_keynames[i] = NULL; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
273 break; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
274 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
275 } |
0 | 276 |
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
|
277 /* 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
|
278 return (0); |
0 | 279 } |
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
|
280 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
281 SDL_Keyboard * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
282 SDL_GetKeyboard(int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
283 { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
284 if (index < 0 || index >= SDL_num_keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
285 return NULL; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
286 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
287 return SDL_keyboards[index]; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
288 } |
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 int |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
291 SDL_AddKeyboard(const SDL_Keyboard * keyboard, int index) |
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 SDL_Keyboard **keyboards; |
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 /* Add the keyboard to the list of keyboards */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
296 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
|
297 keyboards = |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
298 (SDL_Keyboard **) SDL_realloc(SDL_keyboards, |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
299 (SDL_num_keyboards + |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
300 1) * sizeof(*keyboards)); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
301 if (!keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
302 SDL_OutOfMemory(); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
303 return -1; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
304 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
305 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
306 SDL_keyboards = keyboards; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
307 index = SDL_num_keyboards++; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
308 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
309 SDL_keyboards[index] = |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
310 (SDL_Keyboard *) SDL_malloc(sizeof(*SDL_keyboards[index])); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
311 if (!SDL_keyboards[index]) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
312 SDL_OutOfMemory(); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
313 return -1; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
314 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
315 *SDL_keyboards[index] = *keyboard; |
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 return index; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
318 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
319 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
320 void |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
321 SDL_DelKeyboard(int index) |
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_Keyboard *keyboard = SDL_GetKeyboard(index); |
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 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
326 return; |
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 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
329 if (keyboard->FreeKeyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
330 keyboard->FreeKeyboard(keyboard); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
331 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
332 SDL_free(keyboard); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
333 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
334 SDL_keyboards[index] = NULL; |
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 void |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
338 SDL_ResetKeyboard(int index) |
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_Keyboard *keyboard = SDL_GetKeyboard(index); |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
341 SDLKey key; |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
342 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
343 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
344 return; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
345 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
346 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
347 for (key = SDLK_FIRST; key < SDLK_LAST; ++key) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
348 if (keyboard->keystate[key] == SDL_PRESSED) { |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
349 SDL_SendKeyboardKey(index, SDL_RELEASED, 0, key); |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
350 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
351 } |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
352 keyboard->repeat.timestamp = 0; |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
353 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
354 |
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
|
355 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
356 SDL_KeyboardQuit(void) |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
1021
diff
changeset
|
357 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
358 int i; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
359 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
360 for (i = 0; i < SDL_num_keyboards; ++i) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
361 SDL_DelKeyboard(i); |
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 SDL_num_keyboards = 0; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
364 SDL_current_keyboard = 0; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
365 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
366 if (SDL_keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
367 SDL_free(SDL_keyboards); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
368 SDL_keyboards = NULL; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
369 } |
1123
28ac87a38c17
Date: Fri, 08 Jul 2005 22:43:48 +0200 (CEST)
Sam Lantinga <slouken@libsdl.org>
parents:
1021
diff
changeset
|
370 } |
0 | 371 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
372 int |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
373 SDL_GetNumKeyboards(void) |
0 | 374 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
375 return SDL_num_keyboards; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
376 } |
0 | 377 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
378 int |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
379 SDL_SelectKeyboard(int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
380 { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
381 if (index >= 0 && index < SDL_num_keyboards) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
382 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
|
383 } |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
384 return SDL_current_keyboard; |
0 | 385 } |
386 | |
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
|
387 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
388 SDL_EnableUNICODE(int enable) |
0 | 389 { |
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
|
390 int old_mode; |
0 | 391 |
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
|
392 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
|
393 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
|
394 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
|
395 } |
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
|
396 return (old_mode); |
0 | 397 } |
398 | |
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
|
399 Uint8 * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
400 SDL_GetKeyState(int *numkeys) |
0 | 401 { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
402 SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
403 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
404 if (numkeys != (int *) 0) { |
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
|
405 *numkeys = SDLK_LAST; |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
406 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
407 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
408 if (!keyboard) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
409 return NULL; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
410 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
411 return keyboard->keystate; |
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 |
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 SDLMod |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
415 SDL_GetModState(void) |
0 | 416 { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
417 SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
418 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
419 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
420 return KMOD_NONE; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
421 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
422 return keyboard->modstate; |
0 | 423 } |
424 | |
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
|
425 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
426 SDL_SetModState(SDLMod modstate) |
0 | 427 { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
428 SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
429 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
430 if (!keyboard) { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
431 return; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
432 } |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
433 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
|
434 } |
0 | 435 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
436 const char * |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
437 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
|
438 { |
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
|
439 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
|
440 |
1679 | 441 if (key < SDL_arraysize(SDL_keynames)) { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
442 keyname = SDL_keynames[key]; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
443 } else { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
444 keyname = NULL; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
445 } |
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]; |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
449 char *cvt; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
450 temp[0] = (char) key; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
451 temp[1] = '\0'; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
452 cvt = SDL_iconv_string("UTF-8", "LATIN1", temp, 1); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
453 SDL_strlcpy(temp, cvt, SDL_arraysize(temp)); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
454 SDL_free(cvt); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
455 keyname = temp; |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
456 } else { |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
457 keyname = "unknown key"; |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
458 } |
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
|
459 } |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1670
diff
changeset
|
460 return keyname; |
0 | 461 } |
462 | |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
463 void |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
464 SDL_SetKeyboardFocus(int index, SDL_WindowID windowID) |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
465 { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
466 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
467 int i; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
468 SDL_bool focus; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
469 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
470 if (!keyboard || (keyboard->focus == windowID)) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
471 return; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
472 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
473 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
474 /* See if the current window has lost focus */ |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
475 if (keyboard->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
476 focus = SDL_FALSE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
477 for (i = 0; i < SDL_num_keyboards; ++i) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
478 SDL_Keyboard *check; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
479 if (i != index) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
480 check = SDL_GetKeyboard(i); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
481 if (check && check->focus == keyboard->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
482 focus = SDL_TRUE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
483 break; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
484 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
485 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
486 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
487 if (!focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
488 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
489 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
490 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
491 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
492 keyboard->focus = windowID; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
493 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
494 if (keyboard->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
495 focus = SDL_FALSE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
496 for (i = 0; i < SDL_num_keyboards; ++i) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
497 SDL_Keyboard *check; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
498 if (i != index) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
499 check = SDL_GetKeyboard(i); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
500 if (check && check->focus == keyboard->focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
501 focus = SDL_TRUE; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
502 break; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
503 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
504 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
505 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
506 if (!focus) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
507 SDL_SendWindowEvent(windowID, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
508 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
509 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
510 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
511 |
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
|
512 int |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
513 SDL_SendKeyboardKey(int index, Uint8 state, Uint8 scancode, SDLKey key) |
0 | 514 { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
515 SDL_Keyboard *keyboard = SDL_GetKeyboard(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
|
516 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
|
517 Uint16 modstate; |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
518 Uint8 type; |
0 | 519 |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
520 if (!keyboard) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
521 return 0; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
522 } |
0 | 523 #if 0 |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
524 printf("The '%s' key has been %s\n", SDL_GetKeyName(key), |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
525 state == SDL_PRESSED ? "pressed" : "released"); |
0 | 526 #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
|
527 repeatable = 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
|
528 if (state == SDL_PRESSED) { |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
529 modstate = keyboard->modstate; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
530 switch (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
|
531 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
|
532 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
|
533 case SDLK_NUMLOCK: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
534 keyboard->modstate ^= KMOD_NUM; |
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
|
535 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
|
536 case SDLK_CAPSLOCK: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
537 keyboard->modstate ^= KMOD_CAPS; |
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
|
538 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
|
539 case SDLK_LCTRL: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
540 keyboard->modstate |= KMOD_LCTRL; |
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
|
541 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
|
542 case SDLK_RCTRL: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
543 keyboard->modstate |= KMOD_RCTRL; |
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
|
544 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
|
545 case SDLK_LSHIFT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
546 keyboard->modstate |= KMOD_LSHIFT; |
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
|
547 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
|
548 case SDLK_RSHIFT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
549 keyboard->modstate |= KMOD_RSHIFT; |
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
|
550 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
|
551 case SDLK_LALT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
552 keyboard->modstate |= KMOD_LALT; |
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
|
553 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
|
554 case SDLK_RALT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
555 keyboard->modstate |= KMOD_RALT; |
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
|
556 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
|
557 case SDLK_LMETA: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
558 keyboard->modstate |= KMOD_LMETA; |
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
|
559 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
|
560 case SDLK_RMETA: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
561 keyboard->modstate |= KMOD_RMETA; |
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
|
562 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
|
563 case SDLK_MODE: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
564 keyboard->modstate |= KMOD_MODE; |
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 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
|
566 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
|
567 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
|
568 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
|
569 } |
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 } else { |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
571 switch (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
|
572 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
|
573 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
|
574 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
|
575 case SDLK_CAPSLOCK: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
576 break; |
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
|
577 case SDLK_LCTRL: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
578 keyboard->modstate &= ~KMOD_LCTRL; |
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
|
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 case SDLK_RCTRL: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
581 keyboard->modstate &= ~KMOD_RCTRL; |
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
|
582 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
|
583 case SDLK_LSHIFT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
584 keyboard->modstate &= ~KMOD_LSHIFT; |
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 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
|
586 case SDLK_RSHIFT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
587 keyboard->modstate &= ~KMOD_RSHIFT; |
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
|
588 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
|
589 case SDLK_LALT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
590 keyboard->modstate &= ~KMOD_LALT; |
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 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
|
592 case SDLK_RALT: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
593 keyboard->modstate &= ~KMOD_RALT; |
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 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
|
595 case SDLK_LMETA: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
596 keyboard->modstate &= ~KMOD_LMETA; |
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
|
597 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
|
598 case SDLK_RMETA: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
599 keyboard->modstate &= ~KMOD_RMETA; |
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
|
600 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
|
601 case SDLK_MODE: |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
602 keyboard->modstate &= ~KMOD_MODE; |
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
|
603 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
|
604 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
|
605 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
|
606 } |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
607 modstate = keyboard->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
|
608 } |
0 | 609 |
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
|
610 /* 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
|
611 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
|
612 case SDL_PRESSED: |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
613 type = SDL_KEYDOWN; |
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
|
614 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
|
615 case SDL_RELEASED: |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
616 type = SDL_KEYUP; |
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
|
617 /* |
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
|
618 * 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
|
619 */ |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
620 if (keyboard->repeat.timestamp && |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
621 keyboard->repeat.evt.key.keysym.sym == key) { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
622 keyboard->repeat.timestamp = 0; |
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 } |
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
|
624 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
|
625 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
|
626 /* Invalid state -- bail */ |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
627 return 0; |
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
|
628 } |
0 | 629 |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
630 if (key != SDLK_UNKNOWN) { |
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
|
631 /* Drop events that don't change state */ |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
632 if (keyboard->keystate[key] == state) { |
1282
217f5d5a49e5
Date: Sat, 15 Jan 2005 02:01:51 +0000 (UTC)
Sam Lantinga <slouken@libsdl.org>
parents:
1123
diff
changeset
|
633 #if 0 |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
634 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
|
635 #endif |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
636 return 0; |
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
|
637 } |
0 | 638 |
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
|
639 /* Update internal keyboard state */ |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
640 keyboard->keystate[key] = state; |
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
|
641 } |
0 | 642 |
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
|
643 /* 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
|
644 posted = 0; |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
645 if (SDL_ProcessEvents[type] == SDL_ENABLE) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
646 SDL_Event event; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
647 event.key.type = type; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
648 event.key.which = (Uint8) 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
|
649 event.key.state = state; |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
650 event.key.keysym.scancode = scancode; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
651 event.key.keysym.sym = (Uint16) key; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
652 event.key.keysym.mod = modstate; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
653 event.key.keysym.unicode = 0; |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
654 event.key.windowID = keyboard->focus; |
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
|
655 /* |
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 * 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
|
657 */ |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
658 if (repeatable && (keyboard->repeat.delay != 0)) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
659 Uint32 timestamp = SDL_GetTicks(); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
660 if (!timestamp) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
661 timestamp = 1; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
662 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
663 keyboard->repeat.evt = event; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
664 keyboard->repeat.firsttime = 1; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
665 keyboard->repeat.timestamp = 1; |
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
|
666 } |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
667 if ((SDL_EventOK == NULL) || SDL_EventOK(SDL_EventOKParam, &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
|
668 posted = 1; |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
669 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
|
670 } |
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
|
671 } |
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
|
672 return (posted); |
0 | 673 } |
674 | |
1724
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
675 int |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
676 SDL_SendKeyboardText(int index, const char *text) |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
677 { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
678 SDL_Keyboard *keyboard = SDL_GetKeyboard(index); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
679 int posted; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
680 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
681 if (!keyboard) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
682 return 0; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
683 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
684 |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
685 /* Post the event, if desired */ |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
686 posted = 0; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
687 if (SDL_ProcessEvents[SDL_TEXTINPUT] == SDL_ENABLE) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
688 SDL_Event event; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
689 event.text.type = SDL_TEXTINPUT; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
690 event.text.which = (Uint8) index; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
691 SDL_strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
692 event.key.windowID = keyboard->focus; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
693 if ((SDL_EventOK == NULL) || SDL_EventOK(SDL_EventOKParam, &event)) { |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
694 posted = 1; |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
695 SDL_PushEvent(&event); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
696 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
697 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
698 return (posted); |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
699 } |
6c63fc2bd986
Proof of concept done - Win32 GDI implementation mostly complete.
Sam Lantinga <slouken@libsdl.org>
parents:
1722
diff
changeset
|
700 |
0 | 701 /* |
702 * jk 991215 - Added | |
703 */ | |
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
|
704 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
705 SDL_CheckKeyRepeat(void) |
0 | 706 { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
707 int i; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
708 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
709 for (i = 0; i < SDL_num_keyboards; ++i) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
710 SDL_Keyboard *keyboard = SDL_keyboards[i]; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
711 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
712 if (!keyboard) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
713 continue; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
714 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
715 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
716 if (keyboard->repeat.timestamp) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
717 Uint32 now, interval; |
0 | 718 |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
719 now = SDL_GetTicks(); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
720 interval = (now - keyboard->repeat.timestamp); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
721 if (keyboard->repeat.firsttime) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
722 if (interval > (Uint32) keyboard->repeat.delay) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
723 keyboard->repeat.timestamp = now; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
724 keyboard->repeat.firsttime = 0; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
725 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
726 } else { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
727 if (interval > (Uint32) keyboard->repeat.interval) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
728 keyboard->repeat.timestamp = now; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
729 if ((SDL_EventOK == NULL) |
1722
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
730 || SDL_EventOK(SDL_EventOKParam, |
5daa04d862f1
Added a userdata parameter for event filters.
Sam Lantinga <slouken@libsdl.org>
parents:
1720
diff
changeset
|
731 &keyboard->repeat.evt)) { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
732 SDL_PushEvent(&keyboard->repeat.evt); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
733 } |
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
|
734 } |
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
|
735 } |
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
|
736 } |
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
|
737 } |
0 | 738 } |
739 | |
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
|
740 int |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
741 SDL_EnableKeyRepeat(int delay, int interval) |
0 | 742 { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
743 SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
744 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
745 if (!keyboard) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
746 SDL_SetError("No keyboard is currently selected"); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
747 return -1; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
748 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
749 |
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
|
750 if ((delay < 0) || (interval < 0)) { |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
751 SDL_SetError("keyboard repeat value less than zero"); |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
752 return -1; |
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
|
753 } |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
754 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
755 keyboard->repeat.firsttime = 0; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
756 keyboard->repeat.delay = delay; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
757 keyboard->repeat.interval = interval; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
758 keyboard->repeat.timestamp = 0; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
759 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
760 return 0; |
0 | 761 } |
762 | |
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
|
763 void |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
764 SDL_GetKeyRepeat(int *delay, int *interval) |
1507 | 765 { |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
766 SDL_Keyboard *keyboard = SDL_GetKeyboard(SDL_current_keyboard); |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
767 |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
768 if (!keyboard) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
769 if (delay) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
770 *delay = 0; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
771 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
772 if (interval) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
773 *interval = 0; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
774 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
775 return; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
776 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
777 if (delay) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
778 *delay = keyboard->repeat.delay; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
779 } |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
780 if (interval) { |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
781 *interval = keyboard->repeat.interval; |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
782 } |
1507 | 783 } |
784 | |
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
|
785 /* vi: set ts=4 sw=4 expandtab: */ |