esp32 firmware for a toaster reflow oven WIP!!!!!
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.
 
 
 
 
 
 
reflower/main/liquid/input_event.h

57 lines
1.0 KiB

/**
* Input event structural enum
*
* Created on 2020/01/05.
*/
#ifndef LIQUID_INPUT_EVENT_H
#define LIQUID_INPUT_EVENT_H
#include <stdint.h>
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