Factorize keyboard mapping between drivers SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Wed, 13 Sep 2006 21:18:35 +0000
branchSDL-1.2
changeset 3860 bf1586b58ef2
parent 3859 5d14acfdf84d
child 3861 c3625a895caf
Factorize keyboard mapping between drivers
src/video/ataricommon/SDL_atarievents.c
src/video/ataricommon/SDL_atarievents_c.h
src/video/ataricommon/SDL_biosevents.c
src/video/ataricommon/SDL_gemdosevents.c
src/video/ataricommon/SDL_ikbdevents.c
--- a/src/video/ataricommon/SDL_atarievents.c	Tue Sep 12 19:34:18 2006 +0000
+++ b/src/video/ataricommon/SDL_atarievents.c	Wed Sep 13 21:18:35 2006 +0000
@@ -30,10 +30,13 @@
  */
 
 #include <mint/cookie.h>
+#include <mint/ostruct.h>
+#include <mint/osbind.h>
 
 #include "../../events/SDL_sysevents.h"
 #include "../../events/SDL_events_c.h"
 
+#include "SDL_atarikeys.h"
 #include "SDL_atarievents_c.h"
 #include "SDL_biosevents_c.h"
 #include "SDL_gemdosevents_c.h"
@@ -48,6 +51,14 @@
 	MCH_ARANYM
 };
 
+#ifndef KT_NOCHANGE
+# define KT_NOCHANGE -1
+#endif
+
+/* The translation tables from a console scancode to a SDL keysym */
+static SDLKey keymap[ATARIBIOS_MAXKEYS];
+static unsigned char *keytab_normal;
+
 void (*Atari_ShutdownEvents)(void);
 
 static void Atari_InitializeEvents(_THIS)
@@ -108,10 +119,52 @@
 {
 	Atari_InitializeEvents(this);
 
+	SDL_Atari_InitInternalKeymap(this);
+
 	/* Call choosen routine */
 	this->InitOSKeymap(this);
 }
 
+void SDL_Atari_InitInternalKeymap(_THIS)
+{
+	int i;
+	_KEYTAB *key_tables;
+
+	/* Read system tables for scancode -> ascii translation */
+	key_tables = (_KEYTAB *) Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
+	keytab_normal = key_tables->unshift;
+
+	/* Initialize keymap */
+	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
+		keymap[i] = SDLK_UNKNOWN;
+
+	/* Functions keys */
+	for ( i = 0; i<10; i++ )
+		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
+
+	/* Cursor keypad */
+	keymap[SCANCODE_HELP] = SDLK_HELP;
+	keymap[SCANCODE_UNDO] = SDLK_UNDO;
+	keymap[SCANCODE_INSERT] = SDLK_INSERT;
+	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
+	keymap[SCANCODE_UP] = SDLK_UP;
+	keymap[SCANCODE_DOWN] = SDLK_DOWN;
+	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
+	keymap[SCANCODE_LEFT] = SDLK_LEFT;
+
+	/* Special keys */
+	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+	keymap[SCANCODE_TAB] = SDLK_TAB;
+	keymap[SCANCODE_ENTER] = SDLK_RETURN;
+	keymap[SCANCODE_DELETE] = SDLK_DELETE;
+	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+}
+
 void Atari_PumpEvents(_THIS)
 {
 	Atari_InitializeEvents(this);
@@ -162,3 +215,25 @@
 	0x2261,0x00B1,0x2265,0x2264,0x2320,0x2321,0x00F7,0x2248,
 	0x00B0,0x2022,0x00B7,0x221A,0x207F,0x00B2,0x00B3,0x00AF
 };
