Cursor support added gsoc2008_manymouse
authorSzymon Wilczek <kazeuser@gmail.com>
Tue, 05 Aug 2008 14:10:11 +0000
branchgsoc2008_manymouse
changeset 37748b5b67000dc0
parent 3773 3b5691f85c0d
child 3775 e5011833348a
Cursor support added
include/SDL_events.h
include/SDL_mouse.h
src/events/SDL_mouse.c
src/events/SDL_mouse_c.h
src/video/win32/SDL_win32events.c
src/video/win32/SDL_win32mouse.c
     1.1 --- a/include/SDL_events.h	Mon Aug 04 11:18:10 2008 +0000
     1.2 +++ b/include/SDL_events.h	Tue Aug 05 14:10:11 2008 +0000
     1.3 @@ -180,6 +180,7 @@
     1.4      int pressure_min;       /**< Minimum value of the pressure reported by the device*/
     1.5      int rotation;           /**<For future use */
     1.6      int tilt;               /**<For future use */
     1.7 +    int cursor;             /**< The cursor being used in the event */
     1.8      int xrel;               /**< The relative motion in the X direction */
     1.9      int yrel;               /**< The relative motion in the Y direction */
    1.10      SDL_WindowID windowID;  /**< The window with mouse focus, if any */
     2.1 --- a/include/SDL_mouse.h	Mon Aug 04 11:18:10 2008 +0000
     2.2 +++ b/include/SDL_mouse.h	Tue Aug 05 14:10:11 2008 +0000
     2.3 @@ -208,6 +208,8 @@
     2.4  
     2.5  extern DECLSPEC char* SDLCALL SDL_GetMouseName(int index);
     2.6  
     2.7 +extern DECLSPEC int SDLCALL SDL_GetCursorsNumber(int index);
     2.8 +
     2.9  #define SDL_BUTTON(X)		(1 << ((X)-1))
    2.10  #define SDL_BUTTON_LEFT		1
    2.11  #define SDL_BUTTON_MIDDLE	2
     3.1 --- a/src/events/SDL_mouse.c	Mon Aug 04 11:18:10 2008 +0000
     3.2 +++ b/src/events/SDL_mouse.c	Tue Aug 05 14:10:11 2008 +0000
     3.3 @@ -52,7 +52,8 @@
     3.4  }
     3.5  
     3.6  int
     3.7 -SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,int pressure_min)
     3.8 +SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,\
     3.9 +int pressure_min, int ends)
    3.10  {
    3.11      SDL_Mouse **mice;
    3.12      int selected_mouse;
    3.13 @@ -98,6 +99,8 @@
    3.14  	thanx to that, the users that don't want to use many mouses don't have to
    3.15  	worry about anything*/
    3.16      SDL_mice[index]->relative_mode=SDL_FALSE;
    3.17 +    SDL_mice[index]->current_end=0;
    3.18 +    SDL_mice[index]->total_ends=ends;
    3.19      SDL_SelectMouse(selected_mouse);
    3.20  
    3.21      return index;
    3.22 @@ -460,6 +463,7 @@
    3.23          event.motion.windowID = mouse->focus;
    3.24          event.motion.pressure_max=mouse->pressure_max;
    3.25          event.motion.pressure_min=mouse->pressure_min;
    3.26 +		event.motion.cursor=SDL_mice[index]->current_end;
    3.27          posted = (SDL_PushEvent(&event) > 0);
    3.28      }
    3.29      last_x=x;
    3.30 @@ -796,5 +800,24 @@
    3.31      x_max=x;
    3.32      y_max=y;
    3.33  }
    3.34 +
    3.35 +void SDL_ChangeEnd(int id, int end)
    3.36 +{
    3.37 +	int index=SDL_GetIndexById(id);
    3.38 +	SDL_mice[index]->current_end=end;
    3.39 +}
    3.40 +
    3.41 +int SDL_GetCursorsNumber(int index)
    3.42 +{
    3.43 +	if(index>=SDL_num_mice)
    3.44 +	{
    3.45 +		return -1;
    3.46 +	}
    3.47 +	if(SDL_mice[index]==NULL)
    3.48 +	{
    3.49 +		return -1;
    3.50 +	}
    3.51 +	return SDL_mice[index]->total_ends;
    3.52 +}
    3.53  /* vi: set ts=4 sw=4 expandtab: */
    3.54  
     4.1 --- a/src/events/SDL_mouse_c.h	Mon Aug 04 11:18:10 2008 +0000
     4.2 +++ b/src/events/SDL_mouse_c.h	Tue Aug 05 14:10:11 2008 +0000
     4.3 @@ -62,6 +62,8 @@
     4.4      int pressure_min;
     4.5      int tilt;/*for future use*/
     4.6      int rotation;/*for future use*/
     4.7 +    int total_ends;
     4.8 +    int current_end;
     4.9  
    4.10      /* Data common to all mice */
    4.11      SDL_WindowID focus;
    4.12 @@ -96,7 +98,8 @@
    4.13  /* Add a mouse, possibly reattaching at a particular index (or -1),
    4.14     returning the index of the mouse, or -1 if there was an error.
    4.15   */
    4.16 -extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name, int pressure_max, int pressure_min);
    4.17 +extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,\
    4.18 + int pressure_max, int pressure_min, int ends);
    4.19  
    4.20  /* Remove a mouse at an index, clearing the slot for later */
    4.21  extern void SDL_DelMouse(int index);
    4.22 @@ -129,6 +132,10 @@
    4.23  
    4.24  extern void SDL_UpdateCoordinates(int x, int y);
    4.25  
    4.26 +extern void SDL_ChangeEnd(int id, int end);
    4.27 +
    4.28 +extern int SDL_GetCursorsNumber(int index);
    4.29 +
    4.30  #endif /* _SDL_mouse_c_h */
    4.31  
    4.32  /* vi: set ts=4 sw=4 expandtab: */
     5.1 --- a/src/video/win32/SDL_win32events.c	Mon Aug 04 11:18:10 2008 +0000
     5.2 +++ b/src/video/win32/SDL_win32events.c	Tue Aug 05 14:10:11 2008 +0000
     5.3 @@ -32,7 +32,7 @@
     5.4  #include "SDL_vkeys.h"
     5.5  #include "../../events/SDL_events_c.h"
     5.6  #include <wintab.h>
     5.7 -#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE)
     5.8 +#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_CURSOR)
     5.9  #define PACKETMODE 0
    5.10  #include <pktdef.h>
    5.11  
    5.12 @@ -141,6 +141,7 @@
    5.13  			/*if we receive such data we need to update the pressure*/
    5.14  			if (WTPacket((HCTX)lParam, wParam, &packet))
    5.15  			{
    5.16 +				SDL_ChangeEnd(tablet, (int)packet.pkCursor);
    5.17  				pressure=(int)packet.pkNormalPressure;
    5.18  			}
    5.19  		}
     6.1 --- a/src/video/win32/SDL_win32mouse.c	Mon Aug 04 11:18:10 2008 +0000
     6.2 +++ b/src/video/win32/SDL_win32mouse.c	Tue Aug 05 14:10:11 2008 +0000
     6.3 @@ -34,7 +34,7 @@
     6.4  #include "../../events/SDL_mouse_c.h"
     6.5  
     6.6  #include <wintab.h>
     6.7 -#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE)
     6.8 +#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_CURSOR)
     6.9  #define PACKETMODE 0
    6.10  #include <pktdef.h>
    6.11  
    6.12 @@ -176,12 +176,14 @@
    6.13  	if(tablet==index)
    6.14  	{
    6.15  		AXIS pressure;
    6.16 +		int cursors;
    6.17  		WTInfo(WTI_DEVICES,DVC_NPRESSURE, &pressure);
    6.18 -		data->mouse = SDL_AddMouse(&mouse, index,device_name,pressure.axMax,pressure.axMin);
    6.19 +		WTInfo(WTI_DEVICES,DVC_NCSRTYPES, &cursors);
    6.20 +		data->mouse = SDL_AddMouse(&mouse, index,device_name,pressure.axMax,pressure.axMin,cursors);
    6.21  	}
    6.22  	else
    6.23  	{
    6.24 -		data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0);
    6.25 +		data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0,1);
    6.26  	}
    6.27  	++index;
    6.28