Mercurial > sdl-ios-xcode
changeset 3774:8b5b67000dc0 gsoc2008_manymouse
Cursor support added
author | Szymon Wilczek <kazeuser@gmail.com> |
---|---|
date | Tue, 05 Aug 2008 14:10:11 +0000 |
parents | 3b5691f85c0d |
children | e5011833348a |
files | 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 |
diffstat | 6 files changed, 42 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/include/SDL_events.h Mon Aug 04 11:18:10 2008 +0000 +++ b/include/SDL_events.h Tue Aug 05 14:10:11 2008 +0000 @@ -180,6 +180,7 @@ int pressure_min; /**< Minimum value of the pressure reported by the device*/ int rotation; /**<For future use */ int tilt; /**<For future use */ + int cursor; /**< The cursor being used in the event */ int xrel; /**< The relative motion in the X direction */ int yrel; /**< The relative motion in the Y direction */ SDL_WindowID windowID; /**< The window with mouse focus, if any */
--- a/include/SDL_mouse.h Mon Aug 04 11:18:10 2008 +0000 +++ b/include/SDL_mouse.h Tue Aug 05 14:10:11 2008 +0000 @@ -208,6 +208,8 @@ extern DECLSPEC char* SDLCALL SDL_GetMouseName(int index); +extern DECLSPEC int SDLCALL SDL_GetCursorsNumber(int index); + #define SDL_BUTTON(X) (1 << ((X)-1)) #define SDL_BUTTON_LEFT 1 #define SDL_BUTTON_MIDDLE 2
--- a/src/events/SDL_mouse.c Mon Aug 04 11:18:10 2008 +0000 +++ b/src/events/SDL_mouse.c Tue Aug 05 14:10:11 2008 +0000 @@ -52,7 +52,8 @@ } int -SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,int pressure_min) +SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,int pressure_max,\ +int pressure_min, int ends) { SDL_Mouse **mice; int selected_mouse; @@ -98,6 +99,8 @@ thanx to that, the users that don't want to use many mouses don't have to worry about anything*/ SDL_mice[index]->relative_mode=SDL_FALSE; + SDL_mice[index]->current_end=0; + SDL_mice[index]->total_ends=ends; SDL_SelectMouse(selected_mouse); return index; @@ -460,6 +463,7 @@ event.motion.windowID = mouse->focus; event.motion.pressure_max=mouse->pressure_max; event.motion.pressure_min=mouse->pressure_min; + event.motion.cursor=SDL_mice[index]->current_end; posted = (SDL_PushEvent(&event) > 0); } last_x=x; @@ -796,5 +800,24 @@ x_max=x; y_max=y; } + +void SDL_ChangeEnd(int id, int end) +{ + int index=SDL_GetIndexById(id); + SDL_mice[index]->current_end=end; +} + +int SDL_GetCursorsNumber(int index) +{ + if(index>=SDL_num_mice) + { + return -1; + } + if(SDL_mice[index]==NULL) + { + return -1; + } + return SDL_mice[index]->total_ends; +} /* vi: set ts=4 sw=4 expandtab: */
--- a/src/events/SDL_mouse_c.h Mon Aug 04 11:18:10 2008 +0000 +++ b/src/events/SDL_mouse_c.h Tue Aug 05 14:10:11 2008 +0000 @@ -62,6 +62,8 @@ int pressure_min; int tilt;/*for future use*/ int rotation;/*for future use*/ + int total_ends; + int current_end; /* Data common to all mice */ SDL_WindowID focus; @@ -96,7 +98,8 @@ /* 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, int pressure_max, int pressure_min); +extern int SDL_AddMouse(const SDL_Mouse * mouse, int index, char* name,\ + int pressure_max, int pressure_min, int ends); /* Remove a mouse at an index, clearing the slot for later */ extern void SDL_DelMouse(int index); @@ -129,6 +132,10 @@ extern void SDL_UpdateCoordinates(int x, int y); +extern void SDL_ChangeEnd(int id, int end); + +extern int SDL_GetCursorsNumber(int index); + #endif /* _SDL_mouse_c_h */ /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/win32/SDL_win32events.c Mon Aug 04 11:18:10 2008 +0000 +++ b/src/video/win32/SDL_win32events.c Tue Aug 05 14:10:11 2008 +0000 @@ -32,7 +32,7 @@ #include "SDL_vkeys.h" #include "../../events/SDL_events_c.h" #include <wintab.h> -#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE) +#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_CURSOR) #define PACKETMODE 0 #include <pktdef.h> @@ -141,6 +141,7 @@ /*if we receive such data we need to update the pressure*/ if (WTPacket((HCTX)lParam, wParam, &packet)) { + SDL_ChangeEnd(tablet, (int)packet.pkCursor); pressure=(int)packet.pkNormalPressure; } }
--- a/src/video/win32/SDL_win32mouse.c Mon Aug 04 11:18:10 2008 +0000 +++ b/src/video/win32/SDL_win32mouse.c Tue Aug 05 14:10:11 2008 +0000 @@ -34,7 +34,7 @@ #include "../../events/SDL_mouse_c.h" #include <wintab.h> -#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE) +#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE | PK_CURSOR) #define PACKETMODE 0 #include <pktdef.h> @@ -176,12 +176,14 @@ if(tablet==index) { AXIS pressure; + int cursors; WTInfo(WTI_DEVICES,DVC_NPRESSURE, &pressure); - data->mouse = SDL_AddMouse(&mouse, index,device_name,pressure.axMax,pressure.axMin); + WTInfo(WTI_DEVICES,DVC_NCSRTYPES, &cursors); + data->mouse = SDL_AddMouse(&mouse, index,device_name,pressure.axMax,pressure.axMin,cursors); } else { - data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0); + data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0,1); } ++index;