+
+SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
+	SDL_bool pressed)
+{
+	int asciicode = 0;
+
+	/* Set the keysym information */
+	keysym->scancode = scancode;
+	keysym->mod = KMOD_NONE;
+	keysym->sym = keymap[scancode];
+	keysym->unicode = 0;
+
+	if (keysym->sym == SDLK_UNKNOWN) {
+		keysym->sym = asciicode = keytab_normal[scancode];		
+	}
+
+	if (SDL_TranslateUNICODE && pressed) {
+		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
+	}
+
+	return(keysym);
+}
--- a/src/video/ataricommon/SDL_atarievents_c.h	Tue Sep 12 19:34:18 2006 +0000
+++ b/src/video/ataricommon/SDL_atarievents_c.h	Wed Sep 13 21:18:35 2006 +0000
@@ -35,12 +35,31 @@
 /* Hidden "this" pointer for the video functions */
 #define _THIS	SDL_VideoDevice *this
 
+#define ATARIBIOS_MAXKEYS 128
+
+/* Special keys state */
+#ifndef K_RSHIFT
+enum {
+	K_RSHIFT=0,
+	K_LSHIFT,
+	K_CTRL,
+	K_ALT,
+	K_CAPSLOCK,
+	K_CLRHOME,
+	K_INSERT
+};
+#endif
+
 extern void (*Atari_ShutdownEvents)(void);
 
 extern void Atari_InitOSKeymap(_THIS);
 extern void Atari_PumpEvents(_THIS);
 
+extern void SDL_Atari_InitInternalKeymap(_THIS);
+
 /* Atari to Unicode charset translation table */
 extern Uint16 SDL_AtariToUnicodeTable[256];
+SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
+	SDL_bool pressed);
 
 #endif /* _SDL_ATARI_EVENTS_H_ */
--- a/src/video/ataricommon/SDL_biosevents.c	Tue Sep 12 19:34:18 2006 +0000
+++ b/src/video/ataricommon/SDL_biosevents.c	Wed Sep 13 21:18:35 2006 +0000
@@ -39,30 +39,10 @@
 #include "SDL_xbiosevents_c.h"
 #include "SDL_ataridevmouse_c.h"
 
-/* To save state of keyboard */
-#define ATARIBIOS_MAXKEYS 128
-
 static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS];
 static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS];
-static unsigned char bios_currentascii[ATARIBIOS_MAXKEYS];
 static SDL_bool use_dev_mouse = SDL_FALSE;
 
-/* Special keys state */
-enum {
-	K_RSHIFT=0,
-	K_LSHIFT,
-	K_CTRL,
-	K_ALT,
-	K_CAPSLOCK,
-	K_CLRHOME,
-	K_INSERT
-};
-
-/* The translation tables from a console scancode to a SDL keysym */
-static SDLKey keymap[ATARIBIOS_MAXKEYS];
-
-static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
-	SDL_bool pressed);
 static void UpdateSpecialKeys(int special_keys_state);
 
 void AtariBios_InitOSKeymap(_THIS)
@@ -73,45 +53,15 @@
 	SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
 	SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
 
-	/* Initialize keymap */
-	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
-		keymap[i] = SDLK_UNKNOWN;
-
-	/* Functions keys */
-	for ( i = 0; i<10; i++ )
-		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
-
-	/* Cursor keypad */
-	keymap[SCANCODE_HELP] = SDLK_HELP;
-	keymap[SCANCODE_UNDO] = SDLK_UNDO;
-	keymap[SCANCODE_INSERT] = SDLK_INSERT;
-	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
-	keymap[SCANCODE_UP] = SDLK_UP;
-	keymap[SCANCODE_DOWN] = SDLK_DOWN;
-	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
-	keymap[SCANCODE_LEFT] = SDLK_LEFT;
-
-	/* Special keys */
-	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
-	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
-	keymap[SCANCODE_TAB] = SDLK_TAB;
-	keymap[SCANCODE_ENTER] = SDLK_RETURN;
-	keymap[SCANCODE_DELETE] = SDLK_DELETE;
-	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
-	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
-	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
-	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
-	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
-
 	use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
 
 	vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;	/* XBIOS joystick events */
 	if (!use_dev_mouse) {
 		vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;	/* XBIOS mouse events */
 	}
-	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
+/*	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
 		vectors_mask = 0;
-	}
+	}*/
 
 	SDL_AtariXbios_InstallVectors(vectors_mask);
 }
