Browse Source

Capture the mouse on clicks

This hack prevents the cursor from leaving the window when panning the
camera or changing directions quickly. This is important for those with
high mouse sensitivities.
Adam Johnson 12 years ago
parent
commit
b90776fafe
  1. 44
      Sources/Plasma/Apps/plClient/winmain.cpp

44
Sources/Plasma/Apps/plClient/winmain.cpp

@ -395,31 +395,37 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
nc->ResetServerTimeOffset(true); nc->ResetServerTimeOffset(true);
break; break;
case WM_KEYDOWN : case WM_LBUTTONDOWN:
case WM_LBUTTONDOWN : case WM_RBUTTONDOWN:
case WM_RBUTTONDOWN : case WM_LBUTTONDBLCLK:
case WM_LBUTTONDBLCLK : // The left mouse button was double-clicked. case WM_MBUTTONDBLCLK:
case WM_MBUTTONDBLCLK : // The middle mouse button was double-clicked. case WM_MBUTTONDOWN:
case WM_MBUTTONDOWN : // The middle mouse button was pressed. case WM_RBUTTONDBLCLK:
case WM_RBUTTONDBLCLK : // The right mouse button was double-clicked. // Ensure we don't leave the client area during this action
SetCapture(hWnd);
// fall through to old case
case WM_KEYDOWN:
case WM_CHAR:
// If they did anything but move the mouse, quit any intro movie playing. // If they did anything but move the mouse, quit any intro movie playing.
if (gClient)
{ {
if( gClient )
gClient->SetQuitIntro(true); gClient->SetQuitIntro(true);
// normal input processing
if (gClient->WindowActive() && gClient->GetInputManager())
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
} }
// Fall through to other events break;
case WM_CHAR: case WM_LBUTTONUP:
case WM_KEYUP : case WM_RBUTTONUP:
case WM_LBUTTONUP : case WM_MBUTTONUP:
case WM_RBUTTONUP : // Stop hogging the cursor
case WM_MBUTTONUP : // The middle mouse button was released. ReleaseCapture();
case 0x020A: // fuc&ing windows b.s... // fall through to input processing
{ case WM_MOUSEWHEEL:
case WM_KEYUP:
if (gClient && gClient->WindowActive() && gClient->GetInputManager()) if (gClient && gClient->WindowActive() && gClient->GetInputManager())
{
gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd); gClient->GetInputManager()->HandleWin32ControlEvent(message, wParam, lParam, hWnd);
}
}
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:

Loading…
Cancel
Save