Add this just before WM_INPUT in SDL_win32events.c
It gives you relative movement with the mouse with proper Windows Mouse Ballistics. Unfortunately for whoever designed this section of SDL you should not be using RAW INPUT to drive a mouse cursor, which means you can only support one pointer device to move the cursor (in theory windows lets multiple devices move the cursor so it’s not a big issue). However RAWINPUT should be used for any other movement (game/3d movement), so a two pronged approach is needed. I haven’t coded this yet however it should give whoever is in charge of SDL 1.3 an idea about how to tackle this issue.
We need a CURSOR movement AND a mouse movement type event. There is no way you can combine them if you want to use RAWINPUT as it removes the Windows filtering, and the cursor should be maintained at the OS speed not something random.
Code:
case WM_MOUSEMOVE:
{
int x,y,i;
/* mouse has entered the window */
if ( ! in_window )
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
TrackMouseEvent(&tme);
in_window = TRUE;
SDL_SetMouseFocus(0, data->window);
}
/* mouse has moved within the window */
x = LOWORD(lParam);
y = HIWORD(lParam);
if ( 1 ) //relative motion
{
POINT center;
RECT rect;
GetClientRect(hwnd,&rect);
center.x = (rect.right/2);
center.y = (rect.bottom/2);
x -= (Sint16)center.x;
y -= (Sint16)center.y;
if ( x || y )
{
ClientToScreen(hwnd, ¢er);
SetCursorPos(center.x, center.y);
SDL_SendMouseMotion(0, 1, x, y, 0);
}
} else
{
//posted = SDL_PrivateMouseMotion(0, 0, x, y); //do non relative motion here
}
}
break;
There is a bug in SDL_Memset() in sdl_string.c . It doesn’t always clear memory, frankly this code is convoluted and looks like it was written by a high school student. A simple for loop at least wouldn’t be a buggy mess. It won’t take anyone experienced long to see why there is an error in this rather important function.