changeset 4564:5002d6aeb85c SDL-1.2

Use proper GEM API to handle mouse button events
author Patrice Mandin <patmandin@gmail.com>
date Fri, 09 Jul 2010 17:19:18 +0200
parents 4aa31b9207f2
children 46fb637777ed
files src/video/gem/SDL_gemevents.c
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/gem/SDL_gemevents.c	Tue Jul 20 00:01:26 2010 -0700
+++ b/src/video/gem/SDL_gemevents.c	Fri Jul 09 17:19:18 2010 +0200
@@ -67,25 +67,27 @@
 
 void GEM_PumpEvents(_THIS)
 {
-	short mousex, mousey, mouseb, dummy;
-	short kstate, prevkc, prevks;
+	short prevkc, prevks;
+	static short maskmouseb=0;
 	int i;
 	SDL_keysym	keysym;
 
 	SDL_memset(gem_currentkeyboard,0,sizeof(gem_currentkeyboard));
 	prevkc = prevks = 0;
-	
+
 	for (;;)
 	{
 		int quit, resultat, event_mask, mouse_event;
 		short buffer[8], kc;
 		short x2,y2,w2,h2;
+		short mousex, mousey, mouseb, dummy;
+		short kstate;
 
 		quit =
 			mouse_event =
 			x2=y2=w2=h2 = 0;
 
-		event_mask = MU_MESAG|MU_TIMER|MU_KEYBD;
+		event_mask = MU_MESAG|MU_TIMER|MU_KEYBD|MU_BUTTON;
 		if (!GEM_fullscreen && (GEM_handle>=0)) {
 			wind_get (GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
 			event_mask |= MU_M1;
@@ -95,12 +97,12 @@
 
 		resultat = evnt_multi(
 			event_mask,
-			0,0,0,
+			0x101,7,maskmouseb,
 			mouse_event,x2,y2,w2,h2,
 			0,0,0,0,0,
 			buffer,
 			10,
-			&dummy,&dummy,&dummy,&kstate,&kc,&dummy
+			&mousex,&mousey,&mouseb,&kstate,&kc,&dummy
 		);
 
 		/* Message event ? */
@@ -127,15 +129,17 @@
 			GEM_CheckMouseMode(this);
 		}
 
+		/* Mouse button event ? */
+		if (resultat & MU_BUTTON) {
+			do_mouse(this, mousex, mousey, mouseb, kstate);
+			maskmouseb = mouseb & 7;
+		}
+
 		/* Timer event ? */
 		if ((resultat & MU_TIMER) || quit)
 			break;
 	}
 
-	/* Update mouse */
-	graf_mkstate(&mousex, &mousey, &mouseb, &kstate);
-	do_mouse(this, mousex, mousey, mouseb, kstate);
-
 	/* Now generate keyboard events */
 	for (i=0; i<ATARIBIOS_MAXKEYS; i++) {
 		/* Key pressed ? */
@@ -342,7 +346,7 @@
 	if (prevmouseb!=mb) {
 		int i;
 
-		for (i=0;i<2;i++) {
+		for (i=0;i<3;i++) {
 			int curbutton, prevbutton;
 		
 			curbutton = mb & (1<<i);