virtual_portal.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <notification/notification_messages.h>
  3. #include <furi_hal_light.h>
  4. #include "pof_token.h"
  5. #define POF_TOKEN_LIMIT 16
  6. typedef enum {
  7. PoFHid,
  8. PoFXbox360
  9. } PoFType;
  10. typedef enum {
  11. EventExit = (1 << 0),
  12. EventReset = (1 << 1),
  13. EventRx = (1 << 2),
  14. EventTx = (1 << 3),
  15. EventTxComplete = (1 << 4),
  16. EventResetSio = (1 << 5),
  17. EventTxImmediate = (1 << 6),
  18. EventLed = (1 << 7),
  19. EventAll = EventExit | EventReset | EventRx | EventTx | EventTxComplete | EventResetSio |
  20. EventTxImmediate | EventLed,
  21. } PoFEvent;
  22. typedef struct {
  23. uint8_t r;
  24. uint8_t g;
  25. uint8_t b;
  26. uint16_t delay;
  27. } VirtualPortalLed;
  28. typedef struct {
  29. PoFToken* tokens[POF_TOKEN_LIMIT];
  30. uint8_t sequence_number;
  31. bool active;
  32. bool speaker;
  33. NotificationApp* notifications;
  34. PoFType type;
  35. FuriThread* thread;
  36. VirtualPortalLed left;
  37. VirtualPortalLed right;
  38. VirtualPortalLed trap;
  39. } VirtualPortal;
  40. VirtualPortal* virtual_portal_alloc(NotificationApp* notifications);
  41. void virtual_portal_free(VirtualPortal* virtual_portal);
  42. void virtual_portal_cleanup(VirtualPortal* virtual_portal);
  43. void virtual_portal_load_token(VirtualPortal* virtual_portal, PoFToken* pof_token);
  44. int virtual_portal_process_message(
  45. VirtualPortal* virtual_portal,
  46. uint8_t* message,
  47. uint8_t* response);
  48. int virtual_portal_send_status(VirtualPortal* virtual_portal, uint8_t* response);