From a6ec94a8717ba8e6714278fcd6e23ec832cbdfe4 Mon Sep 17 00:00:00 2001 From: Szymon Wilczek Date: Sun, 6 Jul 2008 09:24:56 +0000 Subject: [PATCH] Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation --- include/SDL_events.h | 2 ++ src/events/SDL_mouse.c | 8 +++++--- src/events/SDL_mouse_c.h | 4 +++- src/video/x11/SDL_x11mouse.c | 11 ++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index 81faf13fa..11ce4470d 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -176,6 +176,8 @@ typedef struct SDL_MouseMotionEvent int y; /**< Y coordinate, relative to window */ int z; /**< Z coordinate, for future use*/ int pressure; /**< Pressure reported by tablets */ + int pressure_max; /**< Maximum value of the pressure reported by the device*/ + int pressure_min; /**< Minimum value of the pressure reported by the device*/ int rotation; /**name=SDL_malloc(strlen(name)*sizeof(char)); strcpy(SDL_mice[index]->name,name); + SDL_mice[index]->pressure_max=pressure_max; + SDL_mice[index]->pressure_min=pressure_min; SDL_mice[index]->cursor_shown = SDL_TRUE; selected_mouse = SDL_SelectMouse(index); SDL_mice[index]->cur_cursor = NULL; @@ -368,8 +370,6 @@ SDL_SendMouseMotion(int id, int relative, int x, int y,int z) /* Push the cursor around */ xrel = x - last_x; yrel = y - last_y; - //x = (mouse->x + xrel); - //y = (mouse->y + yrel); } else { xrel = x - last_x; yrel = y - last_y; @@ -438,6 +438,8 @@ event.motion.which = (Uint8) index; event.motion.xrel = xrel; event.motion.yrel = yrel; event.motion.windowID = mouse->focus; + event.motion.pressure_max=mouse->pressure_max; + event.motion.pressure_min=mouse->pressure_min; posted = (SDL_PushEvent(&event) > 0); } last_x=x; diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 8a3c595a4..85a35b081 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -65,6 +65,8 @@ struct SDL_Mouse int xdelta; int ydelta; int pressure; + int pressure_max; + int pressure_min; int tilt;/*for future use*/ int rotation;/*for future use*/ char* name; @@ -91,7 +93,7 @@ extern SDL_Mouse *SDL_GetMouse(int index); /* Add a mouse, possibly reattaching at a particular index (or -1), returning the index of the mouse, or -1 if there was an error. */ -extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name); +extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name, int pressure_max, int pressure_min); /* Remove a mouse at an index, clearing the slot for later */ extern void SDL_DelMouse(int index); diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index e3ac90bde..fa27f4f63 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -47,6 +47,7 @@ X11_InitMouse(_THIS) { if(deviceClass->class==ValuatorClass) { + XValuatorInfo* valInfo; newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices)); if(!newDevices) { @@ -58,7 +59,15 @@ X11_InitMouse(_THIS) SDL_Mouse mouse; SDL_zero(mouse); SDL_SetIndexId(DevList[i].id,index); - data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name); + valInfo=(XValuatorInfo*)deviceClass; + if(valInfo->num_axes>2) + { + data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,valInfo->axes[2].max_value,valInfo->axes[2].min_value); + } + else + { + data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,0,0); + } break; } deviceClass=(XAnyClassPtr)((char*)deviceClass + deviceClass->length);