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  uint8_t pressure;
85 } hid_touch_t;
90 
95 typedef struct {
96  const char *name;
97  const char *unit;
98  float value;
99 } hid_metric_t;
100 
105 typedef struct {
106  void *userdata;
107 } hid_timer_t;
108 
113 typedef struct {
115 } hid_signal_t;
116 
129 typedef struct {
132  bool has_network;
134 } hid_wifi_t;
135 
148 typedef struct {
151  bool has_device;
153 } hid_usb_t;
154 
159 typedef struct {
165 
170 typedef struct {
172 } hid_time_t;
173 
178 typedef struct {
181  union {
182  hid_keycode_t keycode;
183  hid_touch_t touch;
184  hid_metric_t metric;
185  hid_timer_t timer;
186  hid_signal_t signal;
187  hid_wifi_t wifi;
188  hid_iostream_t iostream;
189  hid_time_t time;
190  hid_usb_t usb;
191  } data;
192 } hid_event_t;
193 
208  uint16_t keycode);
209 
220 bool hid_event_queue_metric_float(hid_device_t *device, const char *name,
221  const char *unit, float value);
222 
244  pix_point_t point, uint8_t slot, uint8_t pressure);
245 
255 
267  const hw_wifi_network_t *network);
268 
280  const hw_usb_device_t *usb_device);
281 
292  sys_iostream_event_t events);
293 
303 bool hid_event_queue_time(hid_device_t *device, const sys_date_t *date);
304 
318 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:129
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:149
hw_wifi_event_t event
Wi-Fi status event (see hw_wifi_event_t).
Definition: event.h:130
hw_wifi_network_t network
Associated network info - only valid if has_network is true.
Definition: event.h:131
uint16_t keycode
HID keycode associated with the event.
Definition: event.h:73
void * userdata
Timer userdata associated with this event.
Definition: event.h:106
Opaque byte streams for reading, writing, seeking, and readiness notification.
const char * unit
Metric unit string.
Definition: event.h:97
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:148
pix_point_t point
Touch/event coordinates in pixels.
Definition: event.h:82
const char * name
Metric name.
Definition: event.h:96
sys_env_signal_t signal
Environment signal captured by HID source.
Definition: event.h:114
hw_usb_device_t device
Associated device - only valid if has_device is true.
Definition: event.h:150
Time-oriented HID event payload.
Definition: event.h:170
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:180
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:160
hid_device_t * device
HID child-device associated with this event.
Definition: event.h:179
Point structure representing X,Y coordinates.
Definition: types.h:17
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:178
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:98
Stream-readiness-oriented HID event payload.
Definition: event.h:159
bool hid_event_queue_touch(hid_device_t *device, hid_state_t state, pix_point_t point, uint8_t slot, uint8_t pressure)
Queue a touch HID event to the owning HID instance queue.
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:171
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
uint8_t pressure
Raw pressure reading, where the controller supports one (e.g.
Definition: event.h:84
HID keycode and input-state definitions.
Timer-oriented HID event payload.
Definition: event.h:105
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:113
Metric-oriented HID event payload.
Definition: event.h:95
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