0

So I'm trying to build a simple input-handler to work against windows message-loop. But for some reason when I test the case of WM_MBUTTONDOWN I get the same wParam as if I press the "Shift-key". The code I get when trying to click my middle mouse button is 16 in decimal or 0x10 in hexadecimal. When I looked into it I can see that MBUTTON should be 0x04 but I don't get that.

Anyone encountered this before?

This is the code that I'm using in the WndProc function of my Win32 application. (Ofcourse there is more cases that check if they're up and so on, but didn't feel it was relevant to the question)

case WM_MBUTTONDOWN:
    if (wParam < 256)
    {
        globalInputManager.SetKeyIsDown(static_cast<uint8_t>(wParam));
        OutputDebugStringA(std::to_string(wParam).c_str());
    }
    break;
case WM_KEYDOWN:
    if (wParam < 256)
    {
        globalInputManager.SetKeyIsDown(static_cast<uint8_t>(wParam));
        OutputDebugStringA(std::to_string(wParam).c_str());
    }
    break;
  • 0x10 is correct, that's the value of MK_MBUTTON. The assumption that you should get MBUTTON is just not accurate. – Hans Passant Nov 21 '16 at 08:27
  • Hmm alright, I saw that. So my current solution to store all the "events" both keyboard and mouse is in an array of 256 bools, each representing a "key/button", since I'm getting the same number from both the shift-key and the middle mouse button, this would not work right? – Hampus Siversson Nov 21 '16 at 08:31
  • Avoid re-inventing the GetKeyState() and GetKeyboardState() winapi functions. – Hans Passant Nov 21 '16 at 08:48

0 Answers0