7 #include "input/input_state.h"
18 typedef uint32_t TouchPointID;
21 TOUCH_EVENT_TYPE_FINGER_DOWN,
22 TOUCH_EVENT_TYPE_FINGER_UP,
23 TOUCH_EVENT_TYPE_FINGER_MOVE
28 TouchPointID touch_id;
30 Vec2 normalized_coord;
36 KEY_EVENT_TYPE_KEY_DOWN,
49 bool num_lock =
false;
50 bool caps_lock =
false;
53 bool ctrl()
const {
return lctrl || rctrl; }
54 bool shift()
const {
return lshift || rshift; }
55 bool alt()
const {
return lalt || ralt; }
56 bool super()
const {
return lsuper || rsuper; }
61 KeyboardCode keyboard_code;
65 enum MouseEventType : uint8_t {
66 MOUSE_EVENT_TYPE_BUTTON_DOWN,
67 MOUSE_EVENT_TYPE_BUTTON_UP,
68 MOUSE_EVENT_TYPE_MOTION
80 enum GameControllerEventType {
81 GAME_CONTROLLER_EVENT_TYPE_BUTTON_DOWN,
82 GAME_CONTROLLER_EVENT_TYPE_BUTTON_UP
86 GameControllerIndex index;
87 GameControllerEventType type;
88 JoystickButton button;
96 void handle_touch_begin(
Window* window, TouchPointID touch_id,
float normalized_x,
float normalized_y,
float pressure);
97 void handle_touch_end(
Window* window, TouchPointID touch_id,
float normalized_x,
float normalized_y);
98 void handle_touch_move(
Window* window, TouchPointID touch_id,
float normalized_x,
float normalized_y,
float dx,
float dy);
103 void handle_mouse_down(
Window* window, MouseID
id, uint8_t mouse_button, int32_t x, int32_t y,
bool touch_device);
104 void handle_mouse_up(
Window* window, MouseID
id, uint8_t mouse_button, int32_t x, int32_t y,
bool touch_device);
105 void handle_mouse_move(
Window* window, MouseID
id, int32_t x, int32_t y,
bool touch_device);
107 void handle_controller_button_down(GameControllerIndex controller, JoystickButton button);
108 void handle_controller_button_up(GameControllerIndex controller, JoystickButton button);
111 virtual void on_key_down(
const KeyEvent& evt) {
115 virtual void on_key_up(
const KeyEvent& evt) {
119 virtual void on_mouse_down(
const MouseEvent& evt) {
123 virtual void on_mouse_up(
const MouseEvent& evt) {
127 virtual void on_mouse_move(
const MouseEvent& evt) {
131 virtual void on_touch_begin(
const TouchEvent& evt) {
135 virtual void on_touch_end(
const TouchEvent& evt) {
139 virtual void on_touch_move(
const TouchEvent& evt) {
151 virtual void on_window_focus() {}
152 virtual void on_window_blur() {}
153 virtual void on_window_minimize() {}
154 virtual void on_window_restore() {}
165 void each_event_listener(std::function<
void (
EventListener*)> callback);
168 std::list<EventListener*> listeners_;