/** * Input event structural enum * * Created on 2020/01/05. */ #ifndef LIQUID_INPUT_EVENT_H #define LIQUID_INPUT_EVENT_H #include enum InputEvent_Kind { InputEventKind_Wheel, InputEventKind_Button, }; struct InputEvent { enum InputEvent_Kind kind; union { struct { // Wheel delta int32_t delta; int8_t direction; } wheel; struct { // Button state bool state; } button; }; }; static inline struct InputEvent InputEvent_Wheel(int32_t delta) { return (struct InputEvent) { .kind = InputEventKind_Wheel, .wheel = { .delta = delta, .direction = delta > 0 ? 1 : -1, } }; } /** * Button event (push, release) * * @param state - pushed * @return event */ static inline struct InputEvent InputEvent_Button(bool state) { return (struct InputEvent) { .kind = InputEventKind_Button, .button = {.state = state}, }; } #endif //LIQUID_INPUT_EVENT_H