comparison src/video/ataricommon/SDL_atarievents.c @ 3860:bf1586b58ef2 SDL-1.2

Factorize keyboard mapping between drivers
author Patrice Mandin <patmandin@gmail.com>
date Wed, 13 Sep 2006 21:18:35 +0000
parents d910939febfa
children a1b03ba2fcd0
comparison
equal deleted inserted replaced
3859:5d14acfdf84d 3860:bf1586b58ef2
28 * 28 *
29 * This routines choose what the final event manager will be 29 * This routines choose what the final event manager will be
30 */ 30 */
31 31
32 #include <mint/cookie.h> 32 #include <mint/cookie.h>
33 #include <mint/ostruct.h>
34 #include <mint/osbind.h>
33 35
34 #include "../../events/SDL_sysevents.h" 36 #include "../../events/SDL_sysevents.h"
35 #include "../../events/SDL_events_c.h" 37 #include "../../events/SDL_events_c.h"
36 38
39 #include "SDL_atarikeys.h"
37 #include "SDL_atarievents_c.h" 40 #include "SDL_atarievents_c.h"
38 #include "SDL_biosevents_c.h" 41 #include "SDL_biosevents_c.h"
39 #include "SDL_gemdosevents_c.h" 42 #include "SDL_gemdosevents_c.h"
40 #include "SDL_ikbdevents_c.h" 43 #include "SDL_ikbdevents_c.h"
41 44
45 MCH_TT, 48 MCH_TT,
46 MCH_F30, 49 MCH_F30,
47 MCH_CLONE, 50 MCH_CLONE,
48 MCH_ARANYM 51 MCH_ARANYM
49 }; 52 };
53
54 #ifndef KT_NOCHANGE
55 # define KT_NOCHANGE -1
56 #endif
57
58 /* The translation tables from a console scancode to a SDL keysym */
59 static SDLKey keymap[ATARIBIOS_MAXKEYS];
60 static unsigned char *keytab_normal;
50 61
51 void (*Atari_ShutdownEvents)(void); 62 void (*Atari_ShutdownEvents)(void);
52 63
53 static void Atari_InitializeEvents(_THIS) 64 static void Atari_InitializeEvents(_THIS)
54 { 65 {
106 117
107 void Atari_InitOSKeymap(_THIS) 118 void Atari_InitOSKeymap(_THIS)
108 { 119 {
109 Atari_InitializeEvents(this); 120 Atari_InitializeEvents(this);
110 121
122 SDL_Atari_InitInternalKeymap(this);
123
111 /* Call choosen routine */ 124 /* Call choosen routine */
112 this->InitOSKeymap(this); 125 this->InitOSKeymap(this);
126 }
127
128 void SDL_Atari_InitInternalKeymap(_THIS)
129 {
130 int i;
131 _KEYTAB *key_tables;
132
133 /* Read system tables for scancode -> ascii translation */
134 key_tables = (_KEYTAB *) Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
135 keytab_normal = key_tables->unshift;
136
137 /* Initialize keymap */
138 for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
139 keymap[i] = SDLK_UNKNOWN;
140
141 /* Functions keys */
142 for ( i = 0; i<10; i++ )
143 keymap[SCANCODE_F1 + i] = SDLK_F1+i;
144
145 /* Cursor keypad */
146 keymap[SCANCODE_HELP] = SDLK_HELP;
147 keymap[SCANCODE_UNDO] = SDLK_UNDO;
148 keymap[SCANCODE_INSERT] = SDLK_INSERT;
149 keymap[SCANCODE_CLRHOME] = SDLK_HOME;
150 keymap[SCANCODE_UP] = SDLK_UP;
151 keymap[SCANCODE_DOWN] = SDLK_DOWN;
152 keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
153 keymap[SCANCODE_LEFT] = SDLK_LEFT;
154
155 /* Special keys */
156 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
157 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
158 keymap[SCANCODE_TAB] = SDLK_TAB;
159 keymap[SCANCODE_ENTER] = SDLK_RETURN;
160 keymap[SCANCODE_DELETE] = SDLK_DELETE;
161 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
162 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
163 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
164 keymap[SCANCODE_LEFTALT] = SDLK_LALT;
165 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
113 } 166 }
114 167
115 void Atari_PumpEvents(_THIS) 168 void Atari_PumpEvents(_THIS)
116 { 169 {
117 Atari_InitializeEvents(this); 170 Atari_InitializeEvents(this);
160 0x03B1,0x03B2,0x0393,0x03C0,0x03A3,0x03C3,0x00B5,0x03C4, 213 0x03B1,0x03B2,0x0393,0x03C0,0x03A3,0x03C3,0x00B5,0x03C4,
161 0x03A6,0x0398,0x03A9,0x03B4,0x222E,0x03C6,0x2208,0x2229, 214 0x03A6,0x0398,0x03A9,0x03B4,0x222E,0x03C6,0x2208,0x2229,
162 0x2261,0x00B1,0x2265,0x2264,0x2320,0x2321,0x00F7,0x2248, 215 0x2261,0x00B1,0x2265,0x2264,0x2320,0x2321,0x00F7,0x2248,
163 0x00B0,0x2022,0x00B7,0x221A,0x207F,0x00B2,0x00B3,0x00AF 216 0x00B0,0x2022,0x00B7,0x221A,0x207F,0x00B2,0x00B3,0x00AF
164 }; 217 };
218
219 SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
220 SDL_bool pressed)
221 {
222 int asciicode = 0;
223
224 /* Set the keysym information */
225 keysym->scancode = scancode;
226 keysym->mod = KMOD_NONE;
227 keysym->sym = keymap[scancode];
228 keysym->unicode = 0;
229
230 if (keysym->sym == SDLK_UNKNOWN) {
231 keysym->sym = asciicode = keytab_normal[scancode];
232 }
233
234 if (SDL_TranslateUNICODE && pressed) {
235 keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
236 }
237
238 return(keysym);
239 }