Mercurial > sdl-ios-xcode
comparison src/video/svga/SDL_svgaevents.c @ 1895:c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 10 Jul 2006 21:04:37 +0000 |
parents | d910939febfa |
children | e27bdcc80744 |
comparison
equal
deleted
inserted
replaced
1894:c69cee13dd76 | 1895:c121d94672cb |
---|---|
49 static keymap_t *vga_keymap = NULL; | 49 static keymap_t *vga_keymap = NULL; |
50 #else | 50 #else |
51 #error You must choose your operating system here | 51 #error You must choose your operating system here |
52 #endif | 52 #endif |
53 static SDLKey keymap[128]; | 53 static SDLKey keymap[128]; |
54 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym); | 54 static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym); |
55 | 55 |
56 /* Ugh, we have to duplicate the kernel's keysym mapping code... | 56 /* Ugh, we have to duplicate the kernel's keysym mapping code... |
57 Oh, it's not so bad. :-) | 57 Oh, it's not so bad. :-) |
58 | 58 |
59 FIXME: Add keyboard LED handling code | 59 FIXME: Add keyboard LED handling code |
60 */ | 60 */ |
61 #if defined(linux) | 61 #if defined(linux) |
62 int SVGA_initkeymaps(int fd) | 62 int |
63 { | 63 SVGA_initkeymaps(int fd) |
64 struct kbentry entry; | 64 { |
65 int map, i; | 65 struct kbentry entry; |
66 | 66 int map, i; |
67 /* Load all the keysym mappings */ | 67 |
68 for ( map=0; map<NUM_VGAKEYMAPS; ++map ) { | 68 /* Load all the keysym mappings */ |
69 SDL_memset(vga_keymap[map], 0, NR_KEYS*sizeof(Uint16)); | 69 for (map = 0; map < NUM_VGAKEYMAPS; ++map) { |
70 for ( i=0; i<NR_KEYS; ++i ) { | 70 SDL_memset(vga_keymap[map], 0, NR_KEYS * sizeof(Uint16)); |
71 entry.kb_table = map; | 71 for (i = 0; i < NR_KEYS; ++i) { |
72 entry.kb_index = i; | 72 entry.kb_table = map; |
73 if ( ioctl(fd, KDGKBENT, &entry) == 0 ) { | 73 entry.kb_index = i; |
74 /* The "Enter" key is a special case */ | 74 if (ioctl(fd, KDGKBENT, &entry) == 0) { |
75 if ( entry.kb_value == K_ENTER ) { | 75 /* The "Enter" key is a special case */ |
76 entry.kb_value = K(KT_ASCII,13); | 76 if (entry.kb_value == K_ENTER) { |
77 } | 77 entry.kb_value = K(KT_ASCII, 13); |
78 /* Handle numpad specially as well */ | 78 } |
79 if ( KTYP(entry.kb_value) == KT_PAD ) { | 79 /* Handle numpad specially as well */ |
80 switch ( entry.kb_value ) { | 80 if (KTYP(entry.kb_value) == KT_PAD) { |
81 case K_P0: | 81 switch (entry.kb_value) { |
82 case K_P1: | 82 case K_P0: |
83 case K_P2: | 83 case K_P1: |
84 case K_P3: | 84 case K_P2: |
85 case K_P4: | 85 case K_P3: |
86 case K_P5: | 86 case K_P4: |
87 case K_P6: | 87 case K_P5: |
88 case K_P7: | 88 case K_P6: |
89 case K_P8: | 89 case K_P7: |
90 case K_P9: | 90 case K_P8: |
91 vga_keymap[map][i]=entry.kb_value; | 91 case K_P9: |
92 vga_keymap[map][i]+= '0'; | 92 vga_keymap[map][i] = entry.kb_value; |
93 break; | 93 vga_keymap[map][i] += '0'; |
94 case K_PPLUS: | 94 break; |
95 vga_keymap[map][i]=K(KT_ASCII,'+'); | 95 case K_PPLUS: |
96 break; | 96 vga_keymap[map][i] = K(KT_ASCII, '+'); |
97 case K_PMINUS: | 97 break; |
98 vga_keymap[map][i]=K(KT_ASCII,'-'); | 98 case K_PMINUS: |
99 break; | 99 vga_keymap[map][i] = K(KT_ASCII, '-'); |
100 case K_PSTAR: | 100 break; |
101 vga_keymap[map][i]=K(KT_ASCII,'*'); | 101 case K_PSTAR: |
102 break; | 102 vga_keymap[map][i] = K(KT_ASCII, '*'); |
103 case K_PSLASH: | 103 break; |
104 vga_keymap[map][i]=K(KT_ASCII,'/'); | 104 case K_PSLASH: |
105 break; | 105 vga_keymap[map][i] = K(KT_ASCII, '/'); |
106 case K_PENTER: | 106 break; |
107 vga_keymap[map][i]=K(KT_ASCII,'\r'); | 107 case K_PENTER: |
108 break; | 108 vga_keymap[map][i] = K(KT_ASCII, '\r'); |
109 case K_PCOMMA: | 109 break; |
110 vga_keymap[map][i]=K(KT_ASCII,','); | 110 case K_PCOMMA: |
111 break; | 111 vga_keymap[map][i] = K(KT_ASCII, ','); |
112 case K_PDOT: | 112 break; |
113 vga_keymap[map][i]=K(KT_ASCII,'.'); | 113 case K_PDOT: |
114 break; | 114 vga_keymap[map][i] = K(KT_ASCII, '.'); |
115 default: | 115 break; |
116 break; | 116 default: |
117 } | 117 break; |
118 } | 118 } |
119 /* Do the normal key translation */ | 119 } |
120 if ( (KTYP(entry.kb_value) == KT_LATIN) || | 120 /* Do the normal key translation */ |
121 (KTYP(entry.kb_value) == KT_ASCII) || | 121 if ((KTYP(entry.kb_value) == KT_LATIN) || |
122 (KTYP(entry.kb_value) == KT_LETTER) ) { | 122 (KTYP(entry.kb_value) == KT_ASCII) || |
123 vga_keymap[map][i] = entry.kb_value; | 123 (KTYP(entry.kb_value) == KT_LETTER)) { |
124 } | 124 vga_keymap[map][i] = entry.kb_value; |
125 } | 125 } |
126 } | 126 } |
127 } | 127 } |
128 return(0); | 128 } |
129 return (0); | |
129 } | 130 } |
130 #elif defined(__FREEBSD__) | 131 #elif defined(__FREEBSD__) |
131 int SVGA_initkeymaps(int fd) | 132 int |
132 { | 133 SVGA_initkeymaps(int fd) |
133 vga_keymap = SDL_malloc(sizeof(keymap_t)); | 134 { |
134 if ( ! vga_keymap ) { | 135 vga_keymap = SDL_malloc(sizeof(keymap_t)); |
135 SDL_OutOfMemory(); | 136 if (!vga_keymap) { |
136 return(-1); | 137 SDL_OutOfMemory(); |
137 } | 138 return (-1); |
138 if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) { | 139 } |
139 SDL_free(vga_keymap); | 140 if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) { |
140 vga_keymap = NULL; | 141 SDL_free(vga_keymap); |
141 SDL_SetError("Unable to get keyboard map"); | 142 vga_keymap = NULL; |
142 return(-1); | 143 SDL_SetError("Unable to get keyboard map"); |
143 } | 144 return (-1); |
144 return(0); | 145 } |
146 return (0); | |
145 } | 147 } |
146 #else | 148 #else |
147 #error You must choose your operating system here | 149 #error You must choose your operating system here |
148 #endif | 150 #endif |
149 | 151 |
150 int posted = 0; | 152 int posted = 0; |
151 | 153 |
152 void SVGA_mousecallback(int button, int dx, int dy, | 154 void |
153 int u1,int u2,int u3, int u4) | 155 SVGA_mousecallback(int button, int dx, int dy, int u1, int u2, int u3, int u4) |
154 { | 156 { |
155 if ( dx || dy ) { | 157 if (dx || dy) { |
156 posted += SDL_PrivateMouseMotion(0, 1, dx, dy); | 158 posted += SDL_PrivateMouseMotion(0, 1, dx, dy); |
157 } | 159 } |
158 if ( button & MOUSE_LEFTBUTTON ) { | 160 if (button & MOUSE_LEFTBUTTON) { |
159 if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) { | 161 if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1))) { |
160 posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); | 162 posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); |
161 } | 163 } |
162 } else { | 164 } else { |
163 if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) { | 165 if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1))) { |
164 posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); | 166 posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); |
165 } | 167 } |
166 } | 168 } |
167 if ( button & MOUSE_MIDDLEBUTTON ) { | 169 if (button & MOUSE_MIDDLEBUTTON) { |
168 if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) { | 170 if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2))) { |
169 posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); | 171 posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); |
170 } | 172 } |
171 } else { | 173 } else { |
172 if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) { | 174 if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2))) { |
173 posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); | 175 posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); |
174 } | 176 } |
175 } | 177 } |
176 if ( button & MOUSE_RIGHTBUTTON ) { | 178 if (button & MOUSE_RIGHTBUTTON) { |
177 if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) { | 179 if (!(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3))) { |
178 posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); | 180 posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); |
179 } | 181 } |
180 } else { | 182 } else { |
181 if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) { | 183 if ((SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3))) { |
182 posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); | 184 posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); |
183 } | 185 } |
184 } | 186 } |
185 } | 187 } |
186 | 188 |
187 void SVGA_keyboardcallback(int scancode, int pressed) | 189 void |
188 { | 190 SVGA_keyboardcallback(int scancode, int pressed) |
189 SDL_keysym keysym; | 191 { |
190 | 192 SDL_keysym keysym; |
191 if ( pressed ) { | 193 |
192 posted += SDL_PrivateKeyboard(SDL_PRESSED, | 194 if (pressed) { |
193 TranslateKey(scancode, &keysym)); | 195 posted += SDL_PrivateKeyboard(SDL_PRESSED, |
194 } else { | 196 TranslateKey(scancode, &keysym)); |
195 posted += SDL_PrivateKeyboard(SDL_RELEASED, | 197 } else { |
196 TranslateKey(scancode, &keysym)); | 198 posted += SDL_PrivateKeyboard(SDL_RELEASED, |
197 } | 199 TranslateKey(scancode, &keysym)); |
198 } | 200 } |
199 | 201 } |
200 void SVGA_PumpEvents(_THIS) | 202 |
201 { | 203 void |
202 do { | 204 SVGA_PumpEvents(_THIS) |
203 posted = 0; | 205 { |
204 mouse_update(); | 206 do { |
205 keyboard_update(); | 207 posted = 0; |
206 } while ( posted ); | 208 mouse_update(); |
207 } | 209 keyboard_update(); |
208 | 210 } |
209 void SVGA_InitOSKeymap(_THIS) | 211 while (posted); |
210 { | 212 } |
211 int i; | 213 |
212 | 214 void |
213 /* Initialize the BeOS key translation table */ | 215 SVGA_InitOSKeymap(_THIS) |
214 for ( i=0; i<SDL_arraysize(keymap); ++i ) | 216 { |
215 keymap[i] = SDLK_UNKNOWN; | 217 int i; |
216 | 218 |
217 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; | 219 /* Initialize the BeOS key translation table */ |
218 keymap[SCANCODE_1] = SDLK_1; | 220 for (i = 0; i < SDL_arraysize(keymap); ++i) |
219 keymap[SCANCODE_2] = SDLK_2; | 221 keymap[i] = SDLK_UNKNOWN; |
220 keymap[SCANCODE_3] = SDLK_3; | 222 |
221 keymap[SCANCODE_4] = SDLK_4; | 223 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE; |
222 keymap[SCANCODE_5] = SDLK_5; | 224 keymap[SCANCODE_1] = SDLK_1; |
223 keymap[SCANCODE_6] = SDLK_6; | 225 keymap[SCANCODE_2] = SDLK_2; |
224 keymap[SCANCODE_7] = SDLK_7; | 226 keymap[SCANCODE_3] = SDLK_3; |
225 keymap[SCANCODE_8] = SDLK_8; | 227 keymap[SCANCODE_4] = SDLK_4; |
226 keymap[SCANCODE_9] = SDLK_9; | 228 keymap[SCANCODE_5] = SDLK_5; |
227 keymap[SCANCODE_0] = SDLK_0; | 229 keymap[SCANCODE_6] = SDLK_6; |
228 keymap[SCANCODE_MINUS] = SDLK_MINUS; | 230 keymap[SCANCODE_7] = SDLK_7; |
229 keymap[SCANCODE_EQUAL] = SDLK_EQUALS; | 231 keymap[SCANCODE_8] = SDLK_8; |
230 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; | 232 keymap[SCANCODE_9] = SDLK_9; |
231 keymap[SCANCODE_TAB] = SDLK_TAB; | 233 keymap[SCANCODE_0] = SDLK_0; |
232 keymap[SCANCODE_Q] = SDLK_q; | 234 keymap[SCANCODE_MINUS] = SDLK_MINUS; |
233 keymap[SCANCODE_W] = SDLK_w; | 235 keymap[SCANCODE_EQUAL] = SDLK_EQUALS; |
234 keymap[SCANCODE_E] = SDLK_e; | 236 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE; |
235 keymap[SCANCODE_R] = SDLK_r; | 237 keymap[SCANCODE_TAB] = SDLK_TAB; |
236 keymap[SCANCODE_T] = SDLK_t; | 238 keymap[SCANCODE_Q] = SDLK_q; |
237 keymap[SCANCODE_Y] = SDLK_y; | 239 keymap[SCANCODE_W] = SDLK_w; |
238 keymap[SCANCODE_U] = SDLK_u; | 240 keymap[SCANCODE_E] = SDLK_e; |
239 keymap[SCANCODE_I] = SDLK_i; | 241 keymap[SCANCODE_R] = SDLK_r; |
240 keymap[SCANCODE_O] = SDLK_o; | 242 keymap[SCANCODE_T] = SDLK_t; |
241 keymap[SCANCODE_P] = SDLK_p; | 243 keymap[SCANCODE_Y] = SDLK_y; |
242 keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET; | 244 keymap[SCANCODE_U] = SDLK_u; |
243 keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET; | 245 keymap[SCANCODE_I] = SDLK_i; |
244 keymap[SCANCODE_ENTER] = SDLK_RETURN; | 246 keymap[SCANCODE_O] = SDLK_o; |
245 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; | 247 keymap[SCANCODE_P] = SDLK_p; |
246 keymap[SCANCODE_A] = SDLK_a; | 248 keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET; |
247 keymap[SCANCODE_S] = SDLK_s; | 249 keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET; |
248 keymap[SCANCODE_D] = SDLK_d; | 250 keymap[SCANCODE_ENTER] = SDLK_RETURN; |
249 keymap[SCANCODE_F] = SDLK_f; | 251 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL; |
250 keymap[SCANCODE_G] = SDLK_g; | 252 keymap[SCANCODE_A] = SDLK_a; |
251 keymap[SCANCODE_H] = SDLK_h; | 253 keymap[SCANCODE_S] = SDLK_s; |
252 keymap[SCANCODE_J] = SDLK_j; | 254 keymap[SCANCODE_D] = SDLK_d; |
253 keymap[SCANCODE_K] = SDLK_k; | 255 keymap[SCANCODE_F] = SDLK_f; |
254 keymap[SCANCODE_L] = SDLK_l; | 256 keymap[SCANCODE_G] = SDLK_g; |
255 keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON; | 257 keymap[SCANCODE_H] = SDLK_h; |
256 keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE; | 258 keymap[SCANCODE_J] = SDLK_j; |
257 keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE; | 259 keymap[SCANCODE_K] = SDLK_k; |
258 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; | 260 keymap[SCANCODE_L] = SDLK_l; |
259 keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH; | 261 keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON; |
260 keymap[SCANCODE_Z] = SDLK_z; | 262 keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE; |
261 keymap[SCANCODE_X] = SDLK_x; | 263 keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE; |
262 keymap[SCANCODE_C] = SDLK_c; | 264 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT; |
263 keymap[SCANCODE_V] = SDLK_v; | 265 keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH; |
264 keymap[SCANCODE_B] = SDLK_b; | 266 keymap[SCANCODE_Z] = SDLK_z; |
265 keymap[SCANCODE_N] = SDLK_n; | 267 keymap[SCANCODE_X] = SDLK_x; |
266 keymap[SCANCODE_M] = SDLK_m; | 268 keymap[SCANCODE_C] = SDLK_c; |
267 keymap[SCANCODE_COMMA] = SDLK_COMMA; | 269 keymap[SCANCODE_V] = SDLK_v; |
268 keymap[SCANCODE_PERIOD] = SDLK_PERIOD; | 270 keymap[SCANCODE_B] = SDLK_b; |
269 keymap[SCANCODE_SLASH] = SDLK_SLASH; | 271 keymap[SCANCODE_N] = SDLK_n; |
270 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; | 272 keymap[SCANCODE_M] = SDLK_m; |
271 keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY; | 273 keymap[SCANCODE_COMMA] = SDLK_COMMA; |
272 keymap[SCANCODE_LEFTALT] = SDLK_LALT; | 274 keymap[SCANCODE_PERIOD] = SDLK_PERIOD; |
273 keymap[SCANCODE_SPACE] = SDLK_SPACE; | 275 keymap[SCANCODE_SLASH] = SDLK_SLASH; |
274 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; | 276 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT; |
275 keymap[SCANCODE_F1] = SDLK_F1; | 277 keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY; |
276 keymap[SCANCODE_F2] = SDLK_F2; | 278 keymap[SCANCODE_LEFTALT] = SDLK_LALT; |
277 keymap[SCANCODE_F3] = SDLK_F3; | 279 keymap[SCANCODE_SPACE] = SDLK_SPACE; |
278 keymap[SCANCODE_F4] = SDLK_F4; | 280 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK; |
279 keymap[SCANCODE_F5] = SDLK_F5; | 281 keymap[SCANCODE_F1] = SDLK_F1; |
280 keymap[SCANCODE_F6] = SDLK_F6; | 282 keymap[SCANCODE_F2] = SDLK_F2; |
281 keymap[SCANCODE_F7] = SDLK_F7; | 283 keymap[SCANCODE_F3] = SDLK_F3; |
282 keymap[SCANCODE_F8] = SDLK_F8; | 284 keymap[SCANCODE_F4] = SDLK_F4; |
283 keymap[SCANCODE_F9] = SDLK_F9; | 285 keymap[SCANCODE_F5] = SDLK_F5; |
284 keymap[SCANCODE_F10] = SDLK_F10; | 286 keymap[SCANCODE_F6] = SDLK_F6; |
285 keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK; | 287 keymap[SCANCODE_F7] = SDLK_F7; |
286 keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK; | 288 keymap[SCANCODE_F8] = SDLK_F8; |
287 keymap[SCANCODE_KEYPAD7] = SDLK_KP7; | 289 keymap[SCANCODE_F9] = SDLK_F9; |
288 keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7; | 290 keymap[SCANCODE_F10] = SDLK_F10; |
289 keymap[SCANCODE_KEYPAD8] = SDLK_KP8; | 291 keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK; |
290 keymap[SCANCODE_CURSORUP] = SDLK_KP8; | 292 keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK; |
291 keymap[SCANCODE_KEYPAD9] = SDLK_KP9; | 293 keymap[SCANCODE_KEYPAD7] = SDLK_KP7; |
292 keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9; | 294 keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7; |
293 keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS; | 295 keymap[SCANCODE_KEYPAD8] = SDLK_KP8; |
294 keymap[SCANCODE_KEYPAD4] = SDLK_KP4; | 296 keymap[SCANCODE_CURSORUP] = SDLK_KP8; |
295 keymap[SCANCODE_CURSORLEFT] = SDLK_KP4; | 297 keymap[SCANCODE_KEYPAD9] = SDLK_KP9; |
296 keymap[SCANCODE_KEYPAD5] = SDLK_KP5; | 298 keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9; |
297 keymap[SCANCODE_KEYPAD6] = SDLK_KP6; | 299 keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS; |
298 keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6; | 300 keymap[SCANCODE_KEYPAD4] = SDLK_KP4; |
299 keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS; | 301 keymap[SCANCODE_CURSORLEFT] = SDLK_KP4; |
300 keymap[SCANCODE_KEYPAD1] = SDLK_KP1; | 302 keymap[SCANCODE_KEYPAD5] = SDLK_KP5; |
301 keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1; | 303 keymap[SCANCODE_KEYPAD6] = SDLK_KP6; |
302 keymap[SCANCODE_KEYPAD2] = SDLK_KP2; | 304 keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6; |
303 keymap[SCANCODE_CURSORDOWN] = SDLK_KP2; | 305 keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS; |
304 keymap[SCANCODE_KEYPAD3] = SDLK_KP3; | 306 keymap[SCANCODE_KEYPAD1] = SDLK_KP1; |
305 keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3; | 307 keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1; |
306 keymap[SCANCODE_KEYPAD0] = SDLK_KP0; | 308 keymap[SCANCODE_KEYPAD2] = SDLK_KP2; |
307 keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD; | 309 keymap[SCANCODE_CURSORDOWN] = SDLK_KP2; |
308 keymap[SCANCODE_LESS] = SDLK_LESS; | 310 keymap[SCANCODE_KEYPAD3] = SDLK_KP3; |
309 keymap[SCANCODE_F11] = SDLK_F11; | 311 keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3; |
310 keymap[SCANCODE_F12] = SDLK_F12; | 312 keymap[SCANCODE_KEYPAD0] = SDLK_KP0; |
311 keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER; | 313 keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD; |
312 keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL; | 314 keymap[SCANCODE_LESS] = SDLK_LESS; |
313 keymap[SCANCODE_CONTROL] = SDLK_RCTRL; | 315 keymap[SCANCODE_F11] = SDLK_F11; |
314 keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE; | 316 keymap[SCANCODE_F12] = SDLK_F12; |
315 keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT; | 317 keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER; |
316 keymap[SCANCODE_RIGHTALT] = SDLK_RALT; | 318 keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL; |
317 keymap[SCANCODE_BREAK] = SDLK_BREAK; | 319 keymap[SCANCODE_CONTROL] = SDLK_RCTRL; |
318 keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN; | 320 keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE; |
319 keymap[SCANCODE_HOME] = SDLK_HOME; | 321 keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT; |
320 keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP; | 322 keymap[SCANCODE_RIGHTALT] = SDLK_RALT; |
321 keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP; | 323 keymap[SCANCODE_BREAK] = SDLK_BREAK; |
322 keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT; | 324 keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN; |
323 keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT; | 325 keymap[SCANCODE_HOME] = SDLK_HOME; |
324 keymap[SCANCODE_END] = SDLK_END; | 326 keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP; |
325 keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN; | 327 keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP; |
326 keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN; | 328 keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT; |
327 keymap[SCANCODE_INSERT] = SDLK_INSERT; | 329 keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT; |
328 keymap[SCANCODE_REMOVE] = SDLK_DELETE; | 330 keymap[SCANCODE_END] = SDLK_END; |
329 keymap[119] = SDLK_PAUSE; | 331 keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN; |
330 keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER; | 332 keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN; |
331 keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER; | 333 keymap[SCANCODE_INSERT] = SDLK_INSERT; |
332 keymap[127] = SDLK_MENU; | 334 keymap[SCANCODE_REMOVE] = SDLK_DELETE; |
335 keymap[119] = SDLK_PAUSE; | |
336 keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER; | |
337 keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER; | |
338 keymap[127] = SDLK_MENU; | |
333 } | 339 } |
334 | 340 |
335 #if defined(linux) | 341 #if defined(linux) |
336 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) | 342 static SDL_keysym * |
337 { | 343 TranslateKey(int scancode, SDL_keysym * keysym) |
338 /* Set the keysym information */ | 344 { |
339 keysym->scancode = scancode; | 345 /* Set the keysym information */ |
340 keysym->sym = keymap[scancode]; | 346 keysym->scancode = scancode; |
341 keysym->mod = KMOD_NONE; | 347 keysym->sym = keymap[scancode]; |
342 | 348 keysym->mod = KMOD_NONE; |
343 /* If UNICODE is on, get the UNICODE value for the key */ | 349 |
344 keysym->unicode = 0; | 350 /* If UNICODE is on, get the UNICODE value for the key */ |
345 if ( SDL_TranslateUNICODE ) { | 351 keysym->unicode = 0; |
346 int map; | 352 if (SDL_TranslateUNICODE) { |
347 SDLMod modstate; | 353 int map; |
348 | 354 SDLMod modstate; |
349 modstate = SDL_GetModState(); | 355 |
350 map = 0; | 356 modstate = SDL_GetModState(); |
351 if ( modstate & KMOD_SHIFT ) { | 357 map = 0; |
352 map |= (1<<KG_SHIFT); | 358 if (modstate & KMOD_SHIFT) { |
353 } | 359 map |= (1 << KG_SHIFT); |
354 if ( modstate & KMOD_CTRL ) { | 360 } |
355 map |= (1<<KG_CTRL); | 361 if (modstate & KMOD_CTRL) { |
356 } | 362 map |= (1 << KG_CTRL); |
357 if ( modstate & KMOD_ALT ) { | 363 } |
358 map |= (1<<KG_ALT); | 364 if (modstate & KMOD_ALT) { |
359 } | 365 map |= (1 << KG_ALT); |
360 if ( modstate & KMOD_MODE ) { | 366 } |
361 map |= (1<<KG_ALTGR); | 367 if (modstate & KMOD_MODE) { |
362 } | 368 map |= (1 << KG_ALTGR); |
363 if ( KTYP(vga_keymap[map][scancode]) == KT_LETTER ) { | 369 } |
364 if ( modstate & KMOD_CAPS ) { | 370 if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) { |
365 map ^= (1<<KG_SHIFT); | 371 if (modstate & KMOD_CAPS) { |
366 } | 372 map ^= (1 << KG_SHIFT); |
367 } | 373 } |
368 if ( KTYP(vga_keymap[map][scancode]) == KT_PAD ) { | 374 } |
369 if ( modstate & KMOD_NUM ) { | 375 if (KTYP(vga_keymap[map][scancode]) == KT_PAD) { |
370 keysym->unicode=KVAL(vga_keymap[map][scancode]); | 376 if (modstate & KMOD_NUM) { |
371 } | 377 keysym->unicode = KVAL(vga_keymap[map][scancode]); |
372 } else { | 378 } |
373 keysym->unicode = KVAL(vga_keymap[map][scancode]); | 379 } else { |
374 } | 380 keysym->unicode = KVAL(vga_keymap[map][scancode]); |
375 } | 381 } |
376 return(keysym); | 382 } |
383 return (keysym); | |
377 } | 384 } |
378 #elif defined(__FREEBSD__) | 385 #elif defined(__FREEBSD__) |
379 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym) | 386 static SDL_keysym * |
380 { | 387 TranslateKey(int scancode, SDL_keysym * keysym) |
381 /* Set the keysym information */ | 388 { |
382 keysym->scancode = scancode; | 389 /* Set the keysym information */ |
383 keysym->sym = keymap[scancode]; | 390 keysym->scancode = scancode; |
384 keysym->mod = KMOD_NONE; | 391 keysym->sym = keymap[scancode]; |
385 | 392 keysym->mod = KMOD_NONE; |
386 /* If UNICODE is on, get the UNICODE value for the key */ | 393 |
387 keysym->unicode = 0; | 394 /* If UNICODE is on, get the UNICODE value for the key */ |
388 if ( SDL_TranslateUNICODE && vga_keymap ) { | 395 keysym->unicode = 0; |
389 int map; | 396 if (SDL_TranslateUNICODE && vga_keymap) { |
390 SDLMod modstate; | 397 int map; |
391 | 398 SDLMod modstate; |
392 modstate = SDL_GetModState(); | 399 |
393 map = 0; | 400 modstate = SDL_GetModState(); |
394 if ( modstate & KMOD_SHIFT ) { | 401 map = 0; |
395 map += 1; | 402 if (modstate & KMOD_SHIFT) { |
396 } | 403 map += 1; |
397 if ( modstate & KMOD_CTRL ) { | 404 } |
398 map += 2; | 405 if (modstate & KMOD_CTRL) { |
399 } | 406 map += 2; |
400 if ( modstate & KMOD_ALT ) { | 407 } |
401 map += 4; | 408 if (modstate & KMOD_ALT) { |
402 } | 409 map += 4; |
403 if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) { | 410 } |
404 keysym->unicode = vga_keymap->key[scancode].map[map]; | 411 if (!(vga_keymap->key[scancode].spcl & (0x80 >> map))) { |
405 } | 412 keysym->unicode = vga_keymap->key[scancode].map[map]; |
406 | 413 } |
407 } | 414 |
408 return(keysym); | 415 } |
416 return (keysym); | |
409 } | 417 } |
410 #else | 418 #else |
411 #error You must choose your operating system here | 419 #error You must choose your operating system here |
412 #endif | 420 #endif |
421 /* vi: set ts=4 sw=4 expandtab: */ |