]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/windows/mouse.cpp
Split platform-specific parts into separate directories
[libs/gui.git] / source / input / windows / mouse.cpp
diff --git a/source/input/windows/mouse.cpp b/source/input/windows/mouse.cpp
new file mode 100644 (file)
index 0000000..77f8488
--- /dev/null
@@ -0,0 +1,39 @@
+#include <windowsx.h>
+#include <msp/graphics/window_private.h>
+#include "mouse.h"
+
+namespace Msp {
+namespace Input {
+
+void Mouse::input_event(const Graphics::Window::Event &event)
+{
+       switch(event.msg)
+       {
+       case WM_LBUTTONDOWN:
+       case WM_LBUTTONUP:
+               set_button_state(1, event.msg==WM_LBUTTONDOWN, true);
+               break;
+       case WM_MBUTTONDOWN:
+       case WM_MBUTTONUP:
+               set_button_state(2, event.msg==WM_MBUTTONDOWN, true);
+               break;
+       case WM_RBUTTONDOWN:
+       case WM_RBUTTONUP:
+               set_button_state(3, event.msg==WM_RBUTTONDOWN, true);
+               break;
+       case WM_MOUSEWHEEL:
+               {
+                       unsigned btn = (HIWORD(event.wparam)&0x8000) ? 5 : 4;
+                       set_button_state(btn, true, true);
+                       set_button_state(btn, false, true);
+               }
+               break;
+       case WM_MOUSEMOVE:
+               set_axis_value(0, GET_X_LPARAM(event.lparam)*2.0/window.get_width()-1.0, true);
+               set_axis_value(1, 1.0-GET_Y_LPARAM(event.lparam)*2.0/window.get_height(), true);
+               break;
+       }
+}
+
+} // namespace Input
+} // namepsace Msp