]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/mouse.cpp
Fix mouse buttons on Windows
[libs/gui.git] / source / input / mouse.cpp
index 476275f4a77bc75024d254903abc3cb6ba74140f..2337f70f5aa86139be1b803c3bc6e9385d581adc 100644 (file)
@@ -1,6 +1,8 @@
+#ifdef WIN32
+#include <windowsx.h>
+#endif
 #include <msp/graphics/window.h>
 #include <msp/graphics/window_priv.h>
-#include <msp/strings/format.h>
 #include "mouse.h"
 
 namespace Msp {
@@ -32,7 +34,7 @@ std::string Mouse::get_button_name(unsigned btn) const
        case 5:
                return "Wheel Down";
        default:
-               return format("Button %d", btn);
+               return Device::get_button_name(btn);
        }
 }
 
@@ -45,7 +47,7 @@ std::string Mouse::get_axis_name(unsigned axis) const
        case 1:
                return "Y axis";
        default:
-               return format("Axis %d", axis);
+               return Device::get_axis_name(axis);
        };
 }
 
@@ -60,15 +62,15 @@ void Mouse::input_event(const Graphics::Window::Event &event)
                break;
        case WM_MBUTTONDOWN:
        case WM_MBUTTONUP:
-               set_button_state(2, event.msg==WM_LBUTTONDOWN, true);
+               set_button_state(2, event.msg==WM_MBUTTONDOWN, true);
                break;
        case WM_RBUTTONDOWN:
        case WM_RBUTTONUP:
-               set_button_state(3, event.msg==WM_LBUTTONDOWN, true);
+               set_button_state(3, event.msg==WM_RBUTTONDOWN, true);
                break;
        case WM_MOUSEWHEEL:
                {
-                       unsigned btn = (HIWORD(wp)&0x8000) ? 5 : 4;
+                       unsigned btn = (HIWORD(event.wparam)&0x8000) ? 5 : 4;
                        set_button_state(btn, true, true);
                        set_button_state(btn, false, true);
                }