Skip to content

Commit

Permalink
gem: move some variables, and remove duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Nov 4, 2012
1 parent 3e8833e commit 7000a49
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/video/gem/SDL_gemevents.c
Expand Up @@ -47,6 +47,8 @@
static unsigned char gem_currentkeyboard[ATARIBIOS_MAXKEYS];
static unsigned char gem_previouskeyboard[ATARIBIOS_MAXKEYS];

static short prevmx=0,prevmy=0,prevmb=0;

/* Functions prototypes */

static int do_messages(_THIS, short *message);
Expand All @@ -71,19 +73,16 @@ void GEM_InitOSKeymap(_THIS)

void GEM_PumpEvents(_THIS)
{
short prevkc=0;
static short prevmx=0, prevmy=0, prevmb=0;
short prevkc=0, mousex, mousey, mouseb, kstate;
int i;
SDL_keysym keysym;
SDL_keysym keysym;

SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));

for (;;)
{
int quit, resultat;
short buffer[8], kc;
short mousex, mousey, mouseb, dummy;
short kstate;
short buffer[8], kc, dummy;

quit = 0;

Expand Down Expand Up @@ -303,7 +302,6 @@ static void do_keyboard_special(short ks)

static void do_mouse_motion(_THIS, short mx, short my)
{
static short prevmousex=0, prevmousey=0;
short x2, y2, w2, h2;

/* Don't return mouse events if out of window */
Expand All @@ -329,7 +327,7 @@ static void do_mouse_motion(_THIS, short mx, short my)
wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
}

if ((prevmousex!=mx) || (prevmousey!=my)) {
if ((prevmx!=mx) || (prevmy!=my)) {
int posx, posy;

/* Give mouse position relative to window position */
Expand All @@ -342,27 +340,27 @@ static void do_mouse_motion(_THIS, short mx, short my)

SDL_PrivateMouseMotion(0, 0, posx, posy);
}
prevmousex = mx;
prevmousey = my;

prevmx = mx;
prevmy = my;
}

static void do_mouse_buttons(_THIS, short mb)
{
static short prevmouseb=0;
int i;

/* Don't return mouse events if out of window */
if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)==0)
return;

if (prevmouseb==mb)
if (prevmb==mb)
return;

for (i=0;i<3;i++) {
int curbutton, prevbutton;

curbutton = mb & (1<<i);
prevbutton = prevmouseb & (1<<i);
prevbutton = prevmb & (1<<i);

if (curbutton && !prevbutton) {
SDL_PrivateMouseButton(SDL_PRESSED, i+1, 0, 0);
Expand All @@ -372,7 +370,7 @@ static void do_mouse_buttons(_THIS, short mb)
}
}

prevmouseb = mb;
prevmb = mb;
}

/* Check if mouse in visible area of the window */
Expand Down

0 comments on commit 7000a49

Please sign in to comment.