comparison src/video/ataricommon/SDL_biosevents.c @ 1209:a55ac374271c

Added preliminary missingtranslation from Atari to Unicode charset
author Patrice Mandin <patmandin@gmail.com>
date Sun, 01 Jan 2006 19:14:11 +0000
parents b8d311d90021
children 8ef3e7e92a91
comparison
equal deleted inserted replaced
1208:d90b362628ea 1209:a55ac374271c
39 #include "SDL.h" 39 #include "SDL.h"
40 #include "SDL_sysevents.h" 40 #include "SDL_sysevents.h"
41 #include "SDL_events_c.h" 41 #include "SDL_events_c.h"
42 42
43 #include "SDL_atarikeys.h" 43 #include "SDL_atarikeys.h"
44 #include "SDL_atarievents_c.h"
44 #include "SDL_xbiosevents_c.h" 45 #include "SDL_xbiosevents_c.h"
45 46
46 /* To save state of keyboard */ 47 /* To save state of keyboard */
47 #define ATARIBIOS_MAXKEYS 128 48 #define ATARIBIOS_MAXKEYS 128
48 49
62 }; 63 };
63 64
64 /* The translation tables from a console scancode to a SDL keysym */ 65 /* The translation tables from a console scancode to a SDL keysym */
65 static SDLKey keymap[ATARIBIOS_MAXKEYS]; 66 static SDLKey keymap[ATARIBIOS_MAXKEYS];
66 67
67 static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym); 68 static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
69 SDL_bool pressed);
68 static void UpdateSpecialKeys(int special_keys_state); 70 static void UpdateSpecialKeys(int special_keys_state);
69 71
70 void AtariBios_InitOSKeymap(_THIS) 72 void AtariBios_InitOSKeymap(_THIS)
71 { 73 {
72 int i; 74 int i;
133 135
134 /* Now generate events */ 136 /* Now generate events */
135 for (i=0; i<ATARIBIOS_MAXKEYS; i++) { 137 for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
136 /* Key pressed ? */ 138 /* Key pressed ? */
137 if (bios_currentkeyboard[i] && !bios_previouskeyboard[i]) 139 if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
138 SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, bios_currentascii[i], &keysym)); 140 SDL_PrivateKeyboard(SDL_PRESSED,
141 TranslateKey(i, bios_currentascii[i], &keysym, SDL_TRUE));
139 142
140 /* Key unpressed ? */ 143 /* Key unpressed ? */
141 if (bios_previouskeyboard[i] && !bios_currentkeyboard[i]) 144 if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
142 SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, bios_currentascii[i], &keysym)); 145 SDL_PrivateKeyboard(SDL_RELEASED,
146 TranslateKey(i, bios_currentascii[i], &keysym, SDL_FALSE));
143 } 147 }
144 148
145 SDL_AtariXbios_PostMouseEvents(this); 149 SDL_AtariXbios_PostMouseEvents(this);
146 150
147 /* Will be previous table */ 151 /* Will be previous table */
163 UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL); 167 UPDATE_SPECIAL_KEYS(K_CTRL, SCANCODE_LEFTCONTROL);
164 UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT); 168 UPDATE_SPECIAL_KEYS(K_ALT, SCANCODE_LEFTALT);
165 UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK); 169 UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
166 } 170 }
167 171
168 static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym) 172 static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
173 SDL_bool pressed)
169 { 174 {
170 /* Set the keysym information */ 175 /* Set the keysym information */
171 keysym->scancode = scancode; 176 keysym->scancode = scancode;
172 177
173 if (asciicode) 178 if (asciicode)
175 else 180 else
176 keysym->sym = keymap[scancode]; 181 keysym->sym = keymap[scancode];
177 182
178 keysym->mod = KMOD_NONE; 183 keysym->mod = KMOD_NONE;
179 keysym->unicode = 0; 184 keysym->unicode = 0;
185 if (pressed && (asciicode!=0)) {
186 keysym->unicode = SDL_AtariToUnicode(asciicode);
187 }
180 188
181 return(keysym); 189 return(keysym);
182 } 190 }
183 191
184 void AtariBios_ShutdownEvents(void) 192 void AtariBios_ShutdownEvents(void)