src/video/ataricommon/SDL_gemdosevents.c
branchSDL-1.2
changeset 3860 bf1586b58ef2
parent 3854 f1816773a309
child 4149 2325dd996f73
     1.1 --- a/src/video/ataricommon/SDL_gemdosevents.c	Tue Sep 12 19:34:18 2006 +0000
     1.2 +++ b/src/video/ataricommon/SDL_gemdosevents.c	Wed Sep 13 21:18:35 2006 +0000
     1.3 @@ -40,34 +40,16 @@
     1.4  #include "SDL_ataridevmouse_c.h"
     1.5  
     1.6  /* To save state of keyboard */
     1.7 -#define ATARIBIOS_MAXKEYS 128
     1.8  
     1.9  static unsigned char gemdos_currentkeyboard[ATARIBIOS_MAXKEYS];
    1.10  static unsigned char gemdos_previouskeyboard[ATARIBIOS_MAXKEYS];
    1.11 -static unsigned char gemdos_currentascii[ATARIBIOS_MAXKEYS];
    1.12  static SDL_bool use_dev_mouse = SDL_FALSE;
    1.13  
    1.14 -/* Special keys state */
    1.15 -enum {
    1.16 -	K_RSHIFT=0,
    1.17 -	K_LSHIFT,
    1.18 -	K_CTRL,
    1.19 -	K_ALT,
    1.20 -	K_CAPSLOCK,
    1.21 -	K_CLRHOME,
    1.22 -	K_INSERT
    1.23 -};
    1.24 -
    1.25  enum {
    1.26  	DEV_BUSY=0,
    1.27  	DEV_READY
    1.28  };
    1.29  
    1.30 -/* The translation tables from a console scancode to a SDL keysym */
    1.31 -static SDLKey keymap[ATARIBIOS_MAXKEYS];
    1.32 -
    1.33 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
    1.34 -	SDL_bool pressed);
    1.35  static void UpdateSpecialKeys(int special_keys_state);
    1.36  
    1.37  void AtariGemdos_InitOSKeymap(_THIS)
    1.38 @@ -78,45 +60,15 @@
    1.39  	SDL_memset(gemdos_currentkeyboard, 0, sizeof(gemdos_currentkeyboard));
    1.40  	SDL_memset(gemdos_previouskeyboard, 0, sizeof(gemdos_previouskeyboard));
    1.41  
    1.42 -	/* Initialize keymap */
    1.43 -	for ( i=0; i<ATARIBIOS_MAXKEYS; i++ )
    1.44 -		keymap[i] = SDLK_UNKNOWN;
    1.45 -
    1.46 -	/* Functions keys */
    1.47 -	for ( i = 0; i<10; i++ )
    1.48 -		keymap[SCANCODE_F1 + i] = SDLK_F1+i;
    1.49 -
    1.50 -	/* Cursor keypad */
    1.51 -	keymap[SCANCODE_HELP] = SDLK_HELP;
    1.52 -	keymap[SCANCODE_UNDO] = SDLK_UNDO;
    1.53 -	keymap[SCANCODE_INSERT] = SDLK_INSERT;
    1.54 -	keymap[SCANCODE_CLRHOME] = SDLK_HOME;
    1.55 -	keymap[SCANCODE_UP] = SDLK_UP;
    1.56 -	keymap[SCANCODE_DOWN] = SDLK_DOWN;
    1.57 -	keymap[SCANCODE_RIGHT] = SDLK_RIGHT;
    1.58 -	keymap[SCANCODE_LEFT] = SDLK_LEFT;
    1.59 -
    1.60 -	/* Special keys */
    1.61 -	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
    1.62 -	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
    1.63 -	keymap[SCANCODE_TAB] = SDLK_TAB;
    1.64 -	keymap[SCANCODE_ENTER] = SDLK_RETURN;
    1.65 -	keymap[SCANCODE_DELETE] = SDLK_DELETE;
    1.66 -	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
    1.67 -	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
    1.68 -	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
    1.69 -	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
    1.70 -	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
    1.71 -
    1.72  	use_dev_mouse = (SDL_AtariDevMouse_Open()!=0) ? SDL_TRUE : SDL_FALSE;
    1.73  
    1.74  	vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;	/* XBIOS joystick events */
    1.75  	if (!use_dev_mouse) {
    1.76  		vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;	/* XBIOS mouse events */
    1.77  	}
    1.78 -	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
    1.79 +/*	if (Getcookie(C_MiNT, &dummy)==C_FOUND) {
    1.80  		vectors_mask = 0;
    1.81 -	}
    1.82 +	}*/
    1.83  	SDL_AtariXbios_InstallVectors(vectors_mask);
    1.84  }
    1.85  
    1.86 @@ -130,15 +82,8 @@
    1.87  
    1.88  	while (Cconis()!=DEV_BUSY) {
    1.89  		unsigned long key_pressed;
    1.90 -		unsigned char scancode, asciicode;
    1.91 -
    1.92  		key_pressed=Cnecin();
    1.93 -
    1.94 -		asciicode = key_pressed;
    1.95 -		scancode = key_pressed >> 16;
    1.96 -
    1.97 -		gemdos_currentkeyboard[scancode]=0xFF;
    1.98 -		gemdos_currentascii[scancode]=asciicode;
    1.99 +		gemdos_currentkeyboard[(key_pressed>>16)&(ATARIBIOS_MAXKEYS-1)]=0xFF;
   1.100  	}
   1.101  
   1.102  	/* Read special keys */
   1.103 @@ -149,12 +94,12 @@
   1.104  		/* Key pressed ? */
   1.105  		if (gemdos_currentkeyboard[i] && !gemdos_previouskeyboard[i])
   1.106  			SDL_PrivateKeyboard(SDL_PRESSED,
   1.107 -				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_TRUE));
   1.108 +				SDL_Atari_TranslateKey(i, &keysym, SDL_TRUE));
   1.109  			
   1.110  		/* Key unpressed ? */
   1.111  		if (gemdos_previouskeyboard[i] && !gemdos_currentkeyboard[i])
   1.112  			SDL_PrivateKeyboard(SDL_RELEASED,
   1.113 -				TranslateKey(i, gemdos_currentascii[i], &keysym, SDL_FALSE));
   1.114 +				SDL_Atari_TranslateKey(i, &keysym, SDL_FALSE));
   1.115  	}
   1.116  
   1.117  	if (use_dev_mouse) {
   1.118 @@ -164,7 +109,7 @@
   1.119  	}
   1.120  
   1.121  	/* Will be previous table */
   1.122 -	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, ATARIBIOS_MAXKEYS);
   1.123 +	SDL_memcpy(gemdos_previouskeyboard, gemdos_currentkeyboard, sizeof(gemdos_previouskeyboard));
   1.124  }
   1.125  
   1.126  static void UpdateSpecialKeys(int special_keys_state)
   1.127 @@ -173,7 +118,6 @@
   1.128  	{	\
   1.129  		if (special_keys_state & (1<<(numbit))) { \
   1.130  			gemdos_currentkeyboard[scancode]=0xFF; \
   1.131 -			gemdos_currentascii[scancode]=0; \
   1.132  		}	\
   1.133  	}
   1.134  
   1.135 @@ -184,26 +128,6 @@
   1.136  	UPDATE_SPECIAL_KEYS(K_CAPSLOCK, SCANCODE_CAPSLOCK);
   1.137  }
   1.138  
   1.139 -static SDL_keysym *TranslateKey(int scancode, int asciicode, SDL_keysym *keysym,
   1.140 -	SDL_bool pressed)
   1.141 -{
   1.142 -	/* Set the keysym information */
   1.143 -	keysym->scancode = scancode;
   1.144 -
   1.145 -	if (asciicode)
   1.146 -		keysym->sym = asciicode;		
   1.147 -	else
   1.148 -		keysym->sym = keymap[scancode];
   1.149 -
   1.150 -	keysym->mod = KMOD_NONE;
   1.151 -	keysym->unicode = 0;
   1.152 -	if (SDL_TranslateUNICODE && pressed) {
   1.153 -		keysym->unicode = SDL_AtariToUnicodeTable[asciicode];
   1.154 -	}
   1.155 -
   1.156 -	return(keysym);
   1.157 -}
   1.158 -
   1.159  void AtariGemdos_ShutdownEvents(void)
   1.160  {
   1.161  	SDL_AtariXbios_RestoreVectors();