Skip to content

Commit

Permalink
gem: Move special keys handling in a separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Oct 12, 2012
1 parent b9065e0 commit 5b04bda
Showing 1 changed file with 18 additions and 21 deletions.
39 changes: 18 additions & 21 deletions src/video/gem/SDL_gemevents.c
Expand Up @@ -50,8 +50,9 @@ static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];
/* Functions prototypes */ /* Functions prototypes */


static int do_messages(_THIS, short *message); static int do_messages(_THIS, short *message);
static void do_keyboard(short kc, short ks); static void do_keyboard(short kc);
static void do_mouse(_THIS, short mx, short my, short mb, short ks); static void do_keyboard_special(short ks);
static void do_mouse(_THIS, short mx, short my, short mb);


/* Functions */ /* Functions */


Expand All @@ -68,13 +69,13 @@ void GEM_InitOSKeymap(_THIS)


void GEM_PumpEvents(_THIS) void GEM_PumpEvents(_THIS)
{ {
short prevkc, prevks; short prevkc;
static short maskmouseb=0; static short maskmouseb=0;
int i; int i;
SDL_keysym keysym; SDL_keysym keysym;


SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard)); SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));
prevkc = prevks = 0; prevkc = 0;


for (;;) for (;;)
{ {
Expand Down Expand Up @@ -110,15 +111,18 @@ void GEM_PumpEvents(_THIS)
if (resultat & MU_MESAG) if (resultat & MU_MESAG)
quit = do_messages(this, buffer); quit = do_messages(this, buffer);


/* Special keys ? */
if (resultat & (MU_KEYBD|MU_BUTTON))
do_keyboard_special(kstate);

/* Keyboard event ? */ /* Keyboard event ? */
if (resultat & MU_KEYBD) { if (resultat & MU_KEYBD) {
if ((prevkc != kc) || (prevks != kstate)) { if (prevkc != kc) {
do_keyboard(kc,kstate); do_keyboard(kc);
prevkc = kc; prevkc = kc;
prevks = ks;
} else { } else {
/* Avoid looping, if repeating same key */ /* Avoid looping, if repeating same key */
break; quit = 1;
} }
} }


Expand All @@ -134,7 +138,7 @@ void GEM_PumpEvents(_THIS)


/* Mouse button event ? */ /* Mouse button event ? */
if (resultat & MU_BUTTON) { if (resultat & MU_BUTTON) {
do_mouse(this, mousex, mousey, mouseb, kstate); do_mouse(this, mousex, mousey, mouseb);
maskmouseb = mouseb & 7; maskmouseb = mouseb & 7;
} }


Expand Down Expand Up @@ -277,15 +281,18 @@ static int do_messages(_THIS, short *message)
return quit; return quit;
} }


static void do_keyboard(short kc, short ks) static void do_keyboard(short kc)
{ {
int scancode; int scancode;


if (kc) { if (kc) {
scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1); scancode=(kc>>8) & (ATARIBIOS_MAXKEYS-1);
gem_currentkeyboard[scancode]=0xFF; gem_currentkeyboard[scancode]=0xFF;
} }
}


static void do_keyboard_special(short ks)
{
/* Read special keys */ /* Read special keys */
if (ks & K_RSHIFT) if (ks & K_RSHIFT)
gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF; gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
Expand All @@ -297,7 +304,7 @@ static void do_keyboard(short kc, short ks)
gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF; gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
} }


static void do_mouse(_THIS, short mx, short my, short mb, short ks) static void do_mouse(_THIS, short mx, short my, short mb)
{ {
static short prevmousex=0, prevmousey=0, prevmouseb=0; static short prevmousex=0, prevmousey=0, prevmouseb=0;
short x2, y2, w2, h2; short x2, y2, w2, h2;
Expand Down Expand Up @@ -364,14 +371,4 @@ static void do_mouse(_THIS, short mx, short my, short mb, short ks)
} }
prevmouseb = mb; prevmouseb = mb;
} }

/* Read special keys */
if (ks & K_RSHIFT)
gem_currentkeyboard[SCANCODE_RIGHTSHIFT]=0xFF;
if (ks & K_LSHIFT)
gem_currentkeyboard[SCANCODE_LEFTSHIFT]=0xFF;
if (ks & K_CTRL)
gem_currentkeyboard[SCANCODE_LEFTCONTROL]=0xFF;
if (ks & K_ALT)
gem_currentkeyboard[SCANCODE_LEFTALT]=0xFF;
} }

0 comments on commit 5b04bda

Please sign in to comment.