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

Commit

Permalink
Browse files Browse the repository at this point in the history
Implementation finished
  • Loading branch information
Szymon Wilczek committed Jul 31, 2008
1 parent d6a836e commit 8032bc1
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 287 deletions.
2 changes: 2 additions & 0 deletions src/events/SDL_mouse.c
Expand Up @@ -330,6 +330,8 @@ SDL_SendProximity(int id, int x, int y, int type)
{
int index=SDL_GetIndexById(id);
int posted=0;
last_x=x;
last_y=y;
if(SDL_ProcessEvents[type]==SDL_ENABLE)
{
SDL_Event event;
Expand Down
107 changes: 22 additions & 85 deletions src/video/win32/SDL_win32events.c
Expand Up @@ -62,6 +62,7 @@
extern HCTX* g_hCtx;
extern HANDLE* mice;
extern int total_mice;
extern int tablet;

int pressure=0;

Expand Down Expand Up @@ -146,13 +147,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case WT_PROXIMITY:
{
int h_context=LOWORD(lParam);
LPPOINT point;
GetCursorPos(&point);
ScreenToClient(hwnd, &point);
if(h_context==0)
{
SDL_SendProximity(0, 0, 0, SDL_PROXIMITYOUT);
SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYOUT);
}
else
{
SDL_SendProximity(0, 0, 0, SDL_PROXIMITYIN);
SDL_SendProximity(tablet, (int)(&point->x),(int)(&point->y), SDL_PROXIMITYIN);
}
}
break;
Expand Down Expand Up @@ -202,74 +206,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return (0);
}
break;
case WT_CTXOPEN:
{
SDL_SendMouseMotion(0,1,1,0,0);
SDL_SendMouseMotion(0,1,-1,0,0);
}
/*case WM_MOUSEMOVE:
{
LPBYTE lpb;
const RAWINPUTHEADER *header;
int index;
int i;
int size=0;
SDL_Mouse *mouse;
int x, y;
//index = data->videodata->mouse;
GetRawInputData((HRAWINPUT) lParam, RID_INPUT, NULL, &size, sizeof (RAWINPUTHEADER));
lpb = SDL_malloc(size*sizeof(LPBYTE));
GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER));
raw = (RAWINPUT *) lpb;
header = &raw->header;
for(i=0;i<total_mice;++i)
{
if(mice[i]==header->hDevice)
{
index=i;
break;
}
}
mouse = SDL_GetMouse(index);
if (mouse->focus != data->windowID) {
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
TrackMouseEvent(&tme);
SDL_SetMouseFocus(index, data->windowID);
}
/* mouse has moved within the window */
//x = LOWORD(lParam);
//y = HIWORD(lParam);
//printf("index: %d\n",index);
/*if (WTPacketsPeek(g_hCtx[data->windowID],1,&packet))
{
pressure=(int)packet.pkNormalPressure;
}*/
/*if (mouse->relative_mode) {
int w, h;
POINT center;
SDL_GetWindowSize(data->windowID, &w, &h);
center.x = (w / 2);
center.y = (h / 2);
x -= center.x;
y -= center.y;
if (x || y) {
ClientToScreen(hwnd, &center);
SetCursorPos(center.x, center.y);
SDL_SendMouseMotion(index, 1, x, y,pressure);
}
} else {
SDL_SendMouseMotion(index, 0, x, y,pressure);
}
}
return (0);*/
case WM_INPUT:
{
LPBYTE lpb;
Expand All @@ -287,7 +223,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
GetRawInputData((HRAWINPUT) lParam, RID_INPUT, lpb, &size, sizeof (RAWINPUTHEADER));
raw = (RAWINPUT *) lpb;
header = &raw->header;
//raw_mouse=&raw->data.mouse;
flags=raw->data.mouse.usButtonFlags;
for(i=0;i<total_mice;++i)
{
Expand All @@ -302,7 +237,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
ScreenToClient(hwnd, &point);
SDL_GetWindowSize(data->windowID, &w, &h);
SDL_UpdateCoordinates(w,h);
SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure);
if(i==tablet)
{
SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),pressure);
}
else
{
SDL_SendMouseMotion(index,0,(int)(&point->x),(int)(&point->y),0);
}
if(flags & RI_MOUSE_BUTTON_1_DOWN)
{
SDL_SendMouseButton(index,SDL_PRESSED,SDL_BUTTON_LEFT);
Expand All @@ -327,6 +269,13 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
SDL_SendMouseButton(index,SDL_RELEASED,SDL_BUTTON_RIGHT);
}
if(flags & RI_MOUSE_WHEEL)
{
if(raw->data.mouse.usButtonData!=0)
{
SDL_SendMouseWheel(index, 0, raw->data.mouse.usButtonData);
}
}
}
return(0);
case WM_MOUSELEAVE:
Expand All @@ -342,19 +291,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}
return (0);



