2021-10-03 13:36:05 +03:00
|
|
|
/**
|
|
|
|
* @file input.h
|
|
|
|
* Input: main API
|
|
|
|
*/
|
|
|
|
|
2021-02-10 11:56:05 +03:00
|
|
|
#pragma once
|
2020-10-02 09:44:05 +03:00
|
|
|
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <furi_hal_resources.h>
|
2020-10-02 09:44:05 +03:00
|
|
|
|
2022-09-14 19:11:38 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-07-26 15:21:51 +03:00
|
|
|
#define RECORD_INPUT_EVENTS "input_events"
|
2023-03-09 20:13:18 +03:00
|
|
|
#define INPUT_SEQUENCE_SOURCE_HARDWARE (0u)
|
|
|
|
#define INPUT_SEQUENCE_SOURCE_SOFTWARE (1u)
|
2022-07-26 15:21:51 +03:00
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Input Types
|
2021-02-10 11:56:05 +03:00
|
|
|
* Some of them are physical events and some logical
|
|
|
|
*/
|
2020-10-02 09:44:05 +03:00
|
|
|
typedef enum {
|
2021-10-03 13:36:05 +03:00
|
|
|
InputTypePress, /**< Press event, emitted after debounce */
|
|
|
|
InputTypeRelease, /**< Release event, emitted after debounce */
|
2023-01-11 16:41:57 +03:00
|
|
|
InputTypeShort, /**< Short event, emitted after InputTypeRelease done within INPUT_LONG_PRESS interval */
|
2022-11-28 19:51:51 +03:00
|
|
|
InputTypeLong, /**< Long event, emitted after INPUT_LONG_PRESS_COUNTS interval, asynchronous to InputTypeRelease */
|
|
|
|
InputTypeRepeat, /**< Repeat event, emitted with INPUT_LONG_PRESS_COUNTS period after InputTypeLong event */
|
2022-11-02 17:36:17 +03:00
|
|
|
InputTypeMAX, /**< Special value for exceptional */
|
2021-02-10 11:56:05 +03:00
|
|
|
} InputType;
|
2020-10-02 09:44:05 +03:00
|
|
|
|
2021-11-01 23:35:54 +03:00
|
|
|
/** Input Event, dispatches with FuriPubSub */
|
2020-10-02 09:44:05 +03:00
|
|
|
typedef struct {
|
2023-03-09 20:13:18 +03:00
|
|
|
union {
|
|
|
|
uint32_t sequence;
|
|
|
|
struct {
|
|
|
|
uint8_t sequence_source : 2;
|
|
|
|
uint32_t sequence_counter : 30;
|
|
|
|
};
|
|
|
|
};
|
2021-02-10 11:56:05 +03:00
|
|
|
InputKey key;
|
|
|
|
InputType type;
|
2020-10-02 09:44:05 +03:00
|
|
|
} InputEvent;
|
2021-08-31 11:22:52 +03:00
|
|
|
|
|
|
|
/** Get human readable input key name
|
|
|
|
* @param key - InputKey
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
const char* input_get_key_name(InputKey key);
|
|
|
|
|
|
|
|
/** Get human readable input type name
|
|
|
|
* @param type - InputType
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
const char* input_get_type_name(InputType type);
|
2022-09-14 19:11:38 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|