Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation gsoc2008_manymouse
authorSzymon Wilczek <kazeuser@gmail.com>
Sun, 06 Jul 2008 09:24:56 +0000
branchgsoc2008_manymouse
changeset 3766 24db5d326f57
parent 3765 ed9b7fe8f902
child 3767 abc8acb8e3d7
Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation
include/SDL_events.h
src/events/SDL_mouse.c
src/events/SDL_mouse_c.h
src/video/x11/SDL_x11mouse.c
--- a/include/SDL_events.h	Sat Jul 05 20:02:07 2008 +0000
+++ b/include/SDL_events.h	Sun Jul 06 09:24:56 2008 +0000
@@ -176,6 +176,8 @@
     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;           /**<For future use */
     int tilt;               /**<For future use */
     int xrel;               /**< The relative motion in the X direction */
--- a/src/events/SDL_mouse.c	Sat Jul 05 20:02:07 2008 +0000
+++ b/src/events/SDL_mouse.c	Sun Jul 06 09:24:56 2008 +0000
@@ -52,7 +52,7 @@
 }
 
 int
-SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name)
+SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,int pressure_min)
 {
     SDL_Mouse **mice;
     int selected_mouse;
@@ -78,6 +78,8 @@
     *SDL_mice[index] = *mouse;
     SDL_mice[index]->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 @@
         /* 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.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;
--- a/src/events/SDL_mouse_c.h	Sat Jul 05 20:02:07 2008 +0000
+++ b/src/events/SDL_mouse_c.h	Sun Jul 06 09:24:56 2008 +0000
@@ -65,6 +65,8 @@
     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 @@
 /* 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);
--- a/src/video/x11/SDL_x11mouse.c	Sat Jul 05 20:02:07 2008 +0000
+++ b/src/video/x11/SDL_x11mouse.c	Sun Jul 06 09:24:56 2008 +0000
@@ -47,6 +47,7 @@
             {
                 if(deviceClass->class==ValuatorClass)
                 {
+                    XValuatorInfo* valInfo;
                     newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices));
                     if(!newDevices)
                     {
@@ -58,7 +59,15 @@
                     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);