Why RelativeMouse is Broken Everywhere

Apologies for the flood, but I’m starting to understand what is up
here. It seems SDL 1.3 has it’s own cursor system, and what
relativemousemode does is keep that relative. This is good, but without
the “real” cursor being relative, all relative mouse movements – for
things like fps, etc – is completely broken. The reason is the cursor
eventually gets hung up on an edge and stops sending mouse move events.

I came up with a quick and dirty fix for win32, I’ll look at OS X
tonight. Again, I’m flying by the seat of my pants guessing what needs
to be done and not affect other items!

Here is a fix for the windows version, in the file SDL_win32events.c, in
the function WIN_WindowProc:

Old code:==========================



case WM_MOUSEMOVE:


SDL_SendMouseMotion(data->window, 0, x, y);
break;

==========================

Change this too:

( add int x,y,cx,cy and POINT pt to top of function)

case WM_MOUSEMOVE:


x=LOWORD(lParam);
y=HIWORD(lParam);
cx=data->window->w>>1;
cy=data->window->h>>1;

     if (SDL_GetRelativeMouseMode()) {    // NOTE: It'd be better to 

go right into the SDL_Mouse structure here, but it’s defined in a C file
// so I can’t access it
if ((x==cx) && (y==cy)) break;
}

    SDL_SendMouseMotion(data->window, 1, (x-cx), (y-cy));

    if (SDL_GetRelativeMouseMode()) {     // NOTE: same here, as 

above, this call is wasted, the SDL_Mouse struct needs to be moved to a
h file
pt.x=cx;
pt.y=cy;
ClientToScreen(hwnd,&pt);
SetCursorPos(pt.x,pt.y);
}

I had to change it to relative movement or else it breaks further down
the line. Note that windows sending the setcursorpos back around is
problematic and the solution is something everybody uses but actually
hangs the cursor on a single pixel. A more complicated solution could
be thought up.

Further thoughts: There’s probably a bunch of stuff tied into the SDL
cursor system that can be removed (i.e., relative stuff, and some stuff
I noticed that was commented out) after a fix like this.

Can somebody please comment on patching this or something like it, and
the other things I’ve posted? My code is getting further and further
away from the tip and messier and messier as I experiment with the code.

[>] Brian

I haven’t adequately found a OS X version for this, there’s something going on inside SDL that I don’t understand that’s catching me. If the OS X guy sees this, I’m basically doing this:

	pt.x=window->w>>1;
	pt.y=window->h>>1;
	
	nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
	pt=[nswindow convertBaseToScreen:pt];

	cgpt.x=pt.x;
	cgpt.y=pt.y;
	CGWarpMouseCursorPosition(cgpt);

To recenter the mouse cursor in the window.

The more I think about this, the more I think there should probably be a native mouse warp function in SDL_VideoDevice, and the cursor re-centering in SDL_SendMouseMotion. I tried to implement something like this, but on some platforms I was getting weird results, it’s just that I don’t understand all the separate mouse data that’s being kept.

[>] Brian