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