]> git.tdb.fi Git - libs/gui.git/blob - source/input/windows/mouse.cpp
Touchscreen input device
[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         // http://msdn.microsoft.com/en-us/library/windows/desktop/ms703320.aspx
11         if(window.get_touch_input() && (event.extra&0xFFFFFF00)==0xFF515700)
12                 return;
13
14         switch(event.msg)
15         {
16         case WM_LBUTTONDOWN:
17         case WM_LBUTTONUP:
18                 set_button_state(1, event.msg==WM_LBUTTONDOWN, true);
19                 break;
20         case WM_MBUTTONDOWN:
21         case WM_MBUTTONUP:
22                 set_button_state(2, event.msg==WM_MBUTTONDOWN, true);
23                 break;
24         case WM_RBUTTONDOWN:
25         case WM_RBUTTONUP:
26                 set_button_state(3, event.msg==WM_RBUTTONDOWN, true);
27                 break;
28         case WM_MOUSEWHEEL:
29                 {
30                         unsigned btn = (HIWORD(event.wparam)&0x8000) ? 5 : 4;
31                         set_button_state(btn, true, true);
32                         set_button_state(btn, false, true);
33                 }
34                 break;
35         case WM_MOUSEMOVE:
36                 set_axis_value(0, GET_X_LPARAM(event.lparam)*2.0/window.get_width()-1.0, true);
37                 set_axis_value(1, 1.0-GET_Y_LPARAM(event.lparam)*2.0/window.get_height(), true);
38                 break;
39         }
40 }
41
42 } // namespace Input
43 } // namepsace Msp