mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 06:10:56 +00:00
[input] Make device add/remove events broadcast
It proved necessary to support broadcasting events to all event handlers, with device add/remove being the first such events.
This commit is contained in:
parent
fae9e043df
commit
14a5ec7b41
2 changed files with 15 additions and 0 deletions
|
@ -71,6 +71,11 @@ typedef enum {
|
|||
ie_button,
|
||||
} IE_event_type;
|
||||
|
||||
#define IE_broadcast_events (0 \
|
||||
| (1 << ie_add_device) \
|
||||
| (1 << ie_remove_device) \
|
||||
)
|
||||
|
||||
typedef struct {
|
||||
IE_event_type type;
|
||||
uint64_t when;
|
||||
|
|
|
@ -54,6 +54,16 @@ static unsigned focus;
|
|||
int
|
||||
IE_Send_Event (const IE_event_t *event)
|
||||
{
|
||||
if ((1 << event->type) & IE_broadcast_events) {
|
||||
for (size_t i = 0; i < ie_handlers.size; i++) {
|
||||
ie_reghandler_t *reg = &ie_handlers.a[i];
|
||||
if (reg->handler) {
|
||||
reg->handler (event, reg->data);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (focus < ie_handlers.size && ie_handlers.a[focus].handler) {
|
||||
ie_reghandler_t *reg = &ie_handlers.a[focus];
|
||||
return reg->handler (event, reg->data);
|
||||
|
|
Loading…
Reference in a new issue