Hi,
first of all: keep up the good work!
I am involved of developing a 3D OpenGL-application in which we use SFML to handle the windows & mouse/keyboard-events.
During the last few weeks we encountered to major inconveniences when using SFML to process the mouse input. Up front: I was able to fix those (for the win32 implementation) with a tiny bit of hacking in the WindowImplWin32-class.
The first is: We use the mouse to control the camera, whenever the left button is hold down. Now if the user holds down the button, moves out of the window, where he releases the button the window never receives the MouseButtonReleased-Event. If the user now moves back over the window the input-state IsMouseButtonDown still evaluates to true and the camera is moved even if the user does not physically hold down the mouse button.
The second issue was, that if the user controlled the camerea by holding the mouse button down and left the window on the left or top border, the camera would "jump" to some weird orientation.
It would be great if this behaviour could be fixed in a future release, as I feel, that we are not the only ones struggling with it.
We have fixed it for the Win32 implementation, but do not have the knowledge to fix it for any other OS. Our patches so far work very well, but we have not fully tested them yet.
To fix the first issue this we extended the WindowsImplWin32::processEven method tlike this: Whenerver a mousebutton is pressed, we call SetCapture(myHandle) and on release of the mouse button we call ReleaseCapture(). The effect is, that the window receives the buttonUp event, even if the mouse moved outside of it's scope.
The cause for the second issue was, that the Windows-API uses unsigned shorts (16bit / WORD) to determine the position and SFML uses signed ints (32bit / DWORD)s to store the mouseposition. Now whenever the position of the mouse dropped below 0 we got an overflow and a position of 65535 instead of -1.
Simple (but not very elegant solution): cast the position-information from Windows to signed short.
Snippet from "our" WindowImplWin32::processEvent
case WM_LBUTTONDOWN :
{
Event Evt;
SetCapture(myHandle); // <- OUR MODIFICATION
Evt.Type = Event::MouseButtonPressed;
Evt.MouseButton.Button = Mouse::Left;
Evt.MouseButton.X = (short)LOWORD(LParam); // Note the cast to short
Evt.MouseButton.Y = (short)HIWORD(LParam); // Note the cast to short
SendEvent(Evt);
break;
}
// Mouse left button up event
case WM_LBUTTONUP :
{
Event Evt;
Evt.Type = Event::MouseButtonReleased;
Evt.MouseButton.Button = Mouse::Left;
Evt.MouseButton.X = (short)LOWORD(LParam); //Cast to short again
Evt.MouseButton.Y = (short)HIWORD(LParam); //Cast to short again
SendEvent(Evt);
ReleaseCapture(); // OUR MODIFICATION
break;
}
Further info on Win32Notifications and SetCapture():
http://msdn.microsoft.com/en-us/library/ms645608%28VS.85%29.aspxGreets doeme