From 3ae1b916ea890ead7f4ede1a46f7940c9c7a0b4c Mon Sep 17 00:00:00 2001 From: crs Date: Wed, 29 Dec 2004 21:12:05 +0000 Subject: [PATCH] Now ignoring 4th and 5th mouse buttons if they don't exist. Was previously querying their state, sometimes getting the wrong answer from the OS that they were down, which prevented switching screens. --- lib/platform/CMSWindowsScreen.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/platform/CMSWindowsScreen.cpp b/lib/platform/CMSWindowsScreen.cpp index 4951dad3..2ad2cd57 100644 --- a/lib/platform/CMSWindowsScreen.cpp +++ b/lib/platform/CMSWindowsScreen.cpp @@ -718,12 +718,15 @@ CMSWindowsScreen::handleSystemEvent(const CEvent& event, void*) void CMSWindowsScreen::updateButtons() { + int numButtons = GetSystemMetrics(SM_CMOUSEBUTTONS); m_buttons[kButtonNone] = false; m_buttons[kButtonLeft] = (GetKeyState(VK_LBUTTON) < 0); - m_buttons[kButtonMiddle] = (GetKeyState(VK_MBUTTON) < 0); m_buttons[kButtonRight] = (GetKeyState(VK_RBUTTON) < 0); - m_buttons[kButtonExtra0 + 0] = (GetKeyState(VK_XBUTTON1) < 0); - m_buttons[kButtonExtra0 + 1] = (GetKeyState(VK_XBUTTON2) < 0); + m_buttons[kButtonMiddle] = (GetKeyState(VK_MBUTTON) < 0); + m_buttons[kButtonExtra0 + 0] = (numButtons >= 4) && + (GetKeyState(VK_XBUTTON1) < 0); + m_buttons[kButtonExtra0 + 1] = (numButtons >= 5) && + (GetKeyState(VK_XBUTTON2) < 0); } IKeyState* @@ -1329,10 +1332,16 @@ CMSWindowsScreen::mapButtonFromEvent(WPARAM msg, LPARAM button) const case WM_NCXBUTTONUP: switch (button) { case XBUTTON1: - return kButtonExtra0 + 0; + if (GetSystemMetrics(SM_CMOUSEBUTTONS) >= 4) { + return kButtonExtra0 + 0; + } + break; case XBUTTON2: - return kButtonExtra0 + 1; + if (GetSystemMetrics(SM_CMOUSEBUTTONS) >= 5) { + return kButtonExtra0 + 1; + } + break; } return kButtonNone;