It seems to work correctly. However, after the user stops holding the button (i.e. I recieve SDL_MOUSEBUTTONUP), the next mouse click doesn't work. For that click, I don't receive a SDL_MOUSEBUTTONDOWN, but I receive a SDL_MOUSEBUTTONUP. It doesn't matter if I click inside or outside of the application, the next mouse click just doesn't work. It starts working after that click, however.
My setup is a bit uncommon (Linux, D programming language + Derelict binding), but I don't think that's causing the problem.
Here's my main loop:
/// Start the rendering loop.
void display()
{
bool cameraMode = false;
while (true)
{
SDL_Event event;
while (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_MOUSEBUTTONDOWN:
writeln("down");
if (event.button.button & SDL_BUTTON(SDL_BUTTON_LEFT))
{
// Start camera rotation mode
cameraMode = true;
SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON);
}
break;
case SDL_MOUSEBUTTONUP:
writeln("up");
if (event.button.button & SDL_BUTTON(SDL_BUTTON_LEFT))
{
// End camera rotation mode
cameraMode = false;
SDL_ShowCursor(1);
SDL_WM_GrabInput(SDL_GRAB_OFF);
}
break;
case SDL_MOUSEMOTION:
if (cameraMode == true)
{
rotationX += cast(double)event.motion.xrel / 10.0;
rotationY += cast(double)event.motion.yrel / 10.0;
reconfigureView();
}
break;
case SDL_QUIT:
return;
default:
break;
}
}
render();
}
}
Here's a sample console output (repeatedly trying to move the camera):
down
up
up
down
up
up
down
up
up
down
up
up
down
up
up
down
up
up
...
Edit: Sorry for the bad title, I forgot