/* case WM_MOUSEWHEEL:
{
int index;
int motion = (short) HIWORD(wParam);
index = data->videodata->mouse;
SDL_SendMouseWheel(index, 0, motion);
}
return (0);*/

case WM_SYSKEYDOWN:
case WM_KEYDOWN:
{
Expand Down Expand Up @@ -743,3 +679,4 @@ WIN_SetError(const char *prefix)
}

/* vi: set ts=4 sw=4 expandtab: */

60 changes: 42 additions & 18 deletions src/video/win32/SDL_win32mouse.c
Expand Up @@ -31,13 +31,16 @@

#include "../../events/SDL_mouse_c.h"

extern int total_mice;
#include <wintab.h>
#define PACKETDATA ( PK_X | PK_Y | PK_BUTTONS | PK_NORMAL_PRESSURE)
#define PACKETMODE 0
#include <pktdef.h>

extern HANDLE* mice;

extern int total_mice;

RAWINPUTDEVICE *Rid=NULL;
extern int tablet;

void
WIN_InitMouse(_THIS)
Expand All @@ -48,6 +51,7 @@ WIN_InitMouse(_THIS)
int i;
int tmp=0;
char* buffer=NULL;
char* tab="wacom";

SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;

Expand All @@ -67,6 +71,7 @@ WIN_InitMouse(_THIS)
for(i=0;i<devCount;++i)
{
int j;
int k;
char *default_device_name="Pointing device xx";
const char *reg_key_root = "System\\CurrentControlSet\\Enum\\";
char *device_name=SDL_malloc(256*sizeof(char));
Expand All @@ -77,6 +82,7 @@ WIN_InitMouse(_THIS)
DWORD regtype = REG_SZ;
DWORD out=256*sizeof(char);
SDL_Mouse mouse;
int l;
if(deviceList[i].dwType!=RIM_TYPEMOUSE)
{
continue;
Expand Down Expand Up @@ -117,35 +123,53 @@ WIN_InitMouse(_THIS)
rc = RegOpenKeyExA(HKEY_LOCAL_MACHINE, key_name, 0, KEY_READ, &hkey);

if (rc != ERROR_SUCCESS)
return;
{
SDL_memcpy(device_name, default_device_name, SDL_strlen(default_device_name));
}

rc = RegQueryValueExA(hkey, "DeviceDesc", NULL, &regtype, device_name, &out);
RegCloseKey(hkey);
if (rc != ERROR_SUCCESS)
{
return;
//SDL_memcpy(device_name, default_device_name, SDL_strlen(default_device_name));
SDL_memcpy(device_name, default_device_name, SDL_strlen(default_device_name));
}
//device_name[254] = '\0';

mice[index]=deviceList[i].hDevice;
SDL_zero(mouse);
SDL_SetIndexId(index,index);
data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0);
//data->mouse = SDL_AddMouse(&mouse, index,key_name,0,0);
l=SDL_strlen(device_name);
if(tablet==-1)
{
for(j=0;j<l-5;++j)
{
for(k=0;k<5;++k)
{
if(tab[k]!=SDL_tolower((unsigned char)device_name[j+k]))
{
break;
}
}
if(k==5)
{
tablet=index;
break;
}
}
}
if(tablet==index)
{
AXIS pressure;
WTInfo(WTI_DEVICES,DVC_NPRESSURE, &pressure);
data->mouse = SDL_AddMouse(&mouse, index,device_name,pressure.axMax,pressure.axMin);
}
else
{
data->mouse = SDL_AddMouse(&mouse, index,device_name,0,0);
}
++index;

SDL_free(buffer);
SDL_free(key_name);
}
Rid = SDL_malloc(sizeof(RAWINPUTDEVICE));
/*Rid[0].usUsagePage = 0x01;
Rid[0].usUsage = 0x02;
Rid[0].dwFlags = RIDEV_INPUTSINK; // adds HID mouse and also ignores legacy mouse messages
Rid[0].hwndTarget = NULL;
RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]));*/

total_mice=index;
SDL_free(deviceList);
}
Expand All @@ -159,7 +183,7 @@ WIN_QuitMouse(_THIS)
{
SDL_DelMouse(i);
}
SDL_free(Rid);
}

/* vi: set ts=4 sw=4 expandtab: */

0 comments on commit 8032bc1

Please sign in to comment.