|Project:||The Open Toolkit library|
When I press any of my mouse extra buttons, it always returns MouseButton.Button2 was pressed.
After a bit of debugging I found the issue:
Code which determines which of the extra buttons was pressed is defined like this:
mouse[((wparam.ToUInt32() & 0xFFFF0000) >> 16) != (int)MouseKeys.XButton1 ? MouseButton.Button1 : MouseButton.Button2] = true;
Which takes high-order word of wParam and compares it to defined constant. Which is, technically correct, but it uses incorrect constant. MouseKeys.XButton1 is defined as 0x20 and should be used as a flag for low-order word. Which xbutton was pressed (or released) is stored in high-order word and it's defined as 1 for XButton1 & 2 for XButton2. There are actually two different enums!
This is how the code should look like:
mouse[((wparam.ToUInt32() & 0xFFFF0000) >> 16) == 1 ? MouseButton.Button1 : MouseButton.Button2] = true;
This fix just needs to be applied to
OpenTK/Platform/Windows/WinGLNative.cs : 312
OpenTK/Platform/Windows/WinGLNative.cs : 329
OpenTK/Platform/Windows/WMInput.cs : 113
OpenTK/Platform/Windows/WMInput.cs : 130
and everything works correctly :)
Edit: I didn't check dev builds if this wasn't fixed already. But now I see that 2012-03-15 version still has this bug, it just says Button1 instead of Button2.
Edit2: Actually, the original code is correct, it just compares wparam with wrong constant.