Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
First comments and code upgrades in X11
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Wilczek committed Aug 2, 2008
1 parent a110d66 commit 27a9875
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
23 changes: 5 additions & 18 deletions src/video/x11/SDL_x11events.c
Expand Up @@ -29,16 +29,11 @@
#include "SDL_x11video.h"
#include "../../events/SDL_events_c.h"

//XEventClass *SDL_XEvents;
//int SDL_numOfEvents;

extern int motion;
extern int button_pressed;
extern int button_released;
extern int proximity_in;
extern int proximity_out;
extern int x_max,y_max;

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)
Expand All @@ -47,9 +42,6 @@ X11_DispatchEvent(_THIS)
SDL_WindowData *data;
XEvent xevent;
int i,z;
//extern int motion;
//extern int button_pressed;
//extern int button_released;

SDL_zero(xevent); /* valgrind fix. --ryan. */
XNextEvent(videodata->display, &xevent);
Expand All @@ -67,7 +59,6 @@ X11_DispatchEvent(_THIS)
/* Send a SDL_SYSWMEVENT if the application wants them */
if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
SDL_SysWMmsg wmmsg;

SDL_VERSION(&wmmsg.version);
wmmsg.subsystem = SDL_SYSWM_X11;
wmmsg.event.xevent = xevent;
Expand Down Expand Up @@ -127,8 +118,6 @@ X11_DispatchEvent(_THIS)
(xevent.xcrossing.mode != NotifyUngrab) &&
(xevent.xcrossing.detail != NotifyInferior)) {
XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
//SDL_SendMouseMotion(move->deviceid, 0,
// move->x, move->y,move->axis_data[2]);
SDL_SetMouseFocus(move->deviceid, 0);
}
}
Expand Down Expand Up @@ -300,8 +289,6 @@ X11_DispatchEvent(_THIS)
#endif
XWindowAttributes attrib;
XGetWindowAttributes(videodata->display, ((XAnyEvent*)&xevent)->window, &attrib);
/*x_max=attrib.width;
y_max=attrib.height;*/
SDL_UpdateCoordinates(attrib.width, attrib.height);
XDeviceMotionEvent* move=(XDeviceMotionEvent*)&xevent;
SDL_SendMouseMotion(move->deviceid, 0, move->x,
Expand Down
20 changes: 17 additions & 3 deletions src/video/x11/SDL_x11mouse.c
Expand Up @@ -35,19 +35,26 @@ X11_InitMouse(_THIS)
XDeviceInfo *DevList;
XAnyClassPtr deviceClass;
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;


/*we're getting the list of input devices*/
DevList=XListInputDevices(data->display, &numOfDevices);
SDL_XDevices=(XDevice**) SDL_malloc(sizeof(XDevice));

/*we're aquiring valuators:mices, tablets, etc.*/
for(i=0;i<numOfDevices;++i)
{
/*if it's the core pointer or core keyborard we don't want it*/
if((DevList[i].use!=IsXPointer && DevList[i].use!=IsXKeyboard))
{
/*we have to check all of the device classes*/
deviceClass=DevList[i].inputclassinfo;
for(j=0;j<DevList[i].num_classes;++j)
{
if(deviceClass->class==ValuatorClass)
if(deviceClass->class==ValuatorClass)/*bingo;)*/
{
XValuatorInfo* valInfo;
SDL_Mouse mouse;

newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices));
if(!newDevices)
{
Expand All @@ -56,10 +63,14 @@ X11_InitMouse(_THIS)
}
SDL_XDevices=newDevices;
SDL_XDevices[index]=XOpenDevice(data->display,DevList[i].id);
SDL_Mouse mouse;
SDL_zero(mouse);

/*the id of the device differs from its index
*so we're assigning the index of a device to it's id*/
SDL_SetIndexId(DevList[i].id,index);
/*lets get the device parameters*/
valInfo=(XValuatorInfo*)deviceClass;
/*if the device reports pressure, lets check it parameteres*/
if(valInfo->num_axes>2)
{
data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,valInfo->axes[2].max_value,valInfo->axes[2].min_value);
Expand All @@ -70,11 +81,13 @@ X11_InitMouse(_THIS)
}
break;
}
/*if it's not class we're interested in, lets go further*/
deviceClass=(XAnyClassPtr)((char*)deviceClass + deviceClass->length);
}
}
}
XFreeDeviceList(DevList);

SDL_NumOfXDevices=index;
}

Expand All @@ -83,6 +96,7 @@ X11_QuitMouse(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;

/*Lets delete all of the mice*/
SDL_MouseQuit();
}

Expand Down
20 changes: 11 additions & 9 deletions src/video/x11/SDL_x11video.c
Expand Up @@ -27,14 +27,15 @@
#include "../SDL_pixels_c.h"

#include "SDL_x11video.h"
//#include "SDL_d3drender.h"
//#include "SDL_gdirender.h"
/*#include "SDL_d3drender.h"
#include "SDL_gdirender.h"*/

XDevice **SDL_XDevices;
int SDL_NumOfXDevices;
XEventClass SDL_XEvents[256];
int SDL_NumOfXEvents;
int motion, button_pressed, button_released;

int motion, button_pressed, button_released;/*the definitions of the mice events*/
int proximity_in, proximity_out;

/* Initialization/Query functions */
Expand Down Expand Up @@ -249,20 +250,21 @@ X11_VideoInit(_THIS)
return -1;
}
X11_InitMouse(_this);
/*we're generating the table of events that should be recognized*/
for(i=0;i<SDL_NumOfXDevices;++i)
{
DeviceKeyPress(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent) SDL_XEvents[index++] = xEvent;
DeviceKeyRelease(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent) SDL_XEvents[index++] = xEvent;

/* focus events */
/*focus events*/
DeviceFocusIn(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent) SDL_XEvents[index++] = xEvent;
DeviceFocusOut(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent) SDL_XEvents[index++] = xEvent;

/* button events */
/*button events*/
DeviceButtonPress(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent)
{
Expand All @@ -276,7 +278,7 @@ X11_VideoInit(_THIS)
button_released=c_not_needed;
}

/* proximity events */
/*proximity events*/
ProximityIn(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent)
{
Expand All @@ -289,15 +291,15 @@ X11_VideoInit(_THIS)
SDL_XEvents[index++] = xEvent;
proximity_out=c_not_needed;
}
/* motion events */
/*motion events*/
DeviceMotionNotify(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent)
{
SDL_XEvents[index++] = xEvent;
motion=c_not_needed;
}

/* device state */
/*device state*/
DeviceStateNotify(SDL_XDevices[i],c_not_needed,xEvent);
if (xEvent) SDL_XEvents[index++] = xEvent;
DeviceMappingNotify(SDL_XDevices[i],
Expand All @@ -313,7 +315,7 @@ X11_VideoInit(_THIS)
if (xEvent) SDL_XEvents[index++] = xEvent;
#endif

/* button motion */
/*button motion*/
DeviceButtonMotion(SDL_XDevices[i],
c_not_needed,xEvent);
if (xEvent) SDL_XEvents[index++] = xEvent;
Expand Down

0 comments on commit 27a9875

Please sign in to comment.