- Fixed: The mouse wheel generated no events in GUI mode if you weren't

fullscreen. (e.g. You could no longer scroll the console with the mouse
  buffer.)
- Fixed: Wheeling down was seen as wheeling up with the Win32 mouse.


SVN r1618 (trunk)
This commit is contained in:
Randy Heit 2009-05-27 22:57:21 +00:00
parent 12959a1bd1
commit 092512c44a
4 changed files with 63 additions and 35 deletions

View file

@ -1,4 +1,8 @@
May 27, 2009 May 27, 2009
- Fixed: The mouse wheel generated no events in GUI mode if you weren't
fullscreen. (e.g. You could no longer scroll the console with the mouse
buffer.)
- Fixed: Wheeling down was seen as wheeling up with the Win32 mouse.
- EV_GUI_Key(Down|Up|Repeat) events no longer provide shifted key codes - EV_GUI_Key(Down|Up|Repeat) events no longer provide shifted key codes
in data2. This was just unnecessary overhead that wasn't really needed in data2. This was just unnecessary overhead that wasn't really needed
anywhere. anywhere.

View file

@ -143,6 +143,7 @@ extern menu_t JoystickMenu;
EXTERN_CVAR (String, language) EXTERN_CVAR (String, language)
EXTERN_CVAR (Bool, lookstrafe) EXTERN_CVAR (Bool, lookstrafe)
static int WheelDelta;
extern BOOL paused; extern BOOL paused;
static bool noidle = false; static bool noidle = false;
@ -415,6 +416,32 @@ bool GUIWndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, LRESU
} }
D_PostEvent(&ev); D_PostEvent(&ev);
return true; return true;
// Note: If the mouse is grabbed, it sends the mouse wheel events itself.
case WM_MOUSEWHEEL:
if (wParam & MK_SHIFT) ev.data3 |= GKM_SHIFT;
if (wParam & MK_CONTROL) ev.data3 |= GKM_CTRL;
if (GetKeyState(VK_MENU) & 0x8000) ev.data3 |= GKM_ALT;
WheelDelta += (SHORT)HIWORD(wParam);
if (WheelDelta < 0)
{
ev.subtype = EV_GUI_WheelDown;
while (WheelDelta <= -WHEEL_DELTA)
{
D_PostEvent(&ev);
WheelDelta += WHEEL_DELTA;
}
}
else
{
ev.subtype = EV_GUI_WheelUp;
while (WheelDelta >= WHEEL_DELTA)
{
D_PostEvent(&ev);
WheelDelta -= WHEEL_DELTA;
}
}
return true;
} }
return false; return false;
} }

View file

@ -80,6 +80,7 @@ protected:
void PostButtonEvent(int button, bool down); void PostButtonEvent(int button, bool down);
void ClearButtonState(); void ClearButtonState();
int WheelMove;
int LastX, LastY; // for m_filter int LastX, LastY; // for m_filter
WORD ButtonState; // bit mask of current button states (1=down, 0=up) WORD ButtonState; // bit mask of current button states (1=down, 0=up)
}; };

View file

@ -266,6 +266,7 @@ FMouse::FMouse()
{ {
LastX = LastY = 0; LastX = LastY = 0;
ButtonState = 0; ButtonState = 0;
WheelMove = 0;
} }
//========================================================================== //==========================================================================
@ -316,33 +317,9 @@ void FMouse::WheelMoved(int wheelmove)
event_t ev = { 0 }; event_t ev = { 0 };
int dir; int dir;
if (GUICapture) WheelMove += wheelmove;
{
ev.type = EV_GUI_Event; if (WheelMove < 0)
if (wheelmove < 0)
{
dir = WHEEL_DELTA;
ev.subtype = EV_GUI_WheelDown;
}
else
{
dir = -WHEEL_DELTA;
ev.subtype = EV_GUI_WheelUp;
}
/* FIXME
ev.data3 = ((KeyState[VK_SHIFT]&128) ? GKM_SHIFT : 0) |
((KeyState[VK_CONTROL]&128) ? GKM_CTRL : 0) |
((KeyState[VK_MENU]&128) ? GKM_ALT : 0);
*/
while (abs(wheelmove) >= WHEEL_DELTA)
{
D_PostEvent(&ev);
wheelmove += dir;
}
}
else
{
if (wheelmove < 0)
{ {
dir = WHEEL_DELTA; dir = WHEEL_DELTA;
ev.data1 = KEY_MWHEELDOWN; ev.data1 = KEY_MWHEELDOWN;
@ -352,13 +329,30 @@ void FMouse::WheelMoved(int wheelmove)
dir = -WHEEL_DELTA; dir = -WHEEL_DELTA;
ev.data1 = KEY_MWHEELUP; ev.data1 = KEY_MWHEELUP;
} }
while (abs(wheelmove) >= WHEEL_DELTA)
if (!GUICapture)
{
while (abs(WheelMove) >= WHEEL_DELTA)
{ {
ev.type = EV_KeyDown; ev.type = EV_KeyDown;
D_PostEvent(&ev); D_PostEvent(&ev);
ev.type = EV_KeyUp; ev.type = EV_KeyUp;
D_PostEvent(&ev); D_PostEvent(&ev);
wheelmove += dir; WheelMove += dir;
}
}
else
{
ev.type = EV_GUI_Event;
ev.subtype = (WheelMove < 0) ? EV_GUI_WheelDown : EV_GUI_WheelUp;
if (GetKeyState(VK_SHIFT) & 0x8000) ev.data3 |= GKM_SHIFT;
if (GetKeyState(VK_CONTROL) & 0x8000) ev.data3 |= GKM_CTRL;
if (GetKeyState(VK_MENU) & 0x8000) ev.data3 |= GKM_ALT;
ev.data1 = 0;
while (abs(WheelMove) >= WHEEL_DELTA)
{
D_PostEvent(&ev);
WheelMove += dir;
} }
} }
} }
@ -420,6 +414,8 @@ void FMouse::ClearButtonState()
} }
ButtonState = 0; ButtonState = 0;
} }
// Reset mouse wheel accumulation to 0.
WheelMove = 0;
} }
//========================================================================== //==========================================================================
@ -967,7 +963,7 @@ bool FWin32Mouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa
} }
else if (message == WM_MOUSEWHEEL) else if (message == WM_MOUSEWHEEL)
{ {
WheelMoved(HIWORD(wParam)); WheelMoved((SHORT)HIWORD(wParam));
return true; return true;
} }
else if (message >= WM_LBUTTONDOWN && message <= WM_MBUTTONUP) else if (message >= WM_LBUTTONDOWN && message <= WM_MBUTTONUP)