27 lines
857 B
C
27 lines
857 B
C
//
|
|
// Created by xemon on 16.11.22.
|
|
//
|
|
|
|
#ifndef UVEOS_ON_NATION_USERINPUTBUTTONEVENT_H
|
|
#define UVEOS_ON_NATION_USERINPUTBUTTONEVENT_H
|
|
|
|
#include "stdint.h"
|
|
|
|
typedef enum {
|
|
USER_INPUT_BUTTON_ACTION_RAISE,
|
|
USER_INPUT_BUTTON_ACTION_FALL,
|
|
} eUserInputButtonAction;
|
|
|
|
typedef struct {
|
|
uint16_t buttonId;
|
|
eUserInputButtonAction action;
|
|
uint32_t duration;
|
|
} tUserInputButtonEvent;
|
|
|
|
#define UserInputButtonEventIs(EVENT, BUTTON, ACTION) ((EVENT).buttonId == BUTTON && (EVENT).action == USER_INPUT_BUTTON_ACTION_##ACTION)
|
|
#define UserInputButtonEventBetween(EVENT, MIN, MAX) (((EVENT).duration > MIN ) && ((EVENT).duration < MAX))
|
|
#define UserInputButtonEventIsBetween(EVENT, BUTTON, ACTION, MIN, MAX) (UserInputButtonEventIs(EVENT, BUTTON, ACTION) && UserInputButtonEventBetween(EVENT, MIN, MAX))
|
|
|
|
|
|
#endif //UVEOS_ON_NATION_USERINPUTBUTTONEVENT_H
|