@@ -126,15 +76,8 @@
 
 	while (Bconstat(_CON)) {
 		unsigned long key_pressed;
-		unsigned char asciicode, scancode;
-
 		key_pressed=Bconin(_CON);
-
-		asciicode = key_pressed;
-		scancode = key_pressed >> 16;
-
-		bios_currentkeyboard[scancode]=0xFF;
-		bios_currentascii[scancode]=asciicode;
+		bios_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
 	}
 
 	/* Read special keys */
@@ -145,12 +88,12 @@
 		/* Key pressed ? */
 		if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
 			SDL_PrivateKeyboard(SDL_PRESSED,
-				TranslateKey(i, bios_currentascii[i], &keysym, SDL_TRUE));
+				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
 			
 		/* Key unpressed ? */
 		if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
 			SDL_PrivateKeyboard(SDL_RELEASED,
-				TranslateKey(i, bios_currentascii[i], &keysym, SDL_FALSE));
+				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
 	}
 
 	if (use_dev_mouse) {
@@ -160,7 +103,7 @@
 	}
 
 	/* Will be previous table */
-	SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, ATARIBIOS_MAXKEYS);
+	SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, sizeof(bios_previouskeyboard));
 }
 
 static void UpdateSpecialKeys(int special_keys_state)
@@ -169,7 +112,6 @@
 	{	\
 		if (special_keys_state & (1<<(numbit))) { \
 			bios_currentkeyboard[scancode]=0xFF; \
-			bios_currentascii[scancode]=0; \
 		}	\
 	}
 
@@ -180,26 +122,6 @@
 	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
 }
 
-static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
-	SDL_bool pressed)
-{
-	/* Set the keysym information */
-	keysym->scancode = scancode;
-
-	if (asciicode)
-		keysym->sym = asciicode;		
-	else
-		keysym->sym = keymap[scancode];
-
-	keysym->mod = KMOD_NONE;
-	keysym->unicode = 0;
-	if (SDL_TranslateUNICODE && pressed) {
-		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
-	}
-
-	return(keysym);
-}
-
 void AtariBios_ShutdownEvents(void)
 {
 	SDL_AtariXbios_RestoreVectors();
--- a/src/video/ataricommon/SDL_gemdosevents.c	Tue Sep 12 19:34:18 2006 +0000
+++ b/src/video/ataricommon/SDL_gemdosevents.c	Wed Sep 13 21:18:35 2006 +0000
@@ -40,34 +40,16 @@
 #include "SDL_ataridevmouse_c.h"
 
 /* To save state of keyboard */
-#define ATARIBIOS_MAXKEYS 128
 
 static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS];
 static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS];
-static unsigned char gemdos_currentascii[ATARIBIOS_MAXKEYS];
 static SDL_bool use_dev_mouse = SDL_FALSE;
 
-/* Special keys state */
-enum {
-	K_RSHIFT=0,
-	K_LSHIFT,
-	K_CTRL,
-	K_ALT,
-	K_CAPSLOCK,
-	K_CLRHOME,
-	K_INSERT
-};
-
 enum {
 	DEV_BUSY=0,
 	DEV_READY
 };
 
-/* The translation tables from a console scancode to a SDL keysym */
-static SDLKey keymap[ATARIBIOS_MAXKEYS];
-
-static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
-	SDL_bool pressed);
 static void UpdateSpecialKeys(int special_keys_state);
 
 void AtariGemdos_InitOSKeymap(_THIS)
@@ -78,45 +60,15 @@
 	SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
 	SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
 
