From 66a97b54e046d0a7e990f3167abd58055f81b36b Mon Sep 17 00:00:00 2001 From: Szymon Wilczek Date: Tue, 5 Aug 2008 14:10:11 +0000 Subject: [PATCH] Cursor support added --- include/SDL_events.h | 1 + include/SDL_mouse.h | 2 ++ src/events/SDL_mouse.c | 25 ++++++++++++++++++++++++- src/events/SDL_mouse_c.h | 9 ++++++++- src/video/win32/SDL_win32events.c | 3 ++- src/video/win32/SDL_win32mouse.c | 8 +++++--- 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/include/SDL_events.h b/include/SDL_events.h index 11ce4470d..b00e7b0fc 100644 --- a/include/SDL_events.h +++ b/include/SDL_events.h @@ -180,6 +180,7 @@ typedef struct SDL_MouseMotionEvent int pressure_min; /**< Minimum value of the pressure reported by the device*/ int rotation; /**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 @@ SDL_SendMouseMotion(int id, int relative, int x, int y,int z) 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 @@ void SDL_UpdateCoordinates(int x, int y) 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: */ diff --git a/src/events/SDL_mouse_c.h b/src/events/SDL_mouse_c.h index 0c4d6b00b..6917a46f6 100644 --- a/src/events/SDL_mouse_c.h +++ b/src/events/SDL_mouse_c.h @@ -62,6 +62,8 @@ struct SDL_Mouse 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 @@ 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, 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 char* SDL_GetMouseName(int index); 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: */ diff --git a/src/video/win32/SDL_win32events.c b/src/video/win32/SDL_win32events.c index df4ebe2a2..0486f4f12 100644 --- a/src/video/win32/SDL_win32events.c +++ b/src/video/win32/SDL_win32events.c @@ -32,7 +32,7 @@ #include "SDL_vkeys.h" #include "../../events/SDL_events_c.h" #include -#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 @@ -141,6 +141,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /*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; } } diff --git a/src/video/win32/SDL_win32mouse.c b/src/video/win32/SDL_win32mouse.c index 115a78993..74b6947de 100644 --- a/src/video/win32/SDL_win32mouse.c +++ b/src/video/win32/SDL_win32mouse.c @@ -34,7 +34,7 @@ #include "../../events/SDL_mouse_c.h" #include -#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 @@ -176,12 +176,14 @@ WIN_InitMouse(_THIS) 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;