Use proper GEM API to handle mouse button events SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Fri, 09 Jul 2010 17:19:18 +0200
branchSDL-1.2
changeset 45645002d6aeb85c
parent 4557 4aa31b9207f2
child 4888 46fb637777ed
Use proper GEM API to handle mouse button events
src/video/gem/SDL_gemevents.c
     1.1 --- a/src/video/gem/SDL_gemevents.c	Tue Jul 20 00:01:26 2010 -0700
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Fri Jul 09 17:19:18 2010 +0200
     1.3 @@ -67,25 +67,27 @@
     1.4  
     1.5  void GEM_PumpEvents(_THIS)
     1.6  {
     1.7 -	short mousex, mousey, mouseb, dummy;
     1.8 -	short kstate, prevkc, prevks;
     1.9 +	short prevkc, prevks;
    1.10 +	static short maskmouseb=0;
    1.11  	int i;
    1.12  	SDL_keysym	keysym;
    1.13  
    1.14  	SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));
    1.15  	prevkc = prevks = 0;
    1.16 -	
    1.17 +
    1.18  	for (;;)
    1.19  	{
    1.20  		int quit, resultat, event_mask, mouse_event;
    1.21  		short buffer[8], kc;
    1.22  		short x2,y2,w2,h2;
    1.23 +		short mousex, mousey, mouseb, dummy;
    1.24 +		short kstate;
    1.25  
    1.26  		quit =
    1.27  			mouse_event =
    1.28  			x2=y2=w2=h2 = 0;
    1.29  
    1.30 -		event_mask = MU_MESAG|MU_TIMER|MU_KEYBD;
    1.31 +		event_mask = MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON;
    1.32  		if (!GEM_fullscreen && (GEM_handle>=0)) {
    1.33  			wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.34  			event_mask |= MU_M1;
    1.35 @@ -95,12 +97,12 @@
    1.36  
    1.37  		resultat = evnt_multi(
    1.38  			event_mask,
    1.39 -			0,0,0,
    1.40 +			0x101,7,maskmouseb,
    1.41  			mouse_event,x2,y2,w2,h2,
    1.42  			0,0,0,0,0,
    1.43  			buffer,
    1.44  			10,
    1.45 -			&dummy,&dummy,&dummy,&kstate,&kc,&dummy
    1.46 +			&mousex,&mousey,&mouseb,&kstate,&kc,&dummy
    1.47  		);
    1.48  
    1.49  		/* Message event ? */
    1.50 @@ -127,15 +129,17 @@
    1.51  			GEM_CheckMouseMode(this);
    1.52  		}
    1.53  
    1.54 +		/* Mouse button event ? */
    1.55 +		if (resultat & MU_BUTTON) {
    1.56 +			do_mouse(this, mousex, mousey, mouseb, kstate);
    1.57 +			maskmouseb = mouseb & 7;
    1.58 +		}
    1.59 +
    1.60  		/* Timer event ? */
    1.61  		if ((resultat & MU_TIMER) || quit)
    1.62  			break;
    1.63  	}
    1.64  
    1.65 -	/* Update mouse */
    1.66 -	graf_mkstate(&mousex, &mousey, &mouseb, &kstate);
    1.67 -	do_mouse(this, mousex, mousey, mouseb, kstate);
    1.68 -
    1.69  	/* Now generate keyboard events */
    1.70  	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
    1.71  		/* Key pressed ? */
    1.72 @@ -342,7 +346,7 @@
    1.73  	if (prevmouseb!=mb) {
    1.74  		int i;
    1.75  
    1.76 -		for (i=0;i<2;i++) {
    1.77 +		for (i=0;i<3;i++) {
    1.78  			int curbutton, prevbutton;
    1.79  		
    1.80  			curbutton = mb & (1<<i);