Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=documentation gsoc2008_manymouse
authorSzymon Wilczek
Sun, 06 Jul 2008 09:24:56 +0000
branchgsoc2008_manymouse
changeset 376624db5d326f57
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
     1.1 --- a/include/SDL_events.h	Sat Jul 05 20:02:07 2008 +0000
     1.2 +++ b/include/SDL_events.h	Sun Jul 06 09:24:56 2008 +0000
     1.3 @@ -176,6 +176,8 @@
     1.4      int y;                  /**< Y coordinate, relative to window */
     1.5      int z;                  /**< Z coordinate, for future use*/
     1.6      int pressure;           /**< Pressure reported by tablets */
     1.7 +    int pressure_max;       /**< Maximum value of the pressure reported by the device*/
     1.8 +    int pressure_min;       /**< Minimum value of the pressure reported by the device*/
     1.9      int rotation;           /**<For future use */
    1.10      int tilt;               /**<For future use */
    1.11      int xrel;               /**< The relative motion in the X direction */
     2.1 --- a/src/events/SDL_mouse.c	Sat Jul 05 20:02:07 2008 +0000
     2.2 +++ b/src/events/SDL_mouse.c	Sun Jul 06 09:24:56 2008 +0000
     2.3 @@ -52,7 +52,7 @@
     2.4  }
     2.5  
     2.6  int
     2.7 -SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name)
     2.8 +SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,int pressure_min)
     2.9  {
    2.10      SDL_Mouse **mice;
    2.11      int selected_mouse;
    2.12 @@ -78,6 +78,8 @@
    2.13      *SDL_mice[index] = *mouse;
    2.14      SDL_mice[index]->name=SDL_malloc(strlen(name)*sizeof(char));
    2.15      strcpy(SDL_mice[index]->name,name);
    2.16 +    SDL_mice[index]->pressure_max=pressure_max;
    2.17 +    SDL_mice[index]->pressure_min=pressure_min;
    2.18      SDL_mice[index]->cursor_shown = SDL_TRUE;
    2.19      selected_mouse = SDL_SelectMouse(index);
    2.20      SDL_mice[index]->cur_cursor = NULL;
    2.21 @@ -368,8 +370,6 @@
    2.22          /* Push the cursor around */
    2.23          xrel = x - last_x;
    2.24          yrel = y - last_y;
    2.25 -        //x = (mouse->x + xrel);
    2.26 -        //y = (mouse->y + yrel);
    2.27      } else {
    2.28          xrel = x - last_x;
    2.29          yrel = y - last_y;
    2.30 @@ -438,6 +438,8 @@
    2.31          event.motion.xrel = xrel;
    2.32          event.motion.yrel = yrel;
    2.33          event.motion.windowID = mouse->focus;
    2.34 +        event.motion.pressure_max=mouse->pressure_max;
    2.35 +        event.motion.pressure_min=mouse->pressure_min;
    2.36          posted = (SDL_PushEvent(&event) > 0);
    2.37      }
    2.38      last_x=x;
     3.1 --- a/src/events/SDL_mouse_c.h	Sat Jul 05 20:02:07 2008 +0000
     3.2 +++ b/src/events/SDL_mouse_c.h	Sun Jul 06 09:24:56 2008 +0000
     3.3 @@ -65,6 +65,8 @@
     3.4      int xdelta;
     3.5      int ydelta;
     3.6      int pressure;
     3.7 +    int pressure_max;
     3.8 +    int pressure_min;
     3.9      int tilt;/*for future use*/
    3.10      int rotation;/*for future use*/
    3.11      char* name;
    3.12 @@ -91,7 +93,7 @@
    3.13  /* Add a mouse, possibly reattaching at a particular index (or -1),
    3.14     returning the index of the mouse, or -1 if there was an error.
    3.15   */
    3.16 -extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name);
    3.17 +extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name, int pressure_max, int pressure_min);
    3.18  
    3.19  /* Remove a mouse at an index, clearing the slot for later */
    3.20  extern void SDL_DelMouse(int index);
     4.1 --- a/src/video/x11/SDL_x11mouse.c	Sat Jul 05 20:02:07 2008 +0000
     4.2 +++ b/src/video/x11/SDL_x11mouse.c	Sun Jul 06 09:24:56 2008 +0000
     4.3 @@ -47,6 +47,7 @@
     4.4              {
     4.5                  if(deviceClass->class==ValuatorClass)
     4.6                  {
     4.7 +                    XValuatorInfo* valInfo;
     4.8                      newDevices= (XDevice**) SDL_realloc(SDL_XDevices, (index+1)*sizeof(*newDevices));
     4.9                      if(!newDevices)
    4.10                      {
    4.11 @@ -58,7 +59,15 @@
    4.12                      SDL_Mouse mouse;
    4.13                      SDL_zero(mouse);
    4.14                      SDL_SetIndexId(DevList[i].id,index);
    4.15 -                    data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name);
    4.16 +                    valInfo=(XValuatorInfo*)deviceClass;
    4.17 +                    if(valInfo->num_axes>2)
    4.18 +                    {
    4.19 +                        data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,valInfo->axes[2].max_value,valInfo->axes[2].min_value);
    4.20 +                    }
    4.21 +                    else
    4.22 +                    {
    4.23 +                         data->mouse = SDL_AddMouse(&mouse, index++,DevList[i].name,0,0);
    4.24 +                    }
    4.25                      break;
    4.26                  }
    4.27                  deviceClass=(XAnyClassPtr)((char*)deviceClass + deviceClass->length);