Mercurial > molko
comparison libmlk-core/core/event.h @ 253:c4da052c0def
core: goodbye doxygen
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 03 Dec 2020 09:06:52 +0100 |
parents | 71b3b7036de7 |
children | 87b8c7510717 |
comparison
equal
deleted
inserted
replaced
252:95c2c4a72410 | 253:c4da052c0def |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #ifndef MOLKO_CORE_EVENT_H | 19 #ifndef MOLKO_CORE_EVENT_H |
20 #define MOLKO_CORE_EVENT_H | 20 #define MOLKO_CORE_EVENT_H |
21 | 21 |
22 /** | |
23 * \file event.h | |
24 * \brief Event management. | |
25 * \ingroup input | |
26 */ | |
27 | |
28 #include <stdbool.h> | 22 #include <stdbool.h> |
29 | 23 |
30 #include "key.h" | 24 #include "key.h" |
31 #include "mouse.h" | 25 #include "mouse.h" |
32 | 26 |
33 /** | |
34 * \brief Kind of event. | |
35 */ | |
36 enum event_type { | 27 enum event_type { |
37 EVENT_CLICKDOWN, /*!< Mouse click down (\ref event_click) */ | 28 EVENT_CLICKDOWN, |
38 EVENT_CLICKUP, /*!< Mouse click released (\ref event_click) */ | 29 EVENT_CLICKUP, |
39 EVENT_KEYDOWN, /*!< Single key down (\ref event_key) */ | 30 EVENT_KEYDOWN, |
40 EVENT_KEYUP, /*!< Single key released (\ref event_key) */ | 31 EVENT_KEYUP, |
41 EVENT_MOUSE, /*!< Mouse moved (\ref event_mouse) */ | 32 EVENT_MOUSE, |
42 EVENT_QUIT, /*!< Quit request */ | 33 EVENT_QUIT, |
43 }; | 34 }; |
44 | 35 |
45 /** | |
46 * \brief Key event. | |
47 */ | |
48 struct event_key { | 36 struct event_key { |
49 enum event_type type; /*!< (+) EVENT_KEYDOWN or EVENT_KEYUP */ | 37 enum event_type type; |
50 enum key key; /*!< (+) Which key */ | 38 enum key key; |
51 }; | 39 }; |
52 | 40 |
53 /** | |
54 * \brief Mouse motion event. | |
55 */ | |
56 struct event_mouse { | 41 struct event_mouse { |
57 enum event_type type; /*!< (+) EVENT_MOUSE */ | 42 enum event_type type; |
58 enum mouse_button buttons; /*!< (+) OR'ed buttons that are pressed */ | 43 enum mouse_button buttons; |
59 int x; /*!< (+) Mouse position in x */ | 44 int x; |
60 int y; /*!< (+) Mouse position in y */ | 45 int y; |
61 }; | 46 }; |
62 | 47 |
63 /** | |
64 * \brief Mouse click event. | |
65 */ | |
66 struct event_click { | 48 struct event_click { |
67 enum event_type type; /*!< (+) EVENT_CLICKDOWN or EVENT_CLICKUP */ | 49 enum event_type type; |
68 enum mouse_button button; /*!< (+) Unique button that was pressed */ | 50 enum mouse_button button; |
69 int x; /*!< (+) Mouse position in x */ | 51 int x; |
70 int y; /*!< (+) Mouse position in y */ | 52 int y; |
71 }; | 53 }; |
72 | 54 |
73 /** | |
74 * \brief Store events. | |
75 */ | |
76 union event { | 55 union event { |
77 enum event_type type; /*!< (+) Which kind of event */ | 56 enum event_type type; |
78 struct event_key key; /*!< (+) Key event */ | 57 struct event_key key; |
79 struct event_mouse mouse; /*!< (+) Mouse motion event */ | 58 struct event_mouse mouse; |
80 struct event_click click; /*!< (+) Mouse click event */ | 59 struct event_click click; |
81 }; | 60 }; |
82 | 61 |
83 /** | |
84 * Fetch the next event or return false if there are not. | |
85 * | |
86 * \param ev the event | |
87 * \return True if the event was filled or false otherwise. | |
88 */ | |
89 bool | 62 bool |
90 event_poll(union event *ev); | 63 event_poll(union event *ev); |
91 | 64 |
92 #endif /* !MOLKO_CORE_EVENT_H */ | 65 #endif /* !MOLKO_CORE_EVENT_H */ |