You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
936 B
52 lines
936 B
5 years ago
|
/**
|
||
|
* Input event structural enum
|
||
|
*
|
||
|
* Created on 2020/01/05.
|
||
|
*/
|
||
|
|
||
|
#ifndef LIQUID_INPUT_EVENT_H
|
||
|
#define LIQUID_INPUT_EVENT_H
|
||
|
|
||
|
enum InputEvent_Kind {
|
||
|
InputEventKind_Wheel,
|
||
|
InputEventKind_Button,
|
||
|
};
|
||
|
|
||
|
struct InputEvent {
|
||
|
enum InputEvent_Kind kind;
|
||
|
union {
|
||
|
struct {
|
||
|
// Wheel delta
|
||
|
int32_t delta;
|
||
|
} 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}
|
||
|
};
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 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
|