picofuse

event.h
1 
26 #pragma once
27 #include "device.h"
28 #include "keycode.h"
29 #include <picofuse/hw/usb.h>
30 #include <picofuse/hw/wifi.h>
31 #include <picofuse/pix/types.h>
32 #include <picofuse/sys/date.h>
33 #include <picofuse/sys/io.h>
34 #include <stdbool.h>
35 
46 #ifndef HID_EVENT_CAPACITY
47 #define HID_EVENT_CAPACITY 16u
48 #endif
49 
54 typedef enum {
55  hid_event_type_none = 0,
56  hid_event_type_keycode = 1,
57  hid_event_type_touch = 2,
58  hid_event_type_metric = 3,
59  hid_event_type_timer = 4,
60  hid_event_type_signal = 5,
61  hid_event_type_wifi = 6,
62  hid_event_type_iostream = 7,
63  hid_event_type_time = 8,
64  hid_event_type_usb = 9,
66 
71 typedef struct {
73  uint16_t keycode;
75 
80 typedef struct {
83  uint8_t slot;
84 } hid_touch_t;
85 
90 typedef struct {
91  const char *name;
92  const char *unit;
93  float value;
94 } hid_metric_t;
95 
100 typedef struct {
101  void *userdata;
102 } hid_timer_t;
103 
108 typedef struct {
110 } hid_signal_t;
111 
124 typedef struct {
127  bool has_network;
129 } hid_wifi_t;
130 
143 typedef struct {
146  bool has_device;
148 } hid_usb_t;
149 
154 typedef struct {
160 
165 typedef struct {
167 } hid_time_t;
168 
173 typedef struct {
176  union {
177  hid_keycode_t keycode;
178  hid_touch_t touch;
179  hid_metric_t metric;
180  hid_timer_t timer;
181  hid_signal_t signal;
182  hid_wifi_t wifi;
183  hid_iostream_t iostream;
184  hid_time_t time;
185  hid_usb_t usb;
186  } data;
187 } hid_event_t;
188 
203  uint16_t keycode);
204 
215 bool hid_event_queue_metric_float(hid_device_t *device, const char *name,
216  const char *unit, float value);
217 
237  pix_point_t point, uint8_t slot);
238 
248 
260  const hw_wifi_network_t *network);
261 
273  const hw_usb_device_t *usb_device);
274 
285  sys_iostream_event_t events);
286 
296 bool hid_event_queue_time(hid_device_t *device, const sys_date_t *date);
297 
311 void hid_event_free(hid_event_t *event);
bool hid_event_queue_keycode(hid_device_t *device, hid_state_t state, uint16_t keycode)
Queue a keycode-based HID event to the owning HID instance queue.
Wi-Fi-oriented HID event payload.
Definition: event.h:124
hid_state_t
Input state flags used by the input manager and key handling.
Definition: keycode.h:23
void hid_event_free(hid_event_t *event)
Free a HID event allocated internally by HID queue helpers.
hw_usb_event_t event
USB hotplug event (see hw_usb_event_t).
Definition: event.h:144
hw_wifi_event_t event
Wi-Fi status event (see hw_wifi_event_t).
Definition: event.h:125
hw_wifi_network_t network
Associated network info - only valid if has_network is true.
Definition: event.h:126
uint16_t keycode
HID keycode associated with the event.
Definition: event.h:73
void * userdata
Timer userdata associated with this event.
Definition: event.h:101
Opaque byte streams for reading, writing, seeking, and readiness notification.
const char * unit
Metric unit string.
Definition: event.h:92
bool hid_event_queue_metric_float(hid_device_t *device, const char *name, const char *unit, float value)
Queue a float metric HID event to a HID instance queue.
Touch-oriented HID event payload.
Definition: event.h:80
USB-hotplug-oriented HID event payload.
Definition: event.h:143
pix_point_t point
Touch/event coordinates in pixels.
Definition: event.h:82
const char * name
Metric name.
Definition: event.h:91
sys_env_signal_t signal
Environment signal captured by HID source.
Definition: event.h:109
bool hid_event_queue_touch(hid_device_t *device, hid_state_t state, pix_point_t point, uint8_t slot)
Queue a touch HID event to the owning HID instance queue.
hw_usb_device_t device
Associated device - only valid if has_device is true.
Definition: event.h:145
Time-oriented HID event payload.
Definition: event.h:165
sys_env_signal_t
Environment signal types.
Definition: env.h:57
Wi-Fi management interface.
hid_event_type_t type
Event payload tag.
Definition: event.h:175
sys_iostream_event_t events
Readiness event(s) that occurred - see sys_iostream_event_t; may combine sys_iostream_event_read and ...
Definition: event.h:155
hid_device_t * device
HID child-device associated with this event.
Definition: event.h:174
Point structure representing X,Y coordinates.
Definition: types.h:18
bool hid_event_queue_wifi(hid_device_t *device, hw_wifi_event_t event, const hw_wifi_network_t *network)
Queue a Wi-Fi status HID event to the owning HID instance queue.
Describes a discovered Wi-Fi network (scan result).
Definition: wifi.h:121
struct hid_device_t hid_device_t
HID child-device descriptor tracked by a HID instance.
Definition: device.h:46
Represents a single HID input event.
Definition: event.h:173
bool hid_event_queue_signal(hid_device_t *device, sys_env_signal_t signal)
Queue a signal HID event to the owning HID instance queue.
float value
Metric value.
Definition: event.h:93
Stream-readiness-oriented HID event payload.
Definition: event.h:154
hw_wifi_event_t
Wi-Fi callback event flags.
Definition: wifi.h:88
bool hid_event_queue_iostream(hid_device_t *device, sys_iostream_event_t events)
Queue a stream-readiness HID event to the owning HID instance queue.
USB host interface.
sys_iostream_event_t
Stream readiness event flags.
Definition: io.h:79
Keycode-oriented HID event payload.
Definition: event.h:71
bool hid_event_queue_usb(hid_device_t *device, hw_usb_event_t event, const hw_usb_device_t *usb_device)
Queue a USB hotplug HID event to the owning HID instance queue.
sys_date_t date
Reported date/time (UTC - tzoffset is always 0).
Definition: event.h:166
Describes one interface of a USB device observed by the host.
Definition: usb.h:251
HID device lifecycle and polling interface.
Represents a system date and time.
Definition: date.h:25
HID keycode and input-state definitions.
Timer-oriented HID event payload.
Definition: event.h:100
hid_state_t state
HID state flags for this event.
Definition: event.h:72
bool hid_event_queue_time(hid_device_t *device, const sys_date_t *date)
Queue a time HID event to the owning HID instance queue.
hw_usb_event_t
USB hotplug event type.
Definition: usb.h:135
Defines date and wall-clock time APIs.
uint8_t slot
Touch slot index for multi-touch tracking.
Definition: event.h:83
Signal-oriented HID event payload.
Definition: event.h:108
Metric-oriented HID event payload.
Definition: event.h:90
hid_state_t state
HID state flags for this touch event.
Definition: event.h:81
hid_event_type_t
HID event payload selector.
Definition: event.h:54