comparison src/events/SDL_keyboard.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents 14717b52abc0
children 4da1ee79c9af
comparison
equal deleted inserted replaced
1661:281d3f4870e5 1662:782fd950bd46
28 #include "SDL_events_c.h" 28 #include "SDL_events_c.h"
29 #include "SDL_sysevents.h" 29 #include "SDL_sysevents.h"
30 30
31 31
32 /* Global keystate information */ 32 /* Global keystate information */
33 static Uint8 SDL_KeyState[SDLK_LAST]; 33 static Uint8 SDL_KeyState[SDLK_LAST];
34 static SDLMod SDL_ModState; 34 static SDLMod SDL_ModState;
35 int SDL_TranslateUNICODE = 0; 35 int SDL_TranslateUNICODE = 0;
36 36
37 static const char *keynames[SDLK_LAST]; /* Array of keycode names */ 37 static const char *keynames[SDLK_LAST]; /* Array of keycode names */
38 38
39 /* 39 /*
40 * jk 991215 - added 40 * jk 991215 - added
41 */ 41 */
42 struct { 42 struct
43 int firsttime; /* if we check against the delay or repeat value */ 43 {
44 int delay; /* the delay before we start repeating */ 44 int firsttime; /* if we check against the delay or repeat value */
45 int interval; /* the delay between key repeat events */ 45 int delay; /* the delay before we start repeating */
46 Uint32 timestamp; /* the time the first keydown event occurred */ 46 int interval; /* the delay between key repeat events */
47 47 Uint32 timestamp; /* the time the first keydown event occurred */
48 SDL_Event evt; /* the event we are supposed to repeat */ 48
49 SDL_Event evt; /* the event we are supposed to repeat */
49 } SDL_KeyRepeat; 50 } SDL_KeyRepeat;
50 51
51 /* Public functions */ 52 /* Public functions */
52 int SDL_KeyboardInit(void) 53 int
53 { 54 SDL_KeyboardInit (void)
54 SDL_VideoDevice *video = current_video; 55 {
55 SDL_VideoDevice *this = current_video; 56 SDL_VideoDevice *_this = SDL_GetVideoDevice ();
56 57
57 /* Set default mode of UNICODE translation */ 58 /* Set default mode of UNICODE translation */
58 SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION); 59 SDL_EnableUNICODE (DEFAULT_UNICODE_TRANSLATION);
59 60
60 /* Initialize the tables */ 61 /* Initialize the tables */
61 SDL_ModState = KMOD_NONE; 62 SDL_ModState = KMOD_NONE;
62 SDL_memset((void*)keynames, 0, sizeof(keynames)); 63 SDL_memset ((void *) keynames, 0, sizeof (keynames));
63 SDL_memset(SDL_KeyState, 0, sizeof(SDL_KeyState)); 64 SDL_memset (SDL_KeyState, 0, sizeof (SDL_KeyState));
64 video->InitOSKeymap(this); 65 _this->InitOSKeymap (_this);
65 66
66 SDL_EnableKeyRepeat(0, 0); 67 SDL_EnableKeyRepeat (0, 0);
67 68
68 /* Fill in the blanks in keynames */ 69 /* Fill in the blanks in keynames */
69 keynames[SDLK_BACKSPACE] = "backspace"; 70 keynames[SDLK_BACKSPACE] = "backspace";
70 keynames[SDLK_TAB] = "tab"; 71 keynames[SDLK_TAB] = "tab";
71 keynames[SDLK_CLEAR] = "clear"; 72 keynames[SDLK_CLEAR] = "clear";
72 keynames[SDLK_RETURN] = "return"; 73 keynames[SDLK_RETURN] = "return";
73 keynames[SDLK_PAUSE] = "pause"; 74 keynames[SDLK_PAUSE] = "pause";
74 keynames[SDLK_ESCAPE] = "escape"; 75 keynames[SDLK_ESCAPE] = "escape";
75 keynames[SDLK_SPACE] = "space"; 76 keynames[SDLK_SPACE] = "space";
76 keynames[SDLK_EXCLAIM] = "!"; 77 keynames[SDLK_EXCLAIM] = "!";
77 keynames[SDLK_QUOTEDBL] = "\""; 78 keynames[SDLK_QUOTEDBL] = "\"";
78 keynames[SDLK_HASH] = "#"; 79 keynames[SDLK_HASH] = "#";
79 keynames[SDLK_DOLLAR] = "$"; 80 keynames[SDLK_DOLLAR] = "$";
80 keynames[SDLK_AMPERSAND] = "&"; 81 keynames[SDLK_AMPERSAND] = "&";
81 keynames[SDLK_QUOTE] = "'"; 82 keynames[SDLK_QUOTE] = "'";
82 keynames[SDLK_LEFTPAREN] = "("; 83 keynames[SDLK_LEFTPAREN] = "(";
83 keynames[SDLK_RIGHTPAREN] = ")"; 84 keynames[SDLK_RIGHTPAREN] = ")";
84 keynames[SDLK_ASTERISK] = "*"; 85 keynames[SDLK_ASTERISK] = "*";
85 keynames[SDLK_PLUS] = "+"; 86 keynames[SDLK_PLUS] = "+";
86 keynames[SDLK_COMMA] = ","; 87 keynames[SDLK_COMMA] = ",";
87 keynames[SDLK_MINUS] = "-"; 88 keynames[SDLK_MINUS] = "-";
88 keynames[SDLK_PERIOD] = "."; 89 keynames[SDLK_PERIOD] = ".";
89 keynames[SDLK_SLASH] = "/"; 90 keynames[SDLK_SLASH] = "/";
90 keynames[SDLK_0] = "0"; 91 keynames[SDLK_0] = "0";
91 keynames[SDLK_1] = "1"; 92 keynames[SDLK_1] = "1";
92 keynames[SDLK_2] = "2"; 93 keynames[SDLK_2] = "2";
93 keynames[SDLK_3] = "3"; 94 keynames[SDLK_3] = "3";
94 keynames[SDLK_4] = "4"; 95 keynames[SDLK_4] = "4";
95 keynames[SDLK_5] = "5"; 96 keynames[SDLK_5] = "5";
96 keynames[SDLK_6] = "6"; 97 keynames[SDLK_6] = "6";
97 keynames[SDLK_7] = "7"; 98 keynames[SDLK_7] = "7";
98 keynames[SDLK_8] = "8"; 99 keynames[SDLK_8] = "8";
99 keynames[SDLK_9] = "9"; 100 keynames[SDLK_9] = "9";
100 keynames[SDLK_COLON] = ":"; 101 keynames[SDLK_COLON] = ":";
101 keynames[SDLK_SEMICOLON] = ";"; 102 keynames[SDLK_SEMICOLON] = ";";
102 keynames[SDLK_LESS] = "<"; 103 keynames[SDLK_LESS] = "<";
103 keynames[SDLK_EQUALS] = "="; 104 keynames[SDLK_EQUALS] = "=";
104 keynames[SDLK_GREATER] = ">"; 105 keynames[SDLK_GREATER] = ">";
105 keynames[SDLK_QUESTION] = "?"; 106 keynames[SDLK_QUESTION] = "?";
106 keynames[SDLK_AT] = "@"; 107 keynames[SDLK_AT] = "@";
107 keynames[SDLK_LEFTBRACKET] = "["; 108 keynames[SDLK_LEFTBRACKET] = "[";
108 keynames[SDLK_BACKSLASH] = "\\"; 109 keynames[SDLK_BACKSLASH] = "\\";
109 keynames[SDLK_RIGHTBRACKET] = "]"; 110 keynames[SDLK_RIGHTBRACKET] = "]";
110 keynames[SDLK_CARET] = "^"; 111 keynames[SDLK_CARET] = "^";
111 keynames[SDLK_UNDERSCORE] = "_"; 112 keynames[SDLK_UNDERSCORE] = "_";
112 keynames[SDLK_BACKQUOTE] = "`"; 113 keynames[SDLK_BACKQUOTE] = "`";
113 keynames[SDLK_a] = "a"; 114 keynames[SDLK_a] = "a";
114 keynames[SDLK_b] = "b"; 115 keynames[SDLK_b] = "b";
115 keynames[SDLK_c] = "c"; 116 keynames[SDLK_c] = "c";
116 keynames[SDLK_d] = "d"; 117 keynames[SDLK_d] = "d";
117 keynames[SDLK_e] = "e"; 118 keynames[SDLK_e] = "e";
118 keynames[SDLK_f] = "f"; 119 keynames[SDLK_f] = "f";
119 keynames[SDLK_g] = "g"; 120 keynames[SDLK_g] = "g";
120 keynames[SDLK_h] = "h"; 121 keynames[SDLK_h] = "h";
121 keynames[SDLK_i] = "i"; 122 keynames[SDLK_i] = "i";
122 keynames[SDLK_j] = "j"; 123 keynames[SDLK_j] = "j";
123 keynames[SDLK_k] = "k"; 124 keynames[SDLK_k] = "k";
124 keynames[SDLK_l] = "l"; 125 keynames[SDLK_l] = "l";
125 keynames[SDLK_m] = "m"; 126 keynames[SDLK_m] = "m";
126 keynames[SDLK_n] = "n"; 127 keynames[SDLK_n] = "n";
127 keynames[SDLK_o] = "o"; 128 keynames[SDLK_o] = "o";
128 keynames[SDLK_p] = "p"; 129 keynames[SDLK_p] = "p";
129 keynames[SDLK_q] = "q"; 130 keynames[SDLK_q] = "q";
130 keynames[SDLK_r] = "r"; 131 keynames[SDLK_r] = "r";
131 keynames[SDLK_s] = "s"; 132 keynames[SDLK_s] = "s";
132 keynames[SDLK_t] = "t"; 133 keynames[SDLK_t] = "t";
133 keynames[SDLK_u] = "u"; 134 keynames[SDLK_u] = "u";
134 keynames[SDLK_v] = "v"; 135 keynames[SDLK_v] = "v";
135 keynames[SDLK_w] = "w"; 136 keynames[SDLK_w] = "w";
136 keynames[SDLK_x] = "x"; 137 keynames[SDLK_x] = "x";
137 keynames[SDLK_y] = "y"; 138 keynames[SDLK_y] = "y";
138 keynames[SDLK_z] = "z"; 139 keynames[SDLK_z] = "z";
139 keynames[SDLK_DELETE] = "delete"; 140 keynames[SDLK_DELETE] = "delete";
140 141
141 keynames[SDLK_WORLD_0] = "world 0"; 142 keynames[SDLK_WORLD_0] = "world 0";
142 keynames[SDLK_WORLD_1] = "world 1"; 143 keynames[SDLK_WORLD_1] = "world 1";
143 keynames[SDLK_WORLD_2] = "world 2"; 144 keynames[SDLK_WORLD_2] = "world 2";
144 keynames[SDLK_WORLD_3] = "world 3"; 145 keynames[SDLK_WORLD_3] = "world 3";
145 keynames[SDLK_WORLD_4] = "world 4"; 146 keynames[SDLK_WORLD_4] = "world 4";
146 keynames[SDLK_WORLD_5] = "world 5"; 147 keynames[SDLK_WORLD_5] = "world 5";
147 keynames[SDLK_WORLD_6] = "world 6"; 148 keynames[SDLK_WORLD_6] = "world 6";
148 keynames[SDLK_WORLD_7] = "world 7"; 149 keynames[SDLK_WORLD_7] = "world 7";
149 keynames[SDLK_WORLD_8] = "world 8"; 150 keynames[SDLK_WORLD_8] = "world 8";
150 keynames[SDLK_WORLD_9] = "world 9"; 151 keynames[SDLK_WORLD_9] = "world 9";
151 keynames[SDLK_WORLD_10] = "world 10"; 152 keynames[SDLK_WORLD_10] = "world 10";
152 keynames[SDLK_WORLD_11] = "world 11"; 153 keynames[SDLK_WORLD_11] = "world 11";
153 keynames[SDLK_WORLD_12] = "world 12"; 154 keynames[SDLK_WORLD_12] = "world 12";
154 keynames[SDLK_WORLD_13] = "world 13"; 155 keynames[SDLK_WORLD_13] = "world 13";
155 keynames[SDLK_WORLD_14] = "world 14"; 156 keynames[SDLK_WORLD_14] = "world 14";
156 keynames[SDLK_WORLD_15] = "world 15"; 157 keynames[SDLK_WORLD_15] = "world 15";
157 keynames[SDLK_WORLD_16] = "world 16"; 158 keynames[SDLK_WORLD_16] = "world 16";
158 keynames[SDLK_WORLD_17] = "world 17"; 159 keynames[SDLK_WORLD_17] = "world 17";
159 keynames[SDLK_WORLD_18] = "world 18"; 160 keynames[SDLK_WORLD_18] = "world 18";
160 keynames[SDLK_WORLD_19] = "world 19"; 161 keynames[SDLK_WORLD_19] = "world 19";
161 keynames[SDLK_WORLD_20] = "world 20"; 162 keynames[SDLK_WORLD_20] = "world 20";
162 keynames[SDLK_WORLD_21] = "world 21"; 163 keynames[SDLK_WORLD_21] = "world 21";
163 keynames[SDLK_WORLD_22] = "world 22"; 164 keynames[SDLK_WORLD_22] = "world 22";
164 keynames[SDLK_WORLD_23] = "world 23"; 165 keynames[SDLK_WORLD_23] = "world 23";
165 keynames[SDLK_WORLD_24] = "world 24"; 166 keynames[SDLK_WORLD_24] = "world 24";
166 keynames[SDLK_WORLD_25] = "world 25"; 167 keynames[SDLK_WORLD_25] = "world 25";
167 keynames[SDLK_WORLD_26] = "world 26"; 168 keynames[SDLK_WORLD_26] = "world 26";
168 keynames[SDLK_WORLD_27] = "world 27"; 169 keynames[SDLK_WORLD_27] = "world 27";
169 keynames[SDLK_WORLD_28] = "world 28"; 170 keynames[SDLK_WORLD_28] = "world 28";
170 keynames[SDLK_WORLD_29] = "world 29"; 171 keynames[SDLK_WORLD_29] = "world 29";
171 keynames[SDLK_WORLD_30] = "world 30"; 172 keynames[SDLK_WORLD_30] = "world 30";
172 keynames[SDLK_WORLD_31] = "world 31"; 173 keynames[SDLK_WORLD_31] = "world 31";
173 keynames[SDLK_WORLD_32] = "world 32"; 174 keynames[SDLK_WORLD_32] = "world 32";
174 keynames[SDLK_WORLD_33] = "world 33"; 175 keynames[SDLK_WORLD_33] = "world 33";
175 keynames[SDLK_WORLD_34] = "world 34"; 176 keynames[SDLK_WORLD_34] = "world 34";
176 keynames[SDLK_WORLD_35] = "world 35"; 177 keynames[SDLK_WORLD_35] = "world 35";
177 keynames[SDLK_WORLD_36] = "world 36"; 178 keynames[SDLK_WORLD_36] = "world 36";
178 keynames[SDLK_WORLD_37] = "world 37"; 179 keynames[SDLK_WORLD_37] = "world 37";
179 keynames[SDLK_WORLD_38] = "world 38"; 180 keynames[SDLK_WORLD_38] = "world 38";
180 keynames[SDLK_WORLD_39] = "world 39"; 181 keynames[SDLK_WORLD_39] = "world 39";
181 keynames[SDLK_WORLD_40] = "world 40"; 182 keynames[SDLK_WORLD_40] = "world 40";
182 keynames[SDLK_WORLD_41] = "world 41"; 183 keynames[SDLK_WORLD_41] = "world 41";
183 keynames[SDLK_WORLD_42] = "world 42"; 184 keynames[SDLK_WORLD_42] = "world 42";
184 keynames[SDLK_WORLD_43] = "world 43"; 185 keynames[SDLK_WORLD_43] = "world 43";
185 keynames[SDLK_WORLD_44] = "world 44"; 186 keynames[SDLK_WORLD_44] = "world 44";
186 keynames[SDLK_WORLD_45] = "world 45"; 187 keynames[SDLK_WORLD_45] = "world 45";
187 keynames[SDLK_WORLD_46] = "world 46"; 188 keynames[SDLK_WORLD_46] = "world 46";
188 keynames[SDLK_WORLD_47] = "world 47"; 189 keynames[SDLK_WORLD_47] = "world 47";
189 keynames[SDLK_WORLD_48] = "world 48"; 190 keynames[SDLK_WORLD_48] = "world 48";
190 keynames[SDLK_WORLD_49] = "world 49"; 191 keynames[SDLK_WORLD_49] = "world 49";
191 keynames[SDLK_WORLD_50] = "world 50"; 192 keynames[SDLK_WORLD_50] = "world 50";
192 keynames[SDLK_WORLD_51] = "world 51"; 193 keynames[SDLK_WORLD_51] = "world 51";
193 keynames[SDLK_WORLD_52] = "world 52"; 194 keynames[SDLK_WORLD_52] = "world 52";
194 keynames[SDLK_WORLD_53] = "world 53"; 195 keynames[SDLK_WORLD_53] = "world 53";
195 keynames[SDLK_WORLD_54] = "world 54"; 196 keynames[SDLK_WORLD_54] = "world 54";
196 keynames[SDLK_WORLD_55] = "world 55"; 197 keynames[SDLK_WORLD_55] = "world 55";
197 keynames[SDLK_WORLD_56] = "world 56"; 198 keynames[SDLK_WORLD_56] = "world 56";
198 keynames[SDLK_WORLD_57] = "world 57"; 199 keynames[SDLK_WORLD_57] = "world 57";
199 keynames[SDLK_WORLD_58] = "world 58"; 200 keynames[SDLK_WORLD_58] = "world 58";
200 keynames[SDLK_WORLD_59] = "world 59"; 201 keynames[SDLK_WORLD_59] = "world 59";
201 keynames[SDLK_WORLD_60] = "world 60"; 202 keynames[SDLK_WORLD_60] = "world 60";
202 keynames[SDLK_WORLD_61] = "world 61"; 203 keynames[SDLK_WORLD_61] = "world 61";
203 keynames[SDLK_WORLD_62] = "world 62"; 204 keynames[SDLK_WORLD_62] = "world 62";
204 keynames[SDLK_WORLD_63] = "world 63"; 205 keynames[SDLK_WORLD_63] = "world 63";
205 keynames[SDLK_WORLD_64] = "world 64"; 206 keynames[SDLK_WORLD_64] = "world 64";
206 keynames[SDLK_WORLD_65] = "world 65"; 207 keynames[SDLK_WORLD_65] = "world 65";
207 keynames[SDLK_WORLD_66] = "world 66"; 208 keynames[SDLK_WORLD_66] = "world 66";
208 keynames[SDLK_WORLD_67] = "world 67"; 209 keynames[SDLK_WORLD_67] = "world 67";
209 keynames[SDLK_WORLD_68] = "world 68"; 210 keynames[SDLK_WORLD_68] = "world 68";
210 keynames[SDLK_WORLD_69] = "world 69"; 211 keynames[SDLK_WORLD_69] = "world 69";
211 keynames[SDLK_WORLD_70] = "world 70"; 212 keynames[SDLK_WORLD_70] = "world 70";
212 keynames[SDLK_WORLD_71] = "world 71"; 213 keynames[SDLK_WORLD_71] = "world 71";
213 keynames[SDLK_WORLD_72] = "world 72"; 214 keynames[SDLK_WORLD_72] = "world 72";
214 keynames[SDLK_WORLD_73] = "world 73"; 215 keynames[SDLK_WORLD_73] = "world 73";
215 keynames[SDLK_WORLD_74] = "world 74"; 216 keynames[SDLK_WORLD_74] = "world 74";
216 keynames[SDLK_WORLD_75] = "world 75"; 217 keynames[SDLK_WORLD_75] = "world 75";
217 keynames[SDLK_WORLD_76] = "world 76"; 218 keynames[SDLK_WORLD_76] = "world 76";
218 keynames[SDLK_WORLD_77] = "world 77"; 219 keynames[SDLK_WORLD_77] = "world 77";
219 keynames[SDLK_WORLD_78] = "world 78"; 220 keynames[SDLK_WORLD_78] = "world 78";
220 keynames[SDLK_WORLD_79] = "world 79"; 221 keynames[SDLK_WORLD_79] = "world 79";
221 keynames[SDLK_WORLD_80] = "world 80"; 222 keynames[SDLK_WORLD_80] = "world 80";
222 keynames[SDLK_WORLD_81] = "world 81"; 223 keynames[SDLK_WORLD_81] = "world 81";
223 keynames[SDLK_WORLD_82] = "world 82"; 224 keynames[SDLK_WORLD_82] = "world 82";
224 keynames[SDLK_WORLD_83] = "world 83"; 225 keynames[SDLK_WORLD_83] = "world 83";
225 keynames[SDLK_WORLD_84] = "world 84"; 226 keynames[SDLK_WORLD_84] = "world 84";
226 keynames[SDLK_WORLD_85] = "world 85"; 227 keynames[SDLK_WORLD_85] = "world 85";
227 keynames[SDLK_WORLD_86] = "world 86"; 228 keynames[SDLK_WORLD_86] = "world 86";
228 keynames[SDLK_WORLD_87] = "world 87"; 229 keynames[SDLK_WORLD_87] = "world 87";
229 keynames[SDLK_WORLD_88] = "world 88"; 230 keynames[SDLK_WORLD_88] = "world 88";
230 keynames[SDLK_WORLD_89] = "world 89"; 231 keynames[SDLK_WORLD_89] = "world 89";
231 keynames[SDLK_WORLD_90] = "world 90"; 232 keynames[SDLK_WORLD_90] = "world 90";
232 keynames[SDLK_WORLD_91] = "world 91"; 233 keynames[SDLK_WORLD_91] = "world 91";
233 keynames[SDLK_WORLD_92] = "world 92"; 234 keynames[SDLK_WORLD_92] = "world 92";
234 keynames[SDLK_WORLD_93] = "world 93"; 235 keynames[SDLK_WORLD_93] = "world 93";
235 keynames[SDLK_WORLD_94] = "world 94"; 236 keynames[SDLK_WORLD_94] = "world 94";
236 keynames[SDLK_WORLD_95] = "world 95"; 237 keynames[SDLK_WORLD_95] = "world 95";
237 238
238 keynames[SDLK_KP0] = "[0]"; 239 keynames[SDLK_KP0] = "[0]";
239 keynames[SDLK_KP1] = "[1]"; 240 keynames[SDLK_KP1] = "[1]";
240 keynames[SDLK_KP2] = "[2]"; 241 keynames[SDLK_KP2] = "[2]";
241 keynames[SDLK_KP3] = "[3]"; 242 keynames[SDLK_KP3] = "[3]";
242 keynames[SDLK_KP4] = "[4]"; 243 keynames[SDLK_KP4] = "[4]";
243 keynames[SDLK_KP5] = "[5]"; 244 keynames[SDLK_KP5] = "[5]";
244 keynames[SDLK_KP6] = "[6]"; 245 keynames[SDLK_KP6] = "[6]";
245 keynames[SDLK_KP7] = "[7]"; 246 keynames[SDLK_KP7] = "[7]";
246 keynames[SDLK_KP8] = "[8]"; 247 keynames[SDLK_KP8] = "[8]";
247 keynames[SDLK_KP9] = "[9]"; 248 keynames[SDLK_KP9] = "[9]";
248 keynames[SDLK_KP_PERIOD] = "[.]"; 249 keynames[SDLK_KP_PERIOD] = "[.]";
249 keynames[SDLK_KP_DIVIDE] = "[/]"; 250 keynames[SDLK_KP_DIVIDE] = "[/]";
250 keynames[SDLK_KP_MULTIPLY] = "[*]"; 251 keynames[SDLK_KP_MULTIPLY] = "[*]";
251 keynames[SDLK_KP_MINUS] = "[-]"; 252 keynames[SDLK_KP_MINUS] = "[-]";
252 keynames[SDLK_KP_PLUS] = "[+]"; 253 keynames[SDLK_KP_PLUS] = "[+]";
253 keynames[SDLK_KP_ENTER] = "enter"; 254 keynames[SDLK_KP_ENTER] = "enter";
254 keynames[SDLK_KP_EQUALS] = "equals"; 255 keynames[SDLK_KP_EQUALS] = "equals";
255 256
256 keynames[SDLK_UP] = "up"; 257 keynames[SDLK_UP] = "up";
257 keynames[SDLK_DOWN] = "down"; 258 keynames[SDLK_DOWN] = "down";
258 keynames[SDLK_RIGHT] = "right"; 259 keynames[SDLK_RIGHT] = "right";
259 keynames[SDLK_LEFT] = "left"; 260 keynames[SDLK_LEFT] = "left";
260 keynames[SDLK_DOWN] = "down"; 261 keynames[SDLK_DOWN] = "down";
261 keynames[SDLK_INSERT] = "insert"; 262 keynames[SDLK_INSERT] = "insert";
262 keynames[SDLK_HOME] = "home"; 263 keynames[SDLK_HOME] = "home";
263 keynames[SDLK_END] = "end"; 264 keynames[SDLK_END] = "end";
264 keynames[SDLK_PAGEUP] = "page up"; 265 keynames[SDLK_PAGEUP] = "page up";
265 keynames[SDLK_PAGEDOWN] = "page down"; 266 keynames[SDLK_PAGEDOWN] = "page down";
266 267
267 keynames[SDLK_F1] = "f1"; 268 keynames[SDLK_F1] = "f1";
268 keynames[SDLK_F2] = "f2"; 269 keynames[SDLK_F2] = "f2";
269 keynames[SDLK_F3] = "f3"; 270 keynames[SDLK_F3] = "f3";
270 keynames[SDLK_F4] = "f4"; 271 keynames[SDLK_F4] = "f4";
271 keynames[SDLK_F5] = "f5"; 272 keynames[SDLK_F5] = "f5";
272 keynames[SDLK_F6] = "f6"; 273 keynames[SDLK_F6] = "f6";
273 keynames[SDLK_F7] = "f7"; 274 keynames[SDLK_F7] = "f7";
274 keynames[SDLK_F8] = "f8"; 275 keynames[SDLK_F8] = "f8";
275 keynames[SDLK_F9] = "f9"; 276 keynames[SDLK_F9] = "f9";
276 keynames[SDLK_F10] = "f10"; 277 keynames[SDLK_F10] = "f10";
277 keynames[SDLK_F11] = "f11"; 278 keynames[SDLK_F11] = "f11";
278 keynames[SDLK_F12] = "f12"; 279 keynames[SDLK_F12] = "f12";
279 keynames[SDLK_F13] = "f13"; 280 keynames[SDLK_F13] = "f13";
280 keynames[SDLK_F14] = "f14"; 281 keynames[SDLK_F14] = "f14";
281 keynames[SDLK_F15] = "f15"; 282 keynames[SDLK_F15] = "f15";
282 283
283 keynames[SDLK_NUMLOCK] = "numlock"; 284 keynames[SDLK_NUMLOCK] = "numlock";
284 keynames[SDLK_CAPSLOCK] = "caps lock"; 285 keynames[SDLK_CAPSLOCK] = "caps lock";
285 keynames[SDLK_SCROLLOCK] = "scroll lock"; 286 keynames[SDLK_SCROLLOCK] = "scroll lock";
286 keynames[SDLK_RSHIFT] = "right shift"; 287 keynames[SDLK_RSHIFT] = "right shift";
287 keynames[SDLK_LSHIFT] = "left shift"; 288 keynames[SDLK_LSHIFT] = "left shift";
288 keynames[SDLK_RCTRL] = "right ctrl"; 289 keynames[SDLK_RCTRL] = "right ctrl";
289 keynames[SDLK_LCTRL] = "left ctrl"; 290 keynames[SDLK_LCTRL] = "left ctrl";
290 keynames[SDLK_RALT] = "right alt"; 291 keynames[SDLK_RALT] = "right alt";
291 keynames[SDLK_LALT] = "left alt"; 292 keynames[SDLK_LALT] = "left alt";
292 keynames[SDLK_RMETA] = "right meta"; 293 keynames[SDLK_RMETA] = "right meta";
293 keynames[SDLK_LMETA] = "left meta"; 294 keynames[SDLK_LMETA] = "left meta";
294 keynames[SDLK_LSUPER] = "left super"; /* "Windows" keys */ 295 keynames[SDLK_LSUPER] = "left super"; /* "Windows" keys */
295 keynames[SDLK_RSUPER] = "right super"; 296 keynames[SDLK_RSUPER] = "right super";
296 keynames[SDLK_MODE] = "alt gr"; 297 keynames[SDLK_MODE] = "alt gr";
297 keynames[SDLK_COMPOSE] = "compose"; 298 keynames[SDLK_COMPOSE] = "compose";
298 299
299 keynames[SDLK_HELP] = "help"; 300 keynames[SDLK_HELP] = "help";
300 keynames[SDLK_PRINT] = "print screen"; 301 keynames[SDLK_PRINT] = "print screen";
301 keynames[SDLK_SYSREQ] = "sys req"; 302 keynames[SDLK_SYSREQ] = "sys req";
302 keynames[SDLK_BREAK] = "break"; 303 keynames[SDLK_BREAK] = "break";
303 keynames[SDLK_MENU] = "menu"; 304 keynames[SDLK_MENU] = "menu";
304 keynames[SDLK_POWER] = "power"; 305 keynames[SDLK_POWER] = "power";
305 keynames[SDLK_EURO] = "euro"; 306 keynames[SDLK_EURO] = "euro";
306 keynames[SDLK_UNDO] = "undo"; 307 keynames[SDLK_UNDO] = "undo";
307 308
308 /* Done. Whew. */ 309 /* Done. Whew. */
309 return(0); 310 return (0);
310 } 311 }
311 void SDL_KeyboardQuit(void) 312
313 void
314 SDL_KeyboardQuit (void)
312 { 315 {
313 } 316 }
314 317
315 /* We lost the keyboard, so post key up messages for all pressed keys */ 318 /* We lost the keyboard, so post key up messages for all pressed keys */
316 void SDL_ResetKeyboard(void) 319 void
317 { 320 SDL_ResetKeyboard (void)
318 SDL_keysym keysym; 321 {
319 SDLKey key; 322 SDL_keysym keysym;
320 323 SDLKey key;
321 SDL_memset(&keysym, 0, (sizeof keysym)); 324
322 for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) { 325 SDL_memset (&keysym, 0, (sizeof keysym));
323 if ( SDL_KeyState[key] == SDL_PRESSED ) { 326 for (key = SDLK_FIRST; key < SDLK_LAST; ++key) {
324 keysym.sym = key; 327 if (SDL_KeyState[key] == SDL_PRESSED) {
325 SDL_PrivateKeyboard(SDL_RELEASED, &keysym); 328 keysym.sym = key;
326 } 329 SDL_PrivateKeyboard (SDL_RELEASED, &keysym);
327 } 330 }
328 SDL_KeyRepeat.timestamp = 0; 331 }
329 } 332 SDL_KeyRepeat.timestamp = 0;
330 333 }
331 int SDL_EnableUNICODE(int enable) 334
332 { 335 int
333 int old_mode; 336 SDL_EnableUNICODE (int enable)
334 337 {
335 old_mode = SDL_TranslateUNICODE; 338 int old_mode;
336 if ( enable >= 0 ) { 339
337 SDL_TranslateUNICODE = enable; 340 old_mode = SDL_TranslateUNICODE;
338 } 341 if (enable >= 0) {
339 return(old_mode); 342 SDL_TranslateUNICODE = enable;
340 } 343 }
341 344 return (old_mode);
342 Uint8 * SDL_GetKeyState (int *numkeys) 345 }
343 { 346
344 if ( numkeys != (int *)0 ) 347 Uint8 *
345 *numkeys = SDLK_LAST; 348 SDL_GetKeyState (int *numkeys)
346 return(SDL_KeyState); 349 {
347 } 350 if (numkeys != (int *) 0)
348 SDLMod SDL_GetModState (void) 351 *numkeys = SDLK_LAST;
349 { 352 return (SDL_KeyState);
350 return(SDL_ModState); 353 }
351 } 354
352 void SDL_SetModState (SDLMod modstate) 355 SDLMod
353 { 356 SDL_GetModState (void)
354 SDL_ModState = modstate; 357 {
355 } 358 return (SDL_ModState);
356 359 }
357 char *SDL_GetKeyName(SDLKey key) 360
358 { 361 void
359 const char *keyname; 362 SDL_SetModState (SDLMod modstate)
360 363 {
361 keyname = NULL; 364 SDL_ModState = modstate;
362 if ( key < SDLK_LAST ) { 365 }
363 keyname = keynames[key]; 366
364 } 367 char *
365 if ( keyname == NULL ) { 368 SDL_GetKeyName (SDLKey key)
366 keyname = "unknown key"; 369 {
367 } 370 const char *keyname;
368 /* FIXME: make this function const in 1.3 */ 371
369 return (char *)(keyname); 372 keyname = NULL;
373 if (key < SDLK_LAST) {
374 keyname = keynames[key];
375 }
376 if (keyname == NULL) {
377 keyname = "unknown key";
378 }
379 /* FIXME: make this function const in 1.3 */
380 return (char *) (keyname);
370 } 381 }
371 382
372 /* These are global for SDL_eventloop.c */ 383 /* These are global for SDL_eventloop.c */
373 int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *keysym) 384 int
374 { 385 SDL_PrivateKeyboard (Uint8 state, SDL_keysym * keysym)
375 SDL_Event event; 386 {
376 int posted, repeatable; 387 SDL_Event event;
377 Uint16 modstate; 388 int posted, repeatable;
378 389 Uint16 modstate;
379 SDL_memset(&event, 0, sizeof(event)); 390
391 SDL_memset (&event, 0, sizeof (event));
380 392
381 #if 0 393 #if 0
382 printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym), 394 printf ("The '%s' key has been %s\n", SDL_GetKeyName (keysym->sym),
383 state == SDL_PRESSED ? "pressed" : "released"); 395 state == SDL_PRESSED ? "pressed" : "released");
384 #endif 396 #endif
385 /* Set up the keysym */ 397 /* Set up the keysym */
386 modstate = (Uint16)SDL_ModState; 398 modstate = (Uint16) SDL_ModState;
387 399
388 repeatable = 0; 400 repeatable = 0;
389 401
390 if ( state == SDL_PRESSED ) { 402 if (state == SDL_PRESSED) {
391 keysym->mod = (SDLMod)modstate; 403 keysym->mod = (SDLMod) modstate;
392 switch (keysym->sym) { 404 switch (keysym->sym) {
393 case SDLK_UNKNOWN: 405 case SDLK_UNKNOWN:
394 break; 406 break;
395 case SDLK_NUMLOCK: 407 case SDLK_NUMLOCK:
396 modstate ^= KMOD_NUM; 408 modstate ^= KMOD_NUM;
397 if ( ! (modstate&KMOD_NUM) ) 409 if (!(modstate & KMOD_NUM))
398 state = SDL_RELEASED; 410 state = SDL_RELEASED;
399 keysym->mod = (SDLMod)modstate; 411 keysym->mod = (SDLMod) modstate;
400 break; 412 break;
401 case SDLK_CAPSLOCK: 413 case SDLK_CAPSLOCK:
402 modstate ^= KMOD_CAPS; 414 modstate ^= KMOD_CAPS;
403 if ( ! (modstate&KMOD_CAPS) ) 415 if (!(modstate & KMOD_CAPS))
404 state = SDL_RELEASED; 416 state = SDL_RELEASED;
405 keysym->mod = (SDLMod)modstate; 417 keysym->mod = (SDLMod) modstate;
406 break; 418 break;
407 case SDLK_LCTRL: 419 case SDLK_LCTRL:
408 modstate |= KMOD_LCTRL; 420 modstate |= KMOD_LCTRL;
409 break; 421 break;
410 case SDLK_RCTRL: 422 case SDLK_RCTRL:
411 modstate |= KMOD_RCTRL; 423 modstate |= KMOD_RCTRL;
412 break; 424 break;
413 case SDLK_LSHIFT: 425 case SDLK_LSHIFT:
414 modstate |= KMOD_LSHIFT; 426 modstate |= KMOD_LSHIFT;
415 break; 427 break;
416 case SDLK_RSHIFT: 428 case SDLK_RSHIFT:
417 modstate |= KMOD_RSHIFT; 429 modstate |= KMOD_RSHIFT;
418 break; 430 break;
419 case SDLK_LALT: 431 case SDLK_LALT:
420 modstate |= KMOD_LALT; 432 modstate |= KMOD_LALT;
421 break; 433 break;
422 case SDLK_RALT: 434 case SDLK_RALT:
423 modstate |= KMOD_RALT; 435 modstate |= KMOD_RALT;
424 break; 436 break;
425 case SDLK_LMETA: 437 case SDLK_LMETA:
426 modstate |= KMOD_LMETA; 438 modstate |= KMOD_LMETA;
427 break; 439 break;
428 case SDLK_RMETA: 440 case SDLK_RMETA:
429 modstate |= KMOD_RMETA; 441 modstate |= KMOD_RMETA;
430 break; 442 break;
431 case SDLK_MODE: 443 case SDLK_MODE:
432 modstate |= KMOD_MODE; 444 modstate |= KMOD_MODE;
433 break; 445 break;
434 default: 446 default:
435 repeatable = 1; 447 repeatable = 1;
436 break; 448 break;
437 } 449 }
438 } else { 450 } else {
439 switch (keysym->sym) { 451 switch (keysym->sym) {
440 case SDLK_UNKNOWN: 452 case SDLK_UNKNOWN:
441 break; 453 break;
442 case SDLK_NUMLOCK: 454 case SDLK_NUMLOCK:
443 case SDLK_CAPSLOCK: 455 case SDLK_CAPSLOCK:
444 /* Only send keydown events */ 456 /* Only send keydown events */
445 return(0); 457 return (0);
446 case SDLK_LCTRL: 458 case SDLK_LCTRL:
447 modstate &= ~KMOD_LCTRL; 459 modstate &= ~KMOD_LCTRL;
448 break; 460 break;
449 case SDLK_RCTRL: 461 case SDLK_RCTRL:
450 modstate &= ~KMOD_RCTRL; 462 modstate &= ~KMOD_RCTRL;
451 break; 463 break;
452 case SDLK_LSHIFT: 464 case SDLK_LSHIFT:
453 modstate &= ~KMOD_LSHIFT; 465 modstate &= ~KMOD_LSHIFT;
454 break; 466 break;
455 case SDLK_RSHIFT: 467 case SDLK_RSHIFT:
456 modstate &= ~KMOD_RSHIFT; 468 modstate &= ~KMOD_RSHIFT;
457 break; 469 break;
458 case SDLK_LALT: 470 case SDLK_LALT:
459 modstate &= ~KMOD_LALT; 471 modstate &= ~KMOD_LALT;
460 break; 472 break;
461 case SDLK_RALT: 473 case SDLK_RALT:
462 modstate &= ~KMOD_RALT; 474 modstate &= ~KMOD_RALT;
463 break; 475 break;
464 case SDLK_LMETA: 476 case SDLK_LMETA:
465 modstate &= ~KMOD_LMETA; 477 modstate &= ~KMOD_LMETA;
466 break; 478 break;
467 case SDLK_RMETA: 479 case SDLK_RMETA:
468 modstate &= ~KMOD_RMETA; 480 modstate &= ~KMOD_RMETA;
469 break; 481 break;
470 case SDLK_MODE: 482 case SDLK_MODE:
471 modstate &= ~KMOD_MODE; 483 modstate &= ~KMOD_MODE;
472 break; 484 break;
473 default: 485 default:
474 break; 486 break;
475 } 487 }
476 keysym->mod = (SDLMod)modstate; 488 keysym->mod = (SDLMod) modstate;
477 } 489 }
478 490
479 /* Figure out what type of event this is */ 491 /* Figure out what type of event this is */
480 switch (state) { 492 switch (state) {
481 case SDL_PRESSED: 493 case SDL_PRESSED:
482 event.type = SDL_KEYDOWN; 494 event.type = SDL_KEYDOWN;
483 break; 495 break;
484 case SDL_RELEASED: 496 case SDL_RELEASED:
485 event.type = SDL_KEYUP; 497 event.type = SDL_KEYUP;
486 /* 498 /*
487 * jk 991215 - Added 499 * jk 991215 - Added
488 */ 500 */
489 if ( SDL_KeyRepeat.timestamp && 501 if (SDL_KeyRepeat.timestamp &&
490 SDL_KeyRepeat.evt.key.keysym.sym == keysym->sym ) { 502 SDL_KeyRepeat.evt.key.keysym.sym == keysym->sym) {
491 SDL_KeyRepeat.timestamp = 0; 503 SDL_KeyRepeat.timestamp = 0;
492 } 504 }
493 break; 505 break;
494 default: 506 default:
495 /* Invalid state -- bail */ 507 /* Invalid state -- bail */
496 return(0); 508 return (0);
497 } 509 }
498 510
499 if ( keysym->sym != SDLK_UNKNOWN ) { 511 if (keysym->sym != SDLK_UNKNOWN) {
500 /* Drop events that don't change state */ 512 /* Drop events that don't change state */
501 if ( SDL_KeyState[keysym->sym] == state ) { 513 if (SDL_KeyState[keysym->sym] == state) {
502 #if 0 514 #if 0
503 printf("Keyboard event didn't change state - dropped!\n"); 515 printf ("Keyboard event didn't change state - dropped!\n");
504 #endif 516 #endif
505 return(0); 517 return (0);
506 } 518 }
507 519
508 /* Update internal keyboard state */ 520 /* Update internal keyboard state */
509 SDL_ModState = (SDLMod)modstate; 521 SDL_ModState = (SDLMod) modstate;
510 SDL_KeyState[keysym->sym] = state; 522 SDL_KeyState[keysym->sym] = state;
511 } 523 }
512 524
513 /* Post the event, if desired */ 525 /* Post the event, if desired */
514 posted = 0; 526 posted = 0;
515 if ( SDL_ProcessEvents[event.type] == SDL_ENABLE ) { 527 if (SDL_ProcessEvents[event.type] == SDL_ENABLE) {
516 event.key.state = state; 528 event.key.state = state;
517 event.key.keysym = *keysym; 529 event.key.keysym = *keysym;
518 /* 530 /*
519 * jk 991215 - Added 531 * jk 991215 - Added
520 */ 532 */
521 if (repeatable && (SDL_KeyRepeat.delay != 0)) { 533 if (repeatable && (SDL_KeyRepeat.delay != 0)) {
522 SDL_KeyRepeat.evt = event; 534 SDL_KeyRepeat.evt = event;
523 SDL_KeyRepeat.firsttime = 1; 535 SDL_KeyRepeat.firsttime = 1;
524 SDL_KeyRepeat.timestamp=SDL_GetTicks(); 536 SDL_KeyRepeat.timestamp = SDL_GetTicks ();
525 } 537 }
526 if ( (SDL_EventOK == NULL) || SDL_EventOK(&event) ) { 538 if ((SDL_EventOK == NULL) || SDL_EventOK (&event)) {
527 posted = 1; 539 posted = 1;
528 SDL_PushEvent(&event); 540 SDL_PushEvent (&event);
529 } 541 }
530 } 542 }
531 return(posted); 543 return (posted);
532 } 544 }
533 545
534 /* 546 /*
535 * jk 991215 - Added 547 * jk 991215 - Added
536 */ 548 */
537 void SDL_CheckKeyRepeat(void) 549 void
538 { 550 SDL_CheckKeyRepeat (void)
539 if ( SDL_KeyRepeat.timestamp ) { 551 {
540 Uint32 now, interval; 552 if (SDL_KeyRepeat.timestamp) {
541 553 Uint32 now, interval;
542 now = SDL_GetTicks(); 554
543 interval = (now - SDL_KeyRepeat.timestamp); 555 now = SDL_GetTicks ();
544 if ( SDL_KeyRepeat.firsttime ) { 556 interval = (now - SDL_KeyRepeat.timestamp);
545 if ( interval > (Uint32)SDL_KeyRepeat.delay ) { 557 if (SDL_KeyRepeat.firsttime) {
546 SDL_KeyRepeat.timestamp = now; 558 if (interval > (Uint32) SDL_KeyRepeat.delay) {
547 SDL_KeyRepeat.firsttime = 0; 559 SDL_KeyRepeat.timestamp = now;
548 } 560 SDL_KeyRepeat.firsttime = 0;
549 } else { 561 }
550 if ( interval > (Uint32)SDL_KeyRepeat.interval ) { 562 } else {
551 SDL_KeyRepeat.timestamp = now; 563 if (interval > (Uint32) SDL_KeyRepeat.interval) {
552 if ( (SDL_EventOK == NULL) || SDL_EventOK(&SDL_KeyRepeat.evt) ) { 564 SDL_KeyRepeat.timestamp = now;
553 SDL_PushEvent(&SDL_KeyRepeat.evt); 565 if ((SDL_EventOK == NULL)
554 } 566 || SDL_EventOK (&SDL_KeyRepeat.evt)) {
555 } 567 SDL_PushEvent (&SDL_KeyRepeat.evt);
556 } 568 }
557 } 569 }
558 } 570 }
559 571 }
560 int SDL_EnableKeyRepeat(int delay, int interval) 572 }
561 { 573
562 if ( (delay < 0) || (interval < 0) ) { 574 int
563 SDL_SetError("keyboard repeat value less than zero"); 575 SDL_EnableKeyRepeat (int delay, int interval)
564 return(-1); 576 {
565 } 577 if ((delay < 0) || (interval < 0)) {
566 SDL_KeyRepeat.firsttime = 0; 578 SDL_SetError ("keyboard repeat value less than zero");
567 SDL_KeyRepeat.delay = delay; 579 return (-1);
568 SDL_KeyRepeat.interval = interval; 580 }
569 SDL_KeyRepeat.timestamp = 0; 581 SDL_KeyRepeat.firsttime = 0;
570 return(0); 582 SDL_KeyRepeat.delay = delay;
571 } 583 SDL_KeyRepeat.interval = interval;
572 584 SDL_KeyRepeat.timestamp = 0;
573 void SDL_GetKeyRepeat(int *delay, int *interval) 585 return (0);
574 { 586 }
575 *delay = SDL_KeyRepeat.delay; 587
576 *interval = SDL_KeyRepeat.interval; 588 void
577 } 589 SDL_GetKeyRepeat (int *delay, int *interval)
578 590 {
591 *delay = SDL_KeyRepeat.delay;
592 *interval = SDL_KeyRepeat.interval;
593 }
594
595 /* vi: set ts=4 sw=4 expandtab: */