EVDEV: Add shortcut functions for event types
Add wrappers around generic evdev_push_event for specific event types: EV_KEY/EV_REL/EV_ABS etc... Submitted by: Vladimir Kondratiev <wulf@cicgroup.ru>
This commit is contained in:
parent
4fe54d4279
commit
73362d0e56
@ -822,21 +822,6 @@ evdev_inject_event(struct evdev_dev *evdev, uint16_t type, uint16_t code,
|
||||
return (ret);
|
||||
}
|
||||
|
||||
inline int
|
||||
evdev_sync(struct evdev_dev *evdev)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_SYN, SYN_REPORT, 1));
|
||||
}
|
||||
|
||||
|
||||
inline int
|
||||
evdev_mt_sync(struct evdev_dev *evdev)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_SYN, SYN_MT_REPORT, 1));
|
||||
}
|
||||
|
||||
int
|
||||
evdev_register_client(struct evdev_dev *evdev, struct evdev_client *client)
|
||||
{
|
||||
|
@ -97,8 +97,6 @@ int evdev_register(struct evdev_dev *);
|
||||
int evdev_register_mtx(struct evdev_dev *, struct mtx *);
|
||||
int evdev_unregister(struct evdev_dev *);
|
||||
int evdev_push_event(struct evdev_dev *, uint16_t, uint16_t, int32_t);
|
||||
int evdev_sync(struct evdev_dev *);
|
||||
int evdev_mt_sync(struct evdev_dev *);
|
||||
void evdev_support_prop(struct evdev_dev *, uint16_t);
|
||||
void evdev_support_event(struct evdev_dev *, uint16_t);
|
||||
void evdev_support_key(struct evdev_dev *, uint16_t);
|
||||
@ -129,4 +127,68 @@ void evdev_push_leds(struct evdev_dev *, int);
|
||||
void evdev_push_repeats(struct evdev_dev *, keyboard_t *);
|
||||
evdev_event_t evdev_ev_kbd_event;
|
||||
|
||||
/* Event reporting shortcuts: */
|
||||
static __inline int
|
||||
evdev_sync(struct evdev_dev *evdev)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_SYN, SYN_REPORT, 1));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_mt_sync(struct evdev_dev *evdev)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_SYN, SYN_MT_REPORT, 1));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_push_key(struct evdev_dev *evdev, uint16_t code, int32_t value)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_KEY, code, value != 0));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_push_rel(struct evdev_dev *evdev, uint16_t code, int32_t value)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_REL, code, value));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_push_abs(struct evdev_dev *evdev, uint16_t code, int32_t value)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_ABS, code, value));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_push_msc(struct evdev_dev *evdev, uint16_t code, int32_t value)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_MSC, code, value));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_push_led(struct evdev_dev *evdev, uint16_t code, int32_t value)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_LED, code, value != 0));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_push_snd(struct evdev_dev *evdev, uint16_t code, int32_t value)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_SND, code, value != 0));
|
||||
}
|
||||
|
||||
static __inline int
|
||||
evdev_push_sw(struct evdev_dev *evdev, uint16_t code, int32_t value)
|
||||
{
|
||||
|
||||
return (evdev_push_event(evdev, EV_SW, code, value != 0));
|
||||
}
|
||||
|
||||
#endif /* _DEV_EVDEV_EVDEV_H */
|
||||
|
@ -271,8 +271,8 @@ evdev_push_mouse_btn(struct evdev_dev *evdev, int buttons)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < nitems(evdev_mouse_button_codes); i++)
|
||||
evdev_push_event(evdev, EV_KEY, evdev_mouse_button_codes[i],
|
||||
(buttons & (1 << i)) != 0);
|
||||
evdev_push_key(evdev, evdev_mouse_button_codes[i],
|
||||
buttons & (1 << i));
|
||||
}
|
||||
|
||||
void
|
||||
@ -285,8 +285,7 @@ evdev_push_leds(struct evdev_dev *evdev, int leds)
|
||||
return;
|
||||
|
||||
for (i = 0; i < nitems(evdev_led_codes); i++)
|
||||
evdev_push_event(evdev, EV_LED, evdev_led_codes[i],
|
||||
(leds & (1 << i)) != 0);
|
||||
evdev_push_led(evdev, evdev_led_codes[i], leds & (1 << i));
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user