-	/* Initialize keymap */
-	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
-		keymap[i] = SDLK_UNKNOWN;
-
-	/* Functions keys */
-	for ( i = 0; i<10; i++ )
-		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
-
-	/* Cursor keypad */
-	keymap[SCANCODE_HELP] = SDLK_HELP;
-	keymap[SCANCODE_UNDO] = SDLK_UNDO;
-	keymap[SCANCODE_INSERT] = SDLK_INSERT;
-	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
-	keymap[SCANCODE_UP] = SDLK_UP;
-	keymap[SCANCODE_DOWN] = SDLK_DOWN;
-	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
-	keymap[SCANCODE_LEFT] = SDLK_LEFT;
-
-	/* Special keys */
-	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
-	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
-	keymap[SCANCODE_TAB] = SDLK_TAB;
-	keymap[SCANCODE_ENTER] = SDLK_RETURN;
-	keymap[SCANCODE_DELETE] = SDLK_DELETE;
-	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
-	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
-	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
-	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
-	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
-
 	use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
 
 	vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;	/* XBIOS joystick events */
 	if (!use_dev_mouse) {
 		vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;	/* XBIOS mouse events */
 	}
-	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
+/*	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
 		vectors_mask = 0;
-	}
+	}*/
 	SDL_AtariXbios_InstallVectors(vectors_mask);
 }
 
@@ -130,15 +82,8 @@
 
 	while (Cconis()!=DEV_BUSY) {
 		unsigned long key_pressed;
-		unsigned char scancode, asciicode;
-
 		key_pressed=Cnecin();
-
-		asciicode = key_pressed;
-		scancode = key_pressed >> 16;
-
-		gemdos_currentkeyboard[scancode]=0xFF;
-		gemdos_currentascii[scancode]=asciicode;
+		gemdos_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
 	}
 
 	/* Read special keys */
@@ -149,12 +94,12 @@
 		/* Key pressed ? */
 		if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
 			SDL_PrivateKeyboard(SDL_PRESSED,
-				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_TRUE));
+				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
 			
 		/* Key unpressed ? */
 		if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
 			SDL_PrivateKeyboard(SDL_RELEASED,
-				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_FALSE));
+				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
 	}
 
 	if (use_dev_mouse) {
@@ -164,7 +109,7 @@
 	}
 
 	/* Will be previous table */
-	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
+	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, sizeof(gemdos_previouskeyboard));
 }
 
 static void UpdateSpecialKeys(int special_keys_state)
@@ -173,7 +118,6 @@
 	{	\
 		if (special_keys_state & (1<<(numbit))) { \
 			gemdos_currentkeyboard[scancode]=0xFF; \
-			gemdos_currentascii[scancode]=0; \
 		}	\
 	}
 
@@ -184,26 +128,6 @@
 	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
 }
 
-static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
-	SDL_bool pressed)
-{
-	/* Set the keysym information */
-	keysym->scancode = scancode;
-
-	if (asciicode)
-		keysym->sym = asciicode;		
-	else
-		keysym->sym = keymap[scancode];
-
-	keysym->mod = KMOD_NONE;
-	keysym->unicode = 0;
-	if (SDL_TranslateUNICODE && pressed) {
-		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
-	}
-
-	return(keysym);
-}
-
 void AtariGemdos_ShutdownEvents(void)
 {
 	SDL_AtariXbios_RestoreVectors();
--- a/src/video/ataricommon/SDL_ikbdevents.c	Tue Sep 12 19:34:18 2006 +0000
+++ b/src/video/ataricommon/SDL_ikbdevents.c	Wed Sep 13 21:18:35 2006 +0000
@@ -37,85 +37,17 @@
 #include "SDL_atarievents_c.h"
 #include "SDL_ikbdinterrupt_s.h"
 
-/* Special keys state */
-enum {
-	K_RSHIFT=0,
-	K_LSHIFT,
-	K_CTRL,
-	K_ALT,
-	K_CAPSLOCK,
-	K_CLRHOME,
-	K_INSERT
-};
-
-#define ATARIBIOS_MAXKEYS 128
-
 #define KEY_PRESSED		0xff
 #define KEY_UNDEFINED	0x80
 #define KEY_RELEASED	0x00
 
-/* The translation tables from a console scancode to a SDL keysym */
-#define KT_NOCHANGE -1
-
-enum {
-	KT_UNSHIFT=0,
-	KT_SHIFT=1,
-	KT_CAPS=2
-};
-
 static Uint16 atari_prevmouseb;	/* save state of mouse buttons */
-static int caps_state;			/* caps lock state */
-_KEYTAB *curtables;
-static unsigned char *tab_unshift, *tab_shift, *tab_caps;
-static SDLKey keymap[ATARIBIOS_MAXKEYS];
-
-static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym,
-	SDL_bool pressed);
 
 void AtariIkbd_InitOSKeymap(_THIS)
 {
 	int i;
 
-	SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS);
-
-	/* Initialize keymap */
-	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
-		keymap[i] = SDLK_UNKNOWN;
-
-	/* Functions keys */
-	for ( i = 0; i<10; i++ )
-		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
-
-	/* Cursor keypad */
-	keymap[SCANCODE_HELP] = SDLK_HELP;
-	keymap[SCANCODE_UNDO] = SDLK_UNDO;
-	keymap[SCANCODE_INSERT] = SDLK_INSERT;
-	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
-	keymap[SCANCODE_UP] = SDLK_UP;
-	keymap[SCANCODE_DOWN] = SDLK_DOWN;
-	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
-	keymap[SCANCODE_LEFT] = SDLK_LEFT;
-
-	/* Special keys */
-	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
-	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
-	keymap[SCANCODE_TAB] = SDLK_TAB;
-	keymap[SCANCODE_ENTER] = SDLK_RETURN;
-	keymap[SCANCODE_DELETE] = SDLK_DELETE;
-	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
-	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
-	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
-	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
-	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
-
-	/* Read XBIOS tables for scancode -> ascii translation */
-	curtables=Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
-	tab_unshift=curtables->unshift;
-	tab_shift=curtables->shift;
-	tab_caps=curtables->caps;
-
-	/* Set Caps lock initial state */
-	caps_state=(Kbshift(-1) & (1<<K_CAPSLOCK));
+	SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, sizeof(SDL_AtariIkbd_keyboard));
 
 	/* Now install our handler */
 	SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
