src/video/ataricommon/SDL_ikbdevents.c
changeset 1082 48436ffdf677
parent 769 b8d311d90021
child 1209 a55ac374271c
     1.1 --- a/src/video/ataricommon/SDL_ikbdevents.c	Wed Jun 29 16:18:46 2005 +0000
     1.2 +++ b/src/video/ataricommon/SDL_ikbdevents.c	Wed Jun 29 20:32:46 2005 +0000
     1.3 @@ -54,11 +54,11 @@
     1.4  	K_INSERT
     1.5  };
     1.6  
     1.7 -/* To save state of keyboard */
     1.8  #define ATARIBIOS_MAXKEYS 128
     1.9  
    1.10 -static unsigned char ikbd_previouskeyboard[ATARIBIOS_MAXKEYS];
    1.11 -static Uint16 atari_prevmouseb;	/* buttons */
    1.12 +#define KEY_PRESSED		0xff
    1.13 +#define KEY_UNDEFINED	0x80
    1.14 +#define KEY_RELEASED	0x00
    1.15  
    1.16  /* The translation tables from a console scancode to a SDL keysym */
    1.17  #define KT_NOCHANGE -1
    1.18 @@ -69,7 +69,8 @@
    1.19  	KT_CAPS=2
    1.20  };
    1.21  
    1.22 -static int caps_state;
    1.23 +static Uint16 atari_prevmouseb;	/* save state of mouse buttons */
    1.24 +static int caps_state;			/* caps lock state */
    1.25  _KEYTAB *curtables;
    1.26  static unsigned char *tab_unshift, *tab_shift, *tab_caps;
    1.27  static SDLKey keymap[ATARIBIOS_MAXKEYS];
    1.28 @@ -80,8 +81,7 @@
    1.29  {
    1.30  	int i;
    1.31  
    1.32 -	memset(SDL_AtariIkbd_keyboard, 0, ATARIBIOS_MAXKEYS);
    1.33 -	memset(ikbd_previouskeyboard, 0, ATARIBIOS_MAXKEYS);
    1.34 +	memset(SDL_AtariIkbd_keyboard, KEY_UNDEFINED, ATARIBIOS_MAXKEYS);
    1.35  
    1.36  	/* Initialize keymap */
    1.37  	for ( i=0; i<sizeof(keymap); i++ )
    1.38 @@ -152,30 +152,36 @@
    1.39  	/*--- Send keyboard events ---*/
    1.40  
    1.41  	/* Update caps lock state */
    1.42 -	if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK] && !ikbd_previouskeyboard[SCANCODE_CAPSLOCK])
    1.43 +	if (SDL_AtariIkbd_keyboard[SCANCODE_CAPSLOCK]==KEY_PRESSED) {
    1.44  		caps_state ^= 1;
    1.45 +	}
    1.46  
    1.47  	/* Choose the translation table */
    1.48  	specialkeys=KT_UNSHIFT;
    1.49 -	if (SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT] || SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT])
    1.50 +	if ((SDL_AtariIkbd_keyboard[SCANCODE_LEFTSHIFT]==KEY_PRESSED)
    1.51 +		|| (SDL_AtariIkbd_keyboard[SCANCODE_RIGHTSHIFT]==KEY_PRESSED))
    1.52 +	{
    1.53  		specialkeys = KT_SHIFT;
    1.54 -	if (caps_state)
    1.55 +	}
    1.56 +	if (caps_state) {
    1.57  		specialkeys = KT_CAPS;
    1.58 +	}
    1.59  
    1.60  	/* Now generate events */
    1.61  	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
    1.62  		/* Key pressed ? */
    1.63 -		if (SDL_AtariIkbd_keyboard[i] && !ikbd_previouskeyboard[i])
    1.64 +		if (SDL_AtariIkbd_keyboard[i]==KEY_PRESSED) {
    1.65  			SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(i, specialkeys, &keysym));
    1.66 +			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
    1.67 +		}
    1.68  			
    1.69 -		/* Key unpressed ? */
    1.70 -		if (ikbd_previouskeyboard[i] && !SDL_AtariIkbd_keyboard[i])
    1.71 +		/* Key released ? */
    1.72 +		if (SDL_AtariIkbd_keyboard[i]==KEY_RELEASED) {
    1.73  			SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(i, specialkeys, &keysym));
    1.74 +			SDL_AtariIkbd_keyboard[i]=KEY_UNDEFINED;
    1.75 +		}
    1.76  	}
    1.77  
    1.78 -	/* Will be previous table */
    1.79 -	memcpy(ikbd_previouskeyboard, SDL_AtariIkbd_keyboard, ATARIBIOS_MAXKEYS);
    1.80 -
    1.81  	/*--- Send mouse events ---*/
    1.82  
    1.83  	/* Mouse motion ? */
    1.84 @@ -238,4 +244,3 @@
    1.85  {
    1.86  	Supexec(SDL_AtariIkbdUninstall);
    1.87  }
    1.88 -