src/video/gem/SDL_gemevents.c
branchSDL-1.2
changeset 3861 c3625a895caf
parent 3854 f1816773a309
child 4059 57b017e6aebf
     1.1 --- a/src/video/gem/SDL_gemevents.c	Wed Sep 13 21:18:35 2006 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Wed Sep 13 21:19:13 2006 +0000
     1.3 @@ -41,89 +41,28 @@
     1.4  #include "../ataricommon/SDL_xbiosevents_c.h"
     1.5  #include "../ataricommon/SDL_ataridevmouse_c.h"
     1.6  
     1.7 -/* Defines */
     1.8 -
     1.9 -#define ATARIBIOS_MAXKEYS 128
    1.10 -
    1.11  /* Variables */
    1.12  
    1.13  static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS];
    1.14  static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
    1.15 -static unsigned char gem_currentascii[ATARIBIOS_MAXKEYS];
    1.16 -
    1.17 -/* The translation tables from a console scancode to a SDL keysym */
    1.18 -static SDLKey keymap[ATARIBIOS_MAXKEYS];
    1.19  
    1.20  /* Functions prototypes */
    1.21  
    1.22 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
    1.23 -	SDL_bool pressed);
    1.24  static int do_messages(_THIS, short *message);
    1.25  static void do_keyboard(short kc, short ks);
    1.26  static void do_mouse(_THIS, short mx, short my, short mb, short ks);
    1.27  
    1.28  /* Functions */
    1.29  
    1.30 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
    1.31 -	SDL_bool pressed)
    1.32 -{
    1.33 -	/* Set the keysym information */
    1.34 -	keysym->scancode = scancode;
    1.35 -
    1.36 -	if (asciicode)
    1.37 -		keysym->sym = asciicode;		
    1.38 -	else
    1.39 -		keysym->sym = keymap[scancode];
    1.40 -
    1.41 -	keysym->mod = KMOD_NONE;
    1.42 -	keysym->unicode = 0;
    1.43 -	if (SDL_TranslateUNICODE && pressed) {
    1.44 -		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
    1.45 -	}
    1.46 -
    1.47 -	return(keysym);
    1.48 -}
    1.49 -
    1.50  void GEM_InitOSKeymap(_THIS)
    1.51  {
    1.52 -	int i;
    1.53 -
    1.54  	SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
    1.55  	SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard));
    1.56 -	SDL_memset(gem_currentascii, 0, sizeof(gem_currentascii));
    1.57 -
    1.58 -	/* Initialize keymap */
    1.59 -	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
    1.60 -		keymap[i] = SDLK_UNKNOWN;
    1.61 -
    1.62 -	/* Functions keys */
    1.63 -	for ( i = 0; i<10; i++ )
    1.64 -		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
    1.65 -
    1.66 -	/* Cursor keypad */
    1.67 -	keymap[SCANCODE_HELP] = SDLK_HELP;
    1.68 -	keymap[SCANCODE_UNDO] = SDLK_UNDO;
    1.69 -	keymap[SCANCODE_INSERT] = SDLK_INSERT;
    1.70 -	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    1.71 -	keymap[SCANCODE_UP] = SDLK_UP;
    1.72 -	keymap[SCANCODE_DOWN] = SDLK_DOWN;
    1.73 -	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    1.74 -	keymap[SCANCODE_LEFT] = SDLK_LEFT;
    1.75 -
    1.76 -	/* Special keys */
    1.77 -	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    1.78 -	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    1.79 -	keymap[SCANCODE_TAB] = SDLK_TAB;
    1.80 -	keymap[SCANCODE_ENTER] = SDLK_RETURN;
    1.81 -	keymap[SCANCODE_DELETE] = SDLK_DELETE;
    1.82 -	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    1.83 -	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    1.84 -	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    1.85 -	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    1.86 -	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    1.87  
    1.88  	/* Mouse init */
    1.89  	GEM_mouse_relative = SDL_FALSE;
    1.90 +
    1.91 +	SDL_Atari_InitInternalKeymap(this);
    1.92  }
    1.93  
    1.94  void GEM_PumpEvents(_THIS)
    1.95 @@ -216,12 +155,12 @@
    1.96  		/* Key pressed ? */
    1.97  		if (gem_currentkeyboard[i] && !gem_previouskeyboard[i])
    1.98  			SDL_PrivateKeyboard(SDL_PRESSED,
    1.99 -				TranslateKey(i, gem_currentascii[i], &keysym, SDL_TRUE));
   1.100 +				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
   1.101  			
   1.102  		/* Key unpressed ? */
   1.103  		if (gem_previouskeyboard[i] && !gem_currentkeyboard[i])
   1.104  			SDL_PrivateKeyboard(SDL_RELEASED,
   1.105 -				TranslateKey(i, gem_currentascii[i], &keysym, SDL_FALSE));
   1.106 +				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
   1.107  	}
   1.108  
   1.109  	SDL_memcpy(gem_previouskeyboard,gem_currentkeyboard,sizeof(gem_previouskeyboard));
   1.110 @@ -341,14 +280,11 @@
   1.111  
   1.112  static void do_keyboard(short kc, short ks)
   1.113  {
   1.114 -	int			scancode, asciicode;
   1.115 +	int scancode;
   1.116  
   1.117  	if (kc) {
   1.118 -		scancode=(kc>>8) & 127;
   1.119 -		asciicode=kc & 255;
   1.120 -
   1.121 +		scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1);
   1.122  		gem_currentkeyboard[scancode]=0xFF;
   1.123 -		gem_currentascii[scancode]=asciicode;
   1.124  	}
   1.125  
   1.126  	/* Read special keys */