1 #ifndef GRAPHICS_MOUSE_H
2 #define GRAPHICS_MOUSE_H
3 
4 /**
5  * @file
6  * Mouse state
7  */
8 
9 #include "input/touch.h"
10 
11 /**
12  * Mouse button state
13  */
14 typedef struct {
15     int is_down; /**< Mouse button is down */
16     int went_down; /**< Mouse button went down during this cycle */
17     int went_up; /**< Mouse button went up during this cycle */
18     int double_click; /**< Mouse double clicked during this cycle */
19     int system_change;
20 } mouse_button;
21 
22 typedef enum {
23     SCROLL_NONE = 0,
24     SCROLL_UP = -1,
25     SCROLL_DOWN = 1
26 } scroll_state;
27 
28 /**
29  * Mouse state
30  */
31 typedef struct {
32     int x; /**< Global position X */
33     int y; /**< Global position Y */
34     scroll_state scrolled; /**< Scroll state (up/down/none) */
35     mouse_button left; /**< Left mouse button */
36     mouse_button right; /**< Right mouse button */
37     int is_inside_window; /**< Whether the mouse is in the window */
38     int is_touch; /**< Whether the mouse is a translated touch event */
39 } mouse;
40 
41 /**
42  * Gets the mouse state
43  * @return Mouse state
44  */
45 const mouse *mouse_get(void);
46 
47 /**
48  * Sets the mouse position
49  * @param x X
50  * @param y Y
51  */
52 void mouse_set_position(int x, int y);
53 
54 void mouse_set_left_down(int down);
55 
56 void mouse_set_right_down(int down);
57 
58 void mouse_set_scroll(scroll_state state);
59 
60 void mouse_set_inside_window(int inside);
61 
62 /**
63  * Changes the mouse information from touch information
64  * @param first The first touch
65  */
66 void mouse_set_from_touch(const touch *first, const touch *last);
67 
68 /**
69  * Dissociates touch status from mouse
70  */
71 void mouse_remove_touch(void);
72 
73 void mouse_reset_up_state(void);
74 
75 void mouse_reset_scroll(void);
76 
77 void mouse_reset_button_state(void);
78 
79 void mouse_determine_button_state(void);
80 
81 const mouse *mouse_in_dialog(const mouse *m);
82 
83 #endif // GRAPHICS_MOUSE_H
84