]> git.tdb.fi Git - libs/gui.git/blob - source/input/cocoa/mouse.cpp
Add constants for mouse axes and buttons
[libs/gui.git] / source / input / cocoa / mouse.cpp
1 #include <msp/graphics/window_private.h>
2 #include "keys.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.cevent.type)
11         {
12         case LEFT_MOUSE_DOWN:
13         case LEFT_MOUSE_UP:
14         case RIGHT_MOUSE_DOWN:
15         case RIGHT_MOUSE_UP:
16         case OTHER_MOUSE_DOWN:
17         case OTHER_MOUSE_UP:
18                 set_button_state(event.cevent.button.button, event.cevent.button.state, true);
19                 break;
20         case MOUSE_MOVED:
21                 set_axis_value(MOUSE_X_AXIS, event.cevent.motion.x*2.0/window.get_width()-1.0, true);
22                 set_axis_value(MOUSE_Y_AXIS, event.cevent.motion.y*2.0/window.get_height()-1.0, true);
23                 break;
24         default:;
25         }
26 }
27
28 } // namespace Input
29 } // namespace Msp