gem: Move special keys handling in a separate function SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Fri, 12 Oct 2012 18:25:28 +0200
branchSDL-1.2
changeset 65828b7e21749630
parent 6572 0d391c407a4f
child 6583 15c1dc6ac329
gem: Move special keys handling in a separate function
src/video/gem/SDL_gemevents.c
     1.1 --- a/src/video/gem/SDL_gemevents.c	Thu Oct 11 19:08:03 2012 +0200
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Fri Oct 12 18:25:28 2012 +0200
     1.3 @@ -50,8 +50,9 @@
     1.4  /* Functions prototypes */
     1.5  
     1.6  static int do_messages(_THIS, short *message);
     1.7 -static void do_keyboard(short kc, short ks);
     1.8 -static void do_mouse(_THIS, short mx, short my, short mb, short ks);
     1.9 +static void do_keyboard(short kc);
    1.10 +static void do_keyboard_special(short ks);
    1.11 +static void do_mouse(_THIS, short mx, short my, short mb);
    1.12  
    1.13  /* Functions */
    1.14  
    1.15 @@ -68,13 +69,13 @@
    1.16  
    1.17  void GEM_PumpEvents(_THIS)
    1.18  {
    1.19 -	short prevkc, prevks;
    1.20 +	short prevkc;
    1.21  	static short maskmouseb=0;
    1.22  	int i;
    1.23  	SDL_keysym	keysym;
    1.24  
    1.25  	SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));
    1.26 -	prevkc = prevks = 0;
    1.27 +	prevkc = 0;
    1.28  
    1.29  	for (;;)
    1.30  	{
    1.31 @@ -110,15 +111,18 @@
    1.32  		if (resultat & MU_MESAG)
    1.33  			quit = do_messages(this, buffer);
    1.34  
    1.35 +		/* Special keys ? */
    1.36 +		if (resultat & (MU_KEYBD|MU_BUTTON))
    1.37 +			do_keyboard_special(kstate);
    1.38 +
    1.39  		/* Keyboard event ? */
    1.40  		if (resultat & MU_KEYBD) {
    1.41 -			if ((prevkc != kc) || (prevks != kstate)) {
    1.42 -				do_keyboard(kc,kstate);
    1.43 +			if (prevkc != kc) {
    1.44 +				do_keyboard(kc);
    1.45  				prevkc = kc;
    1.46 -				prevks = ks;
    1.47  			} else {
    1.48  				/* Avoid looping, if repeating same key */
    1.49 -				break;
    1.50 +				quit = 1;
    1.51  			}
    1.52  		}
    1.53  
    1.54 @@ -134,7 +138,7 @@
    1.55  
    1.56  		/* Mouse button event ? */
    1.57  		if (resultat & MU_BUTTON) {
    1.58 -			do_mouse(this, mousex, mousey, mouseb, kstate);
    1.59 +			do_mouse(this, mousex, mousey, mouseb);
    1.60  			maskmouseb = mouseb & 7;
    1.61  		}
    1.62  
    1.63 @@ -277,7 +281,7 @@
    1.64  	return quit;
    1.65  }
    1.66  
    1.67 -static void do_keyboard(short kc, short ks)
    1.68 +static void do_keyboard(short kc)
    1.69  {
    1.70  	int scancode;
    1.71  
    1.72 @@ -285,7 +289,10 @@
    1.73  		scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1);
    1.74  		gem_currentkeyboard[scancode]=0xFF;
    1.75  	}
    1.76 +}
    1.77  
    1.78 +static void do_keyboard_special(short ks)
    1.79 +{
    1.80  	/* Read special keys */
    1.81  	if (ks & K_RSHIFT)
    1.82  		gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
    1.83 @@ -297,7 +304,7 @@
    1.84  		gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
    1.85  }
    1.86  
    1.87 -static void do_mouse(_THIS, short mx, short my, short mb, short ks)
    1.88 +static void do_mouse(_THIS, short mx, short my, short mb)
    1.89  {
    1.90  	static short prevmousex=0, prevmousey=0, prevmouseb=0;
    1.91  	short x2, y2, w2, h2;
    1.92 @@ -364,14 +371,4 @@
    1.93  		}
    1.94  		prevmouseb = mb;
    1.95  	}
    1.96 -
    1.97 -	/* Read special keys */
    1.98 -	if (ks & K_RSHIFT)
    1.99 -		gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
   1.100 -	if (ks & K_LSHIFT)
   1.101 -		gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF;
   1.102 -	if (ks & K_CTRL)
   1.103 -		gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF;
   1.104 -	if (ks & K_ALT)
   1.105 -		gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
   1.106  }