input.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * @file input.h
  3. * Input: main API
  4. */
  5. #pragma once
  6. #include <furi_hal_resources.h>
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define RECORD_INPUT_EVENTS "input_events"
  11. #define INPUT_SEQUENCE_SOURCE_HARDWARE (0u)
  12. #define INPUT_SEQUENCE_SOURCE_SOFTWARE (1u)
  13. /** Input Types
  14. * Some of them are physical events and some logical
  15. */
  16. typedef enum {
  17. InputTypePress, /**< Press event, emitted after debounce */
  18. InputTypeRelease, /**< Release event, emitted after debounce */
  19. InputTypeShort, /**< Short event, emitted after InputTypeRelease done within INPUT_LONG_PRESS interval */
  20. InputTypeLong, /**< Long event, emitted after INPUT_LONG_PRESS_COUNTS interval, asynchronous to InputTypeRelease */
  21. InputTypeRepeat, /**< Repeat event, emitted with INPUT_LONG_PRESS_COUNTS period after InputTypeLong event */
  22. InputTypeMAX, /**< Special value for exceptional */
  23. } InputType;
  24. /** Input Event, dispatches with FuriPubSub */
  25. typedef struct {
  26. union {
  27. uint32_t sequence;
  28. struct {
  29. uint8_t sequence_source : 2;
  30. uint32_t sequence_counter : 30;
  31. };
  32. };
  33. InputKey key;
  34. InputType type;
  35. } InputEvent;
  36. /** Get human readable input key name
  37. * @param key - InputKey
  38. * @return string
  39. */
  40. const char* input_get_key_name(InputKey key);
  41. /** Get human readable input type name
  42. * @param type - InputType
  43. * @return string
  44. */
  45. const char* input_get_type_name(InputType type);
  46. #ifdef __cplusplus
  47. }
  48. #endif