|
CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
|
Subscribe to system events and publish module events. More...
Macros | |
| #define | EVENT_KEY_PRESSED (1u << 0) |
| #define | EVENT_KEY_RELEASED (1u << 1) |
| #define | EVENT_KEY_LONG_PRESS (1u << 2) |
| #define | EVENT_POWER_USB_CONN (1u << 3) |
| #define | EVENT_POWER_USB_DISCONN (1u << 4) |
| #define | EVENT_POWER_CHARGING (1u << 5) |
| #define | EVENT_POWER_BATT_LOW (1u << 6) |
| #define | EVENT_POWER_BATT_CRIT (1u << 7) |
| #define | EVENT_SYSTEM_UNLOCK (1u << 8) |
| #define | EVENT_SYSTEM_LOCK (1u << 9) |
| #define | EVENT_SYSTEM_SLEEP (1u << 10) |
| #define | EVENT_SYSTEM_WAKE (1u << 11) |
| #define | EVENT_BLE_CONNECTED (1u << 12) |
| #define | EVENT_BLE_DISCONNECTED (1u << 13) |
| #define | EVENT_TIMER_TICK (1u << 14) |
| #define | EVENT_MODULE_EVENT (1u << 15) |
| #define | EVENT_DISPLAY_REFRESH (1u << 16) |
Functions | |
| int | host_event_subscribe (uint32_t event_mask, uint32_t action_id) |
| Subscribe to one or more events. | |
| int | host_event_unsubscribe (uint32_t subscription_id) |
| Cancel a subscription returned by host_event_subscribe. | |
| int | host_event_publish (uint32_t module_event_subtype, uint32_t value) |
| Publish an EVENT_MODULE_EVENT carrying subtype and value. | |
Subscribe to system events and publish module events.
Subscriptions are dispatched as plugin actions. Background-capable plugins receive events even when not on screen. The action fires with idx = the event-type ordinal and user_data = the event payload. Each EVENT_* flag is defined as (1u << ordinal), where the ordinal is the value of the matching cdc::core::EventType enumerator - that enum is the single source of truth (a static_assert in host_api_event.cpp guards the match). Plugin-facing events sit first in that enum, so these bits are contiguous. For key events user_data is the ASCII key code ('0'..'9', 'Y' = 89, 'N' = 78).
| #define EVENT_BLE_CONNECTED (1u << 12) |
Definition at line 1677 of file host_api.h.
| #define EVENT_BLE_DISCONNECTED (1u << 13) |
Definition at line 1678 of file host_api.h.
| #define EVENT_DISPLAY_REFRESH (1u << 16) |
A FAST or FULL e-paper refresh is in progress: user_data = 1 at begin, 0 at end. Subscribe to pause animation/game logic while the panel is unreadable.
Definition at line 1684 of file host_api.h.
| #define EVENT_KEY_LONG_PRESS (1u << 2) |
Definition at line 1667 of file host_api.h.
| #define EVENT_KEY_PRESSED (1u << 0) |
Definition at line 1665 of file host_api.h.
| #define EVENT_KEY_RELEASED (1u << 1) |
Definition at line 1666 of file host_api.h.
| #define EVENT_MODULE_EVENT (1u << 15) |
Definition at line 1680 of file host_api.h.
| #define EVENT_POWER_BATT_CRIT (1u << 7) |
Definition at line 1672 of file host_api.h.
| #define EVENT_POWER_BATT_LOW (1u << 6) |
Definition at line 1671 of file host_api.h.
| #define EVENT_POWER_CHARGING (1u << 5) |
Definition at line 1670 of file host_api.h.
| #define EVENT_POWER_USB_CONN (1u << 3) |
Definition at line 1668 of file host_api.h.
| #define EVENT_POWER_USB_DISCONN (1u << 4) |
Definition at line 1669 of file host_api.h.
| #define EVENT_SYSTEM_LOCK (1u << 9) |
Definition at line 1674 of file host_api.h.
| #define EVENT_SYSTEM_SLEEP (1u << 10) |
Definition at line 1675 of file host_api.h.
| #define EVENT_SYSTEM_UNLOCK (1u << 8) |
Definition at line 1673 of file host_api.h.
| #define EVENT_SYSTEM_WAKE (1u << 11) |
Definition at line 1676 of file host_api.h.
| #define EVENT_TIMER_TICK (1u << 14) |
Definition at line 1679 of file host_api.h.
| int host_event_publish | ( | uint32_t | module_event_subtype, |
| uint32_t | value ) |
Publish an EVENT_MODULE_EVENT carrying subtype and value.
Definition at line 139 of file host_api_event.cpp.
References cdc::core::Event::data, HOST_OK, cdc::core::EventBus::instance(), cdc::core::MODULE_EVENT, cdc::core::EventBus::publish(), cdc::core::Event::timestamp, cdc::core::Event::type, and cdc::core::Event::value.
Referenced by cdc::plugin_manager::w_host_event_publish().
| int host_event_subscribe | ( | uint32_t | event_mask, |
| uint32_t | action_id ) |
Subscribe to one or more events.
| event_mask | Bitwise OR of EVENT_* flags. |
| action_id | Plugin action invoked when any subscribed event fires. |
Definition at line 102 of file host_api_event.cpp.
References cdc::plugin_manager::SlotTable< T, N >::allocate(), HOST_ERR_NO_CAPABILITY, HOST_ERR_NO_MEMORY, cdc::core::EventBus::instance(), plg_get_active_plugin(), plg_log_warn(), and cdc::core::EventBus::subscribe().
Referenced by cdc::plugin_manager::w_host_event_subscribe().
| int host_event_unsubscribe | ( | uint32_t | subscription_id | ) |
Cancel a subscription returned by host_event_subscribe.
Definition at line 128 of file host_api_event.cpp.
References HOST_ERR_NOT_FOUND, and HOST_OK.
Referenced by cdc::plugin_manager::w_host_event_unsubscribe().