@@ -140,41 +72,23 @@
 
 void AtariIkbd_PumpEvents(_THIS)
 {
-	int i;
+	int i, specialkeys;
 	SDL_keysym keysym;
-	int specialkeys;
 
 	/*--- Send keyboard events ---*/
 
-	/* Update caps lock state */
-	if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK]==KEY_PRESSED) {
-		caps_state ^= 1;
-	}
-
-	/* Choose the translation table */
-	specialkeys=KT_UNSHIFT;
-	if ((SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT]==KEY_PRESSED)
-		|| (SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT]==KEY_PRESSED))
-	{
-		specialkeys = KT_SHIFT;
-	}
-	if (caps_state) {
-		specialkeys = KT_CAPS;
-	}
-
-	/* Now generate events */
 	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
 		/* Key pressed ? */
 		if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
 			SDL_PrivateKeyboard(SDL_PRESSED,
-				TranslateKey(i, specialkeys, &keysym, SDL_TRUE));
+				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
 			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
 		}
 			
 		/* Key released ? */
 		if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
 			SDL_PrivateKeyboard(SDL_RELEASED,
-				TranslateKey(i, specialkeys, &keysym, SDL_FALSE));
+				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
 			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
 		}
 	}
@@ -206,41 +120,6 @@
 	}
 }
 
-static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym,
-	SDL_bool pressed)
-{
-	unsigned char asciicode;
-
-	/* Set the keysym information */
-	keysym->scancode = scancode;
-
-	asciicode=0;
-	switch(numkeytable) {
-		case KT_UNSHIFT:
-			asciicode=tab_unshift[scancode];
-			break;
-		case KT_SHIFT:
-			asciicode=tab_shift[scancode];
-			break;
-		case KT_CAPS:
-			asciicode=tab_caps[scancode];
-			break;
-	}
-
-	if (asciicode)
-		keysym->sym = asciicode;		
-	else
-		keysym->sym = keymap[scancode];
-
-	keysym->mod = KMOD_NONE;
-	keysym->unicode = 0;
-	if (SDL_TranslateUNICODE && pressed) {
-		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
-	}
-
-	return(keysym);
-}
-
 void AtariIkbd_ShutdownEvents(void)
 {
 	Supexec(SDL_AtariIkbdUninstall);