Final merge of Google Summer of Code 2008 work...

Many-mouse and tablet support
by Szymon Wilczek, mentored by Ryan C. Gordon

Everything concerning the project is noted on the wiki:
http://wilku.ravenlord.ws/doku.php?id=start

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403155
This commit is contained in:
Sam Lantinga 2008-08-25 06:33:00 +00:00
parent 95134b6d3c
commit e7d72614c3
22 changed files with 805 additions and 267 deletions

View file

@ -29,6 +29,12 @@
#include "SDL_x11video.h"
#include "../../events/SDL_events_c.h"
extern int motion; /* the motion event id defined by an XInput function */
extern int button_pressed; /* the button_pressed event id defined by an XInput function */
extern int button_released; /* the button_released event id defined by an XInput function */
extern int proximity_in; /* the proximity in event defined by an XInput function */
extern int proximity_out; /* the proximity out event defined by an XInput function */
static void
X11_DispatchEvent(_THIS)
{
@ -91,9 +97,10 @@ X11_DispatchEvent(_THIS)
#endif
if ((xevent.xcrossing.mode != NotifyGrab) &&
(xevent.xcrossing.mode != NotifyUngrab)) {
SDL_SetMouseFocus(videodata->mouse, data->windowID);
SDL_SendMouseMotion(videodata->mouse, 0, xevent.xcrossing.x,
xevent.xcrossing.y);
XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
SDL_SetMouseFocus(move->deviceid, data->windowID);
SDL_SendMouseMotion(move->deviceid, 0, move->x,
move->y, move->axis_data[2]);
}
}
break;
@ -111,9 +118,8 @@ X11_DispatchEvent(_THIS)
if ((xevent.xcrossing.mode != NotifyGrab) &&
(xevent.xcrossing.mode != NotifyUngrab) &&
(xevent.xcrossing.detail != NotifyInferior)) {
SDL_SendMouseMotion(videodata->mouse, 0,
xevent.xcrossing.x, xevent.xcrossing.y);
SDL_SetMouseFocus(videodata->mouse, 0);
XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
SDL_SetMouseFocus(move->deviceid, 0);
}
}
break;
@ -166,30 +172,6 @@ X11_DispatchEvent(_THIS)
}
break;
/* Mouse motion? */
case MotionNotify:{
#ifdef DEBUG_MOTION
printf("X11 motion: %d,%d\n", xevent.xmotion.x, xevent.xmotion.y);
#endif
SDL_SendMouseMotion(videodata->mouse, 0, xevent.xmotion.x,
xevent.xmotion.y);
}
break;
/* Mouse button press? */
case ButtonPress:{
SDL_SendMouseButton(videodata->mouse, SDL_PRESSED,
xevent.xbutton.button);
}
break;
/* Mouse button release? */
case ButtonRelease:{
SDL_SendMouseButton(videodata->mouse, SDL_RELEASED,
xevent.xbutton.button);
}
break;
/* Key press? */
case KeyPress:{
KeyCode keycode = xevent.xkey.keycode;
@ -301,8 +283,44 @@ X11_DispatchEvent(_THIS)
break;
default:{
if (xevent.type == motion) { /* MotionNotify */
#ifdef DEBUG_MOTION
printf("X11 motion: %d,%d\n", xevent.xmotion.x,
xevent.xmotion.y);
#endif
XWindowAttributes attrib;
XGetWindowAttributes(videodata->display,
((XAnyEvent *) & xevent)->window,
&attrib);
SDL_UpdateCoordinates(attrib.width, attrib.height);
XDeviceMotionEvent *move = (XDeviceMotionEvent *) & xevent;
SDL_SendMouseMotion(move->deviceid, 0, move->x,
move->y, move->axis_data[2]);
} else if (xevent.type == button_pressed) { /* ButtonPress */
XDeviceButtonPressedEvent *pressed =
(XDeviceButtonPressedEvent *) & xevent;
SDL_SendMouseButton(pressed->deviceid, SDL_PRESSED,
pressed->button);
} else if (xevent.type == button_released) { /* ButtonRelease */
XDeviceButtonReleasedEvent *released =
(XDeviceButtonReleasedEvent *) & xevent;
SDL_SendMouseButton(released->deviceid, SDL_RELEASED,
released->button);
} else if (xevent.type == proximity_in) {
XProximityNotifyEvent *proximity =
(XProximityNotifyEvent *) & xevent;
SDL_SendProximity(proximity->deviceid, proximity->x,
proximity->y, SDL_PROXIMITYIN);
} else if (xevent.type == proximity_out) {
XProximityNotifyEvent *proximity =
(XProximityNotifyEvent *) & xevent;
SDL_SendProximity(proximity->deviceid, proximity->x,
proximity->y, SDL_PROXIMITYOUT);
}
#ifdef DEBUG_XEVENTS
printf("Unhandled event %d\n", xevent.type);
else {
printf("Unhandled event %d\n", xevent.type);
}
#endif
}
break;