comparison src/video/ataricommon/SDL_atarievents.c @ 2030:d774e9d7c2a8

Forward keyboard reworking from 1.2
author Patrice Mandin <patmandin@gmail.com>
date Wed, 20 Sep 2006 19:47:09 +0000
parents c121d94672cb
children ddf89133aebc
comparison
equal deleted inserted replaced
2029:8640d90b0406 2030:d774e9d7c2a8
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
46 MCH_TT, 49 MCH_TT,
47 MCH_F30, 50 MCH_F30,
48 MCH_CLONE, 51 MCH_CLONE,
49 MCH_ARANYM 52 MCH_ARANYM
50 }; 53 };
54
55 #ifndef KT_NOCHANGE
56 # define KT_NOCHANGE -1
57 #endif
58
59 /* The translation tables from a console scancode to a SDL keysym */
60 static SDLKey keymap[ATARIBIOS_MAXKEYS];
61 static unsigned char *keytab_normal;
51 62
52 void (*Atari_ShutdownEvents) (void); 63 void (*Atari_ShutdownEvents) (void);
53 64
54 static void 65 static void
55 Atari_InitializeEvents(_THIS) 66 Atari_InitializeEvents(_THIS)
109 void 120 void
110 Atari_InitOSKeymap(_THIS) 121 Atari_InitOSKeymap(_THIS)
111 { 122 {
112 Atari_InitializeEvents(this); 123 Atari_InitializeEvents(this);
113 124
125 SDL_Atari_InitInternalKeymap(this);
126
114 /* Call choosen routine */ 127 /* Call choosen routine */
115 this->InitOSKeymap(this); 128 this->InitOSKeymap(this);
116 } 129 }
117 130
118 void 131 void
120 { 133 {
121 Atari_InitializeEvents(this); 134 Atari_InitializeEvents(this);
122 135
123 /* Call choosen routine */ 136 /* Call choosen routine */
124 this->PumpEvents(this); 137 this->PumpEvents(this);
138 }
139
140 void
141 SDL_Atari_InitInternalKeymap(_THIS)
142 {
143 int i;
144 _KEYTAB *key_tables;
145
146 /* Read system tables for scancode -> ascii translation */
147 key_tables = (_KEYTAB *) Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
148 keytab_normal = key_tables->unshift;
149
150 /* Initialize keymap */
151 for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
152 keymap[i] = SDLK_UNKNOWN;
153
154 /* Functions keys */
155 for ( i = 0; i<10; i++ )
156 keymap[SCANCODE_F1 + i] = SDLK_F1+i;
157
158 /* Cursor keypad */
159 keymap[SCANCODE_HELP] = SDLK_HELP;
160 keymap[SCANCODE_UNDO] = SDLK_UNDO;
161 keymap[SCANCODE_INSERT] = SDLK_INSERT;
162 keymap[SCANCODE_CLRHOME] = SDLK_HOME;
163 keymap[SCANCODE_UP] = SDLK_UP;
164 keymap[SCANCODE_DOWN] = SDLK_DOWN;
165 keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
166 keymap[SCANCODE_LEFT] = SDLK_LEFT;
167
168 /* Special keys */
169 keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
170 keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
171 keymap[SCANCODE_TAB] = SDLK_TAB;
172 keymap[SCANCODE_ENTER] = SDLK_RETURN;
173 keymap[SCANCODE_DELETE] = SDLK_DELETE;
174 keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
175 keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
176 keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
177 keymap[SCANCODE_LEFTALT] = SDLK_LALT;
178 keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
125 } 179 }
126 180
127 /* Atari to Unicode charset translation table */ 181 /* Atari to Unicode charset translation table */
128 182
129 Uint16 SDL_AtariToUnicodeTable[256] = { 183 Uint16 SDL_AtariToUnicodeTable[256] = {
165 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x222E, 0x03C6, 0x2208, 0x2229, 219 0x03A6, 0x0398, 0x03A9, 0x03B4, 0x222E, 0x03C6, 0x2208, 0x2229,
166 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248, 220 0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
167 0x00B0, 0x2022, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x00B3, 0x00AF 221 0x00B0, 0x2022, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x00B3, 0x00AF
168 }; 222 };
169 223
224 SDL_keysym *
225 SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
226 SDL_bool pressed)
227 {
228 int asciicode = 0;
229
230 /* Set the keysym information */
231 keysym->scancode = scancode;
232 keysym->mod = KMOD_NONE;
233 keysym->sym = keymap[scancode];
234 keysym->unicode = 0;
235
236 if (keysym->sym == SDLK_UNKNOWN) {
237 keysym->sym = asciicode = keytab_normal[scancode];
238 }
239
240 if (SDL_TranslateUNICODE && pressed) {
241 keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
242 }
243
244 return(keysym);
245 }
246
170 /* vi: set ts=4 sw=4 expandtab: */ 247 /* vi: set ts=4 sw=4 expandtab: */