Factorize keyboard mapping between drivers SDL-1.2
authorPatrice Mandin
Wed, 13 Sep 2006 21:18:35 +0000
branchSDL-1.2
changeset 3860bf1586b58ef2
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
     1.1 --- a/src/video/ataricommon/SDL_atarievents.c	Tue Sep 12 19:34:18 2006 +0000
     1.2 +++ b/src/video/ataricommon/SDL_atarievents.c	Wed Sep 13 21:18:35 2006 +0000
     1.3 @@ -30,10 +30,13 @@
     1.4   */
     1.5  
     1.6  #include <mint/cookie.h>
     1.7 +#include <mint/ostruct.h>
     1.8 +#include <mint/osbind.h>
     1.9  
    1.10  #include "../../events/SDL_sysevents.h"
    1.11  #include "../../events/SDL_events_c.h"
    1.12  
    1.13 +#include "SDL_atarikeys.h"
    1.14  #include "SDL_atarievents_c.h"
    1.15  #include "SDL_biosevents_c.h"
    1.16  #include "SDL_gemdosevents_c.h"
    1.17 @@ -48,6 +51,14 @@
    1.18  	MCH_ARANYM
    1.19  };
    1.20  
    1.21 +#ifndef KT_NOCHANGE
    1.22 +# define KT_NOCHANGE -1
    1.23 +#endif
    1.24 +
    1.25 +/* The translation tables from a console scancode to a SDL keysym */
    1.26 +static SDLKey keymap[ATARIBIOS_MAXKEYS];
    1.27 +static unsigned char *keytab_normal;
    1.28 +
    1.29  void (*Atari_ShutdownEvents)(void);
    1.30  
    1.31  static void Atari_InitializeEvents(_THIS)
    1.32 @@ -108,10 +119,52 @@
    1.33  {
    1.34  	Atari_InitializeEvents(this);
    1.35  
    1.36 +	SDL_Atari_InitInternalKeymap(this);
    1.37 +
    1.38  	/* Call choosen routine */
    1.39  	this->InitOSKeymap(this);
    1.40  }
    1.41  
    1.42 +void SDL_Atari_InitInternalKeymap(_THIS)
    1.43 +{
    1.44 +	int i;
    1.45 +	_KEYTAB *key_tables;
    1.46 +
    1.47 +	/* Read system tables for scancode -> ascii translation */
    1.48 +	key_tables = (_KEYTAB *) Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
    1.49 +	keytab_normal = key_tables->unshift;
    1.50 +
    1.51 +	/* Initialize keymap */
    1.52 +	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
    1.53 +		keymap[i] = SDLK_UNKNOWN;
    1.54 +
    1.55 +	/* Functions keys */
    1.56 +	for ( i = 0; i<10; i++ )
    1.57 +		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
    1.58 +
    1.59 +	/* Cursor keypad */
    1.60 +	keymap[SCANCODE_HELP] = SDLK_HELP;
    1.61 +	keymap[SCANCODE_UNDO] = SDLK_UNDO;
    1.62 +	keymap[SCANCODE_INSERT] = SDLK_INSERT;
    1.63 +	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    1.64 +	keymap[SCANCODE_UP] = SDLK_UP;
    1.65 +	keymap[SCANCODE_DOWN] = SDLK_DOWN;
    1.66 +	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    1.67 +	keymap[SCANCODE_LEFT] = SDLK_LEFT;
    1.68 +
    1.69 +	/* Special keys */
    1.70 +	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    1.71 +	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    1.72 +	keymap[SCANCODE_TAB] = SDLK_TAB;
    1.73 +	keymap[SCANCODE_ENTER] = SDLK_RETURN;
    1.74 +	keymap[SCANCODE_DELETE] = SDLK_DELETE;
    1.75 +	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    1.76 +	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    1.77 +	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    1.78 +	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    1.79 +	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    1.80 +}
    1.81 +
    1.82  void Atari_PumpEvents(_THIS)
    1.83  {
    1.84  	Atari_InitializeEvents(this);
    1.85 @@ -162,3 +215,25 @@
    1.86  	0x2261,0x00B1,0x2265,0x2264,0x2320,0x2321,0x00F7,0x2248,
    1.87  	0x00B0,0x2022,0x00B7,0x221A,0x207F,0x00B2,0x00B3,0x00AF
    1.88  };
    1.89 +
    1.90 +SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
    1.91 +	SDL_bool pressed)
    1.92 +{
    1.93 +	int asciicode = 0;
    1.94 +
    1.95 +	/* Set the keysym information */
    1.96 +	keysym->scancode = scancode;
    1.97 +	keysym->mod = KMOD_NONE;
    1.98 +	keysym->sym = keymap[scancode];
    1.99 +	keysym->unicode = 0;
   1.100 +
   1.101 +	if (keysym->sym == SDLK_UNKNOWN) {
   1.102 +		keysym->sym = asciicode = keytab_normal[scancode];		
   1.103 +	}
   1.104 +
   1.105 +	if (SDL_TranslateUNICODE && pressed) {
   1.106 +		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
   1.107 +	}
   1.108 +
   1.109 +	return(keysym);
   1.110 +}
     2.1 --- a/src/video/ataricommon/SDL_atarievents_c.h	Tue Sep 12 19:34:18 2006 +0000
     2.2 +++ b/src/video/ataricommon/SDL_atarievents_c.h	Wed Sep 13 21:18:35 2006 +0000
     2.3 @@ -35,12 +35,31 @@
     2.4  /* Hidden "this" pointer for the video functions */
     2.5  #define _THIS	SDL_VideoDevice *this
     2.6  
     2.7 +#define ATARIBIOS_MAXKEYS 128
     2.8 +
     2.9 +/* Special keys state */
    2.10 +#ifndef K_RSHIFT
    2.11 +enum {
    2.12 +	K_RSHIFT=0,
    2.13 +	K_LSHIFT,
    2.14 +	K_CTRL,
    2.15 +	K_ALT,
    2.16 +	K_CAPSLOCK,
    2.17 +	K_CLRHOME,
    2.18 +	K_INSERT
    2.19 +};
    2.20 +#endif
    2.21 +
    2.22  extern void (*Atari_ShutdownEvents)(void);
    2.23  
    2.24  extern void Atari_InitOSKeymap(_THIS);
    2.25  extern void Atari_PumpEvents(_THIS);
    2.26  
    2.27 +extern void SDL_Atari_InitInternalKeymap(_THIS);
    2.28 +
    2.29  /* Atari to Unicode charset translation table */
    2.30  extern Uint16 SDL_AtariToUnicodeTable[256];
    2.31 +SDL_keysym *SDL_Atari_TranslateKey(int scancode, SDL_keysym *keysym,
    2.32 +	SDL_bool pressed);
    2.33  
    2.34  #endif /* _SDL_ATARI_EVENTS_H_ */
     3.1 --- a/src/video/ataricommon/SDL_biosevents.c	Tue Sep 12 19:34:18 2006 +0000
     3.2 +++ b/src/video/ataricommon/SDL_biosevents.c	Wed Sep 13 21:18:35 2006 +0000
     3.3 @@ -39,30 +39,10 @@
     3.4  #include "SDL_xbiosevents_c.h"
     3.5  #include "SDL_ataridevmouse_c.h"
     3.6  
     3.7 -/* To save state of keyboard */
     3.8 -#define ATARIBIOS_MAXKEYS 128
     3.9 -
    3.10  static unsigned char bios_currentkeyboard[ATARIBIOS_MAXKEYS];
    3.11  static unsigned char bios_previouskeyboard[ATARIBIOS_MAXKEYS];
    3.12 -static unsigned char bios_currentascii[ATARIBIOS_MAXKEYS];
    3.13  static SDL_bool use_dev_mouse = SDL_FALSE;
    3.14  
    3.15 -/* Special keys state */
    3.16 -enum {
    3.17 -	K_RSHIFT=0,
    3.18 -	K_LSHIFT,
    3.19 -	K_CTRL,
    3.20 -	K_ALT,
    3.21 -	K_CAPSLOCK,
    3.22 -	K_CLRHOME,
    3.23 -	K_INSERT
    3.24 -};
    3.25 -
    3.26 -/* The translation tables from a console scancode to a SDL keysym */
    3.27 -static SDLKey keymap[ATARIBIOS_MAXKEYS];
    3.28 -
    3.29 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
    3.30 -	SDL_bool pressed);
    3.31  static void UpdateSpecialKeys(int special_keys_state);
    3.32  
    3.33  void AtariBios_InitOSKeymap(_THIS)
    3.34 @@ -73,45 +53,15 @@
    3.35  	SDL_memset(bios_currentkeyboard, 0, sizeof(bios_currentkeyboard));
    3.36  	SDL_memset(bios_previouskeyboard, 0, sizeof(bios_previouskeyboard));
    3.37  
    3.38 -	/* Initialize keymap */
    3.39 -	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
    3.40 -		keymap[i] = SDLK_UNKNOWN;
    3.41 -
    3.42 -	/* Functions keys */
    3.43 -	for ( i = 0; i<10; i++ )
    3.44 -		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
    3.45 -
    3.46 -	/* Cursor keypad */
    3.47 -	keymap[SCANCODE_HELP] = SDLK_HELP;
    3.48 -	keymap[SCANCODE_UNDO] = SDLK_UNDO;
    3.49 -	keymap[SCANCODE_INSERT] = SDLK_INSERT;
    3.50 -	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    3.51 -	keymap[SCANCODE_UP] = SDLK_UP;
    3.52 -	keymap[SCANCODE_DOWN] = SDLK_DOWN;
    3.53 -	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    3.54 -	keymap[SCANCODE_LEFT] = SDLK_LEFT;
    3.55 -
    3.56 -	/* Special keys */
    3.57 -	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    3.58 -	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    3.59 -	keymap[SCANCODE_TAB] = SDLK_TAB;
    3.60 -	keymap[SCANCODE_ENTER] = SDLK_RETURN;
    3.61 -	keymap[SCANCODE_DELETE] = SDLK_DELETE;
    3.62 -	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    3.63 -	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    3.64 -	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    3.65 -	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    3.66 -	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    3.67 -
    3.68  	use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
    3.69  
    3.70  	vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;	/* XBIOS joystick events */
    3.71  	if (!use_dev_mouse) {
    3.72  		vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;	/* XBIOS mouse events */
    3.73  	}
    3.74 -	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
    3.75 +/*	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
    3.76  		vectors_mask = 0;
    3.77 -	}
    3.78 +	}*/
    3.79  
    3.80  	SDL_AtariXbios_InstallVectors(vectors_mask);
    3.81  }
    3.82 @@ -126,15 +76,8 @@
    3.83  
    3.84  	while (Bconstat(_CON)) {
    3.85  		unsigned long key_pressed;
    3.86 -		unsigned char asciicode, scancode;
    3.87 -
    3.88  		key_pressed=Bconin(_CON);
    3.89 -
    3.90 -		asciicode = key_pressed;
    3.91 -		scancode = key_pressed >> 16;
    3.92 -
    3.93 -		bios_currentkeyboard[scancode]=0xFF;
    3.94 -		bios_currentascii[scancode]=asciicode;
    3.95 +		bios_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
    3.96  	}
    3.97  
    3.98  	/* Read special keys */
    3.99 @@ -145,12 +88,12 @@
   3.100  		/* Key pressed ? */
   3.101  		if (bios_currentkeyboard[i] && !bios_previouskeyboard[i])
   3.102  			SDL_PrivateKeyboard(SDL_PRESSED,
   3.103 -				TranslateKey(i, bios_currentascii[i], &keysym, SDL_TRUE));
   3.104 +				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
   3.105  			
   3.106  		/* Key unpressed ? */
   3.107  		if (bios_previouskeyboard[i] && !bios_currentkeyboard[i])
   3.108  			SDL_PrivateKeyboard(SDL_RELEASED,
   3.109 -				TranslateKey(i, bios_currentascii[i], &keysym, SDL_FALSE));
   3.110 +				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
   3.111  	}
   3.112  
   3.113  	if (use_dev_mouse) {
   3.114 @@ -160,7 +103,7 @@
   3.115  	}
   3.116  
   3.117  	/* Will be previous table */
   3.118 -	SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, ATARIBIOS_MAXKEYS);
   3.119 +	SDL_memcpy(bios_previouskeyboard, bios_currentkeyboard, sizeof(bios_previouskeyboard));
   3.120  }
   3.121  
   3.122  static void UpdateSpecialKeys(int special_keys_state)
   3.123 @@ -169,7 +112,6 @@
   3.124  	{	\
   3.125  		if (special_keys_state & (1<<(numbit))) { \
   3.126  			bios_currentkeyboard[scancode]=0xFF; \
   3.127 -			bios_currentascii[scancode]=0; \
   3.128  		}	\
   3.129  	}
   3.130  
   3.131 @@ -180,26 +122,6 @@
   3.132  	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
   3.133  }
   3.134  
   3.135 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
   3.136 -	SDL_bool pressed)
   3.137 -{
   3.138 -	/* Set the keysym information */
   3.139 -	keysym->scancode = scancode;
   3.140 -
   3.141 -	if (asciicode)
   3.142 -		keysym->sym = asciicode;		
   3.143 -	else
   3.144 -		keysym->sym = keymap[scancode];
   3.145 -
   3.146 -	keysym->mod = KMOD_NONE;
   3.147 -	keysym->unicode = 0;
   3.148 -	if (SDL_TranslateUNICODE && pressed) {
   3.149 -		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
   3.150 -	}
   3.151 -
   3.152 -	return(keysym);
   3.153 -}
   3.154 -
   3.155  void AtariBios_ShutdownEvents(void)
   3.156  {
   3.157  	SDL_AtariXbios_RestoreVectors();
     4.1 --- a/src/video/ataricommon/SDL_gemdosevents.c	Tue Sep 12 19:34:18 2006 +0000
     4.2 +++ b/src/video/ataricommon/SDL_gemdosevents.c	Wed Sep 13 21:18:35 2006 +0000
     4.3 @@ -40,34 +40,16 @@
     4.4  #include "SDL_ataridevmouse_c.h"
     4.5  
     4.6  /* To save state of keyboard */
     4.7 -#define ATARIBIOS_MAXKEYS 128
     4.8  
     4.9  static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS];
    4.10  static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS];
    4.11 -static unsigned char gemdos_currentascii[ATARIBIOS_MAXKEYS];
    4.12  static SDL_bool use_dev_mouse = SDL_FALSE;
    4.13  
    4.14 -/* Special keys state */
    4.15 -enum {
    4.16 -	K_RSHIFT=0,
    4.17 -	K_LSHIFT,
    4.18 -	K_CTRL,
    4.19 -	K_ALT,
    4.20 -	K_CAPSLOCK,
    4.21 -	K_CLRHOME,
    4.22 -	K_INSERT
    4.23 -};
    4.24 -
    4.25  enum {
    4.26  	DEV_BUSY=0,
    4.27  	DEV_READY
    4.28  };
    4.29  
    4.30 -/* The translation tables from a console scancode to a SDL keysym */
    4.31 -static SDLKey keymap[ATARIBIOS_MAXKEYS];
    4.32 -
    4.33 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
    4.34 -	SDL_bool pressed);
    4.35  static void UpdateSpecialKeys(int special_keys_state);
    4.36  
    4.37  void AtariGemdos_InitOSKeymap(_THIS)
    4.38 @@ -78,45 +60,15 @@
    4.39  	SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
    4.40  	SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
    4.41  
    4.42 -	/* Initialize keymap */
    4.43 -	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
    4.44 -		keymap[i] = SDLK_UNKNOWN;
    4.45 -
    4.46 -	/* Functions keys */
    4.47 -	for ( i = 0; i<10; i++ )
    4.48 -		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
    4.49 -
    4.50 -	/* Cursor keypad */
    4.51 -	keymap[SCANCODE_HELP] = SDLK_HELP;
    4.52 -	keymap[SCANCODE_UNDO] = SDLK_UNDO;
    4.53 -	keymap[SCANCODE_INSERT] = SDLK_INSERT;
    4.54 -	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    4.55 -	keymap[SCANCODE_UP] = SDLK_UP;
    4.56 -	keymap[SCANCODE_DOWN] = SDLK_DOWN;
    4.57 -	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    4.58 -	keymap[SCANCODE_LEFT] = SDLK_LEFT;
    4.59 -
    4.60 -	/* Special keys */
    4.61 -	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    4.62 -	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    4.63 -	keymap[SCANCODE_TAB] = SDLK_TAB;
    4.64 -	keymap[SCANCODE_ENTER] = SDLK_RETURN;
    4.65 -	keymap[SCANCODE_DELETE] = SDLK_DELETE;
    4.66 -	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    4.67 -	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    4.68 -	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    4.69 -	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    4.70 -	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    4.71 -
    4.72  	use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
    4.73  
    4.74  	vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;	/* XBIOS joystick events */
    4.75  	if (!use_dev_mouse) {
    4.76  		vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;	/* XBIOS mouse events */
    4.77  	}
    4.78 -	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
    4.79 +/*	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
    4.80  		vectors_mask = 0;
    4.81 -	}
    4.82 +	}*/
    4.83  	SDL_AtariXbios_InstallVectors(vectors_mask);
    4.84  }
    4.85  
    4.86 @@ -130,15 +82,8 @@
    4.87  
    4.88  	while (Cconis()!=DEV_BUSY) {
    4.89  		unsigned long key_pressed;
    4.90 -		unsigned char scancode, asciicode;
    4.91 -
    4.92  		key_pressed=Cnecin();
    4.93 -
    4.94 -		asciicode = key_pressed;
    4.95 -		scancode = key_pressed >> 16;
    4.96 -
    4.97 -		gemdos_currentkeyboard[scancode]=0xFF;
    4.98 -		gemdos_currentascii[scancode]=asciicode;
    4.99 +		gemdos_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
   4.100  	}
   4.101  
   4.102  	/* Read special keys */
   4.103 @@ -149,12 +94,12 @@
   4.104  		/* Key pressed ? */
   4.105  		if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
   4.106  			SDL_PrivateKeyboard(SDL_PRESSED,
   4.107 -				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_TRUE));
   4.108 +				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
   4.109  			
   4.110  		/* Key unpressed ? */
   4.111  		if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
   4.112  			SDL_PrivateKeyboard(SDL_RELEASED,
   4.113 -				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_FALSE));
   4.114 +				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
   4.115  	}
   4.116  
   4.117  	if (use_dev_mouse) {
   4.118 @@ -164,7 +109,7 @@
   4.119  	}
   4.120  
   4.121  	/* Will be previous table */
   4.122 -	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
   4.123 +	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, sizeof(gemdos_previouskeyboard));
   4.124  }
   4.125  
   4.126  static void UpdateSpecialKeys(int special_keys_state)
   4.127 @@ -173,7 +118,6 @@
   4.128  	{	\
   4.129  		if (special_keys_state & (1<<(numbit))) { \
   4.130  			gemdos_currentkeyboard[scancode]=0xFF; \
   4.131 -			gemdos_currentascii[scancode]=0; \
   4.132  		}	\
   4.133  	}
   4.134  
   4.135 @@ -184,26 +128,6 @@
   4.136  	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
   4.137  }
   4.138  
   4.139 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
   4.140 -	SDL_bool pressed)
   4.141 -{
   4.142 -	/* Set the keysym information */
   4.143 -	keysym->scancode = scancode;
   4.144 -
   4.145 -	if (asciicode)
   4.146 -		keysym->sym = asciicode;		
   4.147 -	else
   4.148 -		keysym->sym = keymap[scancode];
   4.149 -
   4.150 -	keysym->mod = KMOD_NONE;
   4.151 -	keysym->unicode = 0;
   4.152 -	if (SDL_TranslateUNICODE && pressed) {
   4.153 -		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
   4.154 -	}
   4.155 -
   4.156 -	return(keysym);
   4.157 -}
   4.158 -
   4.159  void AtariGemdos_ShutdownEvents(void)
   4.160  {
   4.161  	SDL_AtariXbios_RestoreVectors();
     5.1 --- a/src/video/ataricommon/SDL_ikbdevents.c	Tue Sep 12 19:34:18 2006 +0000
     5.2 +++ b/src/video/ataricommon/SDL_ikbdevents.c	Wed Sep 13 21:18:35 2006 +0000
     5.3 @@ -37,85 +37,17 @@
     5.4  #include "SDL_atarievents_c.h"
     5.5  #include "SDL_ikbdinterrupt_s.h"
     5.6  
     5.7 -/* Special keys state */
     5.8 -enum {
     5.9 -	K_RSHIFT=0,
    5.10 -	K_LSHIFT,
    5.11 -	K_CTRL,
    5.12 -	K_ALT,
    5.13 -	K_CAPSLOCK,
    5.14 -	K_CLRHOME,
    5.15 -	K_INSERT
    5.16 -};
    5.17 -
    5.18 -#define ATARIBIOS_MAXKEYS 128
    5.19 -
    5.20  #define KEY_PRESSED		0xff
    5.21  #define KEY_UNDEFINED	0x80
    5.22  #define KEY_RELEASED	0x00
    5.23  
    5.24 -/* The translation tables from a console scancode to a SDL keysym */
    5.25 -#define KT_NOCHANGE -1
    5.26 -
    5.27 -enum {
    5.28 -	KT_UNSHIFT=0,
    5.29 -	KT_SHIFT=1,
    5.30 -	KT_CAPS=2
    5.31 -};
    5.32 -
    5.33  static Uint16 atari_prevmouseb;	/* save state of mouse buttons */
    5.34 -static int caps_state;			/* caps lock state */
    5.35 -_KEYTAB *curtables;
    5.36 -static unsigned char *tab_unshift, *tab_shift, *tab_caps;
    5.37 -static SDLKey keymap[ATARIBIOS_MAXKEYS];
    5.38 -
    5.39 -static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym,
    5.40 -	SDL_bool pressed);
    5.41  
    5.42  void AtariIkbd_InitOSKeymap(_THIS)
    5.43  {
    5.44  	int i;
    5.45  
    5.46 -	SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS);
    5.47 -
    5.48 -	/* Initialize keymap */
    5.49 -	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
    5.50 -		keymap[i] = SDLK_UNKNOWN;
    5.51 -
    5.52 -	/* Functions keys */
    5.53 -	for ( i = 0; i<10; i++ )
    5.54 -		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
    5.55 -
    5.56 -	/* Cursor keypad */
    5.57 -	keymap[SCANCODE_HELP] = SDLK_HELP;
    5.58 -	keymap[SCANCODE_UNDO] = SDLK_UNDO;
    5.59 -	keymap[SCANCODE_INSERT] = SDLK_INSERT;
    5.60 -	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    5.61 -	keymap[SCANCODE_UP] = SDLK_UP;
    5.62 -	keymap[SCANCODE_DOWN] = SDLK_DOWN;
    5.63 -	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    5.64 -	keymap[SCANCODE_LEFT] = SDLK_LEFT;
    5.65 -
    5.66 -	/* Special keys */
    5.67 -	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    5.68 -	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    5.69 -	keymap[SCANCODE_TAB] = SDLK_TAB;
    5.70 -	keymap[SCANCODE_ENTER] = SDLK_RETURN;
    5.71 -	keymap[SCANCODE_DELETE] = SDLK_DELETE;
    5.72 -	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    5.73 -	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    5.74 -	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    5.75 -	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    5.76 -	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    5.77 -
    5.78 -	/* Read XBIOS tables for scancode -> ascii translation */
    5.79 -	curtables=Keytbl(KT_NOCHANGE, KT_NOCHANGE, KT_NOCHANGE);
    5.80 -	tab_unshift=curtables->unshift;
    5.81 -	tab_shift=curtables->shift;
    5.82 -	tab_caps=curtables->caps;
    5.83 -
    5.84 -	/* Set Caps lock initial state */
    5.85 -	caps_state=(Kbshift(-1) & (1<<K_CAPSLOCK));
    5.86 +	SDL_memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, sizeof(SDL_AtariIkbd_keyboard));
    5.87  
    5.88  	/* Now install our handler */
    5.89  	SDL_AtariIkbd_mouseb = SDL_AtariIkbd_mousex = SDL_AtariIkbd_mousey = 0;
    5.90 @@ -140,41 +72,23 @@
    5.91  
    5.92  void AtariIkbd_PumpEvents(_THIS)
    5.93  {
    5.94 -	int i;
    5.95 +	int i, specialkeys;
    5.96  	SDL_keysym keysym;
    5.97 -	int specialkeys;
    5.98  
    5.99  	/*--- Send keyboard events ---*/
   5.100  
   5.101 -	/* Update caps lock state */
   5.102 -	if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK]==KEY_PRESSED) {
   5.103 -		caps_state ^= 1;
   5.104 -	}
   5.105 -
   5.106 -	/* Choose the translation table */
   5.107 -	specialkeys=KT_UNSHIFT;
   5.108 -	if ((SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT]==KEY_PRESSED)
   5.109 -		|| (SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT]==KEY_PRESSED))
   5.110 -	{
   5.111 -		specialkeys = KT_SHIFT;
   5.112 -	}
   5.113 -	if (caps_state) {
   5.114 -		specialkeys = KT_CAPS;
   5.115 -	}
   5.116 -
   5.117 -	/* Now generate events */
   5.118  	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
   5.119  		/* Key pressed ? */
   5.120  		if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
   5.121  			SDL_PrivateKeyboard(SDL_PRESSED,
   5.122 -				TranslateKey(i, specialkeys, &keysym, SDL_TRUE));
   5.123 +				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
   5.124  			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
   5.125  		}
   5.126  			
   5.127  		/* Key released ? */
   5.128  		if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
   5.129  			SDL_PrivateKeyboard(SDL_RELEASED,
   5.130 -				TranslateKey(i, specialkeys, &keysym, SDL_FALSE));
   5.131 +				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
   5.132  			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
   5.133  		}
   5.134  	}
   5.135 @@ -206,41 +120,6 @@
   5.136  	}
   5.137  }
   5.138  
   5.139 -static SDL_keysym *TranslateKey(int scancode, int numkeytable, SDL_keysym *keysym,
   5.140 -	SDL_bool pressed)
   5.141 -{
   5.142 -	unsigned char asciicode;
   5.143 -
   5.144 -	/* Set the keysym information */
   5.145 -	keysym->scancode = scancode;
   5.146 -
   5.147 -	asciicode=0;
   5.148 -	switch(numkeytable) {
   5.149 -		case KT_UNSHIFT:
   5.150 -			asciicode=tab_unshift[scancode];
   5.151 -			break;
   5.152 -		case KT_SHIFT:
   5.153 -			asciicode=tab_shift[scancode];
   5.154 -			break;
   5.155 -		case KT_CAPS:
   5.156 -			asciicode=tab_caps[scancode];
   5.157 -			break;
   5.158 -	}
   5.159 -
   5.160 -	if (asciicode)
   5.161 -		keysym->sym = asciicode;		
   5.162 -	else
   5.163 -		keysym->sym = keymap[scancode];
   5.164 -
   5.165 -	keysym->mod = KMOD_NONE;
   5.166 -	keysym->unicode = 0;
   5.167 -	if (SDL_TranslateUNICODE && pressed) {
   5.168 -		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
   5.169 -	}
   5.170 -
   5.171 -	return(keysym);
   5.172 -}
   5.173 -
   5.174  void AtariIkbd_ShutdownEvents(void)
   5.175  {
   5.176  	Supexec(SDL_AtariIkbdUninstall);