- I_CheckNativeMouse() now checks the foreground window to determine if the

mouse should be grabbed. This fixes the case where you start the game in
  the background and it grabs the mouse anyway.
- Changed raw mouse grabbing to call ShowCursor() directly instead of through
  SetCursorState(), since changing the pointer isn't working with it
  (probably due to the lack of legacy mouse messages), and the others work
  fine by setting an invisible cursor.
- Fixed: Raw mouse input passes wheel movements in an unsigned field, but the
  value is signed, so it requires a cast to use it.
- Reverted accidental changes to src/sdl/i_input.cpp.

SVN r1605 (trunk)
This commit is contained in:
Randy Heit 2009-05-26 00:30:51 +00:00
parent e43453b614
commit 5245e8d4dd
3 changed files with 41 additions and 21 deletions

View file

@ -1,4 +1,15 @@
May 23, 2009
May 25, 2009
- I_CheckNativeMouse() now checks the foreground window to determine if the
mouse should be grabbed. This fixes the case where you start the game in
the background and it grabs the mouse anyway.
- Changed raw mouse grabbing to call ShowCursor() directly instead of through
SetCursorState(), since changing the pointer isn't working with it
(probably due to the lack of legacy mouse messages), and the others work
fine by setting an invisible cursor.
- Fixed: Raw mouse input passes wheel movements in an unsigned field, but the
value is signed, so it requires a cast to use it.
May 23, 2009
- SetCursorState() now calls ShowCursor() again, because capturing the mouse
with RIDEV_NOLEGACY apparently prevents SetCursor() from doing anything.
- Split mouse code off from i_input.cpp into i_mouse.cpp and added raw mouse

View file

@ -21,7 +21,8 @@
static void I_CheckGUICapture ();
static void I_CheckNativeMouse ();
bool GUICapture;
static bool GUICapture;
static bool NativeMouse = true;
extern int paused;

View file

@ -175,18 +175,9 @@ static void SetCursorState(bool visible)
{
HCURSOR usingCursor = visible ? TheArrowCursor : TheInvisibleCursor;
SetClassLongPtr(Window, GCLP_HCURSOR, (LONG_PTR)usingCursor);
//if (HaveFocus)
if (HaveFocus)
{
SetCursor(usingCursor);
if (visible)
{
ShowCursor(TRUE);
}
else
{
while (ShowCursor(FALSE) >= 0)
{ }
}
}
}
@ -223,18 +214,33 @@ static bool CaptureMode_InGame()
void I_CheckNativeMouse(bool preferNative)
{
bool wantNative = (GetFocus() != Window) ||
((!screen || !screen->IsFullscreen()) &&
(!CaptureMode_InGame() || GUICapture || paused || preferNative || !use_mouse || demoplayback));
bool windowed = (screen == NULL) || !screen->IsFullscreen();
bool want_native;
if (!windowed)
{
want_native = false;
}
else
{
want_native =
(GetForegroundWindow() != Window) ||
!CaptureMode_InGame() ||
GUICapture ||
paused ||
preferNative ||
!use_mouse ||
demoplayback;
}
//Printf ("%d %d %d\n", wantNative, preferNative, NativeMouse);
if (wantNative != NativeMouse)
if (want_native != NativeMouse)
{
if (Mouse != NULL)
{
NativeMouse = wantNative;
if (wantNative)
NativeMouse = want_native;
if (want_native)
{
Mouse->Ungrab();
}
@ -493,6 +499,7 @@ void FRawMouse::ProcessInput()
//
//==========================================================================
extern BOOL AppActive;
void FRawMouse::Grab()
{
if (!Grabbed)
@ -507,7 +514,8 @@ void FRawMouse::Grab()
{
GetCursorPos(&UngrabbedPointerPos);
Grabbed = true;
SetCursorState(false);
while (ShowCursor(FALSE) >= 0)
{ }
// By setting the cursor position, we force the pointer image
// to change right away instead of having it delayed until
// some time in the future.
@ -537,7 +545,7 @@ void FRawMouse::Ungrab()
Grabbed = false;
ClearButtonState();
}
SetCursorState(true);
ShowCursor(TRUE);
SetCursorPos(UngrabbedPointerPos.x, UngrabbedPointerPos.y);
}
}
@ -589,7 +597,7 @@ bool FRawMouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPara
}
if (raw->data.mouse.usButtonFlags & RI_MOUSE_WHEEL)
{
WheelMoved(raw->data.mouse.usButtonData);
WheelMoved((SHORT)raw->data.mouse.usButtonData);
}
PostMouseMove(m_noprescale ? raw->data.mouse.lLastX : raw->data.mouse.lLastX<<2,
-raw->data.mouse.lLastY);