]> git.tdb.fi Git - libs/gui.git/blob - source/input/x11/mouse.cpp
3533d561fc17b4c325c60b06288a84b4e44fcfab
[libs/gui.git] / source / input / x11 / mouse.cpp
1 #include <msp/graphics/window_private.h>
2 #include "mouse.h"
3
4 namespace Msp {
5 namespace Input {
6
7 void Mouse::input_event(const Graphics::Window::Event &event)
8 {
9         switch(event.xevent.type)
10         {
11         case ButtonPress:
12         case ButtonRelease:
13                 set_button_state(event.xevent.xbutton.button, event.xevent.type==ButtonPress, true);
14                 break;
15         case MotionNotify:
16                 set_axis_value(0, event.xevent.xmotion.x*2.0/window.get_width()-1.0, true);
17                 set_axis_value(1, 1.0-event.xevent.xmotion.y*2.0/window.get_height(), true);
18                 break;
19         }
20 }
21
22 } // namespace Input
23 } // namepsace Msp