1 | // LAF OS Library |
---|---|
2 | // Copyright (c) 2020-2022 Igara Studio S.A. |
3 | // |
4 | // This file is released under the terms of the MIT license. |
5 | // Read LICENSE.txt for more information. |
6 | |
7 | #ifndef OS_X11_MOUSE_INCLUDED |
8 | #define OS_X11_MOUSE_INCLUDED |
9 | #pragma once |
10 | |
11 | #include "os/event.h" |
12 | #include <X11/X.h> |
13 | |
14 | namespace os { |
15 | |
16 | inline Event::MouseButton get_mouse_button_from_x(int button) { |
17 | switch (button) { |
18 | case Button1: return Event::LeftButton; |
19 | case Button2: return Event::MiddleButton; |
20 | case Button3: return Event::RightButton; |
21 | case 8: return Event::X1Button; |
22 | case 9: return Event::X2Button; |
23 | } |
24 | TRACE("Unknown Button %d\n", button); |
25 | return Event::NoneButton; |
26 | } |
27 | |
28 | inline int get_x_mouse_button_from_event(Event::MouseButton button) { |
29 | switch (button) { |
30 | case Event::NoneButton: return 0; |
31 | case Event::LeftButton: return Button1; |
32 | case Event::MiddleButton: return Button2; |
33 | case Event::RightButton: return Button3; |
34 | case Event::X1Button: return 8; |
35 | case Event::X2Button: return 9; |
36 | } |
37 | TRACE("Unknown Button %d\n", button); |
38 | return 0; |
39 | } |
40 | |
41 | } // namespace os |
42 | |
43 | #endif |
44 |