]> git.tdb.fi Git - libs/gui.git/blob - source/input/windows/mouse.cpp
77f84885a4f31c28d0ced2642f708fd0e6a39e00
[libs/gui.git] / source / input / windows / mouse.cpp
1 #include <windowsx.h>
2 #include <msp/graphics/window_private.h>
3 #include "mouse.h"
4
5 namespace Msp {
6 namespace Input {
7
8 void Mouse::input_event(const Graphics::Window::Event &event)
9 {
10         switch(event.msg)
11         {
12         case WM_LBUTTONDOWN:
13         case WM_LBUTTONUP:
14                 set_button_state(1, event.msg==WM_LBUTTONDOWN, true);
15                 break;
16         case WM_MBUTTONDOWN:
17         case WM_MBUTTONUP:
18                 set_button_state(2, event.msg==WM_MBUTTONDOWN, true);
19                 break;
20         case WM_RBUTTONDOWN:
21         case WM_RBUTTONUP:
22                 set_button_state(3, event.msg==WM_RBUTTONDOWN, true);
23                 break;
24         case WM_MOUSEWHEEL:
25                 {
26                         unsigned btn = (HIWORD(event.wparam)&0x8000) ? 5 : 4;
27                         set_button_state(btn, true, true);
28                         set_button_state(btn, false, true);
29                 }
30                 break;
31         case WM_MOUSEMOVE:
32                 set_axis_value(0, GET_X_LPARAM(event.lparam)*2.0/window.get_width()-1.0, true);
33                 set_axis_value(1, 1.0-GET_Y_LPARAM(event.lparam)*2.0/window.get_height(), true);
34                 break;
35         }
36 }
37
38 } // namespace Input
39 } // namepsace Msp