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

Commit

Permalink
Pressure levels. Documentation http://wilku.ravenlord.ws/doku.php?id=…
Browse files Browse the repository at this point in the history
  • Loading branch information
Szymon Wilczek committed Jul 6, 2008
1 parent 4f71740 commit a6ec94a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions include/SDL_events.h
Expand Up @@ -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; /**<For future use */
int tilt; /**<For future use */
int xrel; /**< The relative motion in the X direction */
Expand Down
8 changes: 5 additions & 3 deletions src/events/SDL_mouse.c
Expand Up @@ -52,7 +52,7 @@ SDL_GetMouse(int index)
}

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;
Expand All @@ -78,6 +78,8 @@ SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name)
*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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/events/SDL_mouse_c.h
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion src/video/x11/SDL_x11mouse.c
Expand Up @@ -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)
{
Expand All @@ -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);
Expand Down

0 comments on commit a6ec94a

Please sign in to comment.