mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 04:30:06 +01:00
plugin: use evdev_frame_append_one() for simpler code
Instead of creating a struct and passing it in as array let's use the helper function. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1260>
This commit is contained in:
parent
a635176632
commit
892e5d35c7
3 changed files with 18 additions and 37 deletions
|
|
@ -250,18 +250,15 @@ debounce_notify_button(struct plugin_device *device,
|
|||
struct evdev_frame *frame,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
const struct evdev_event button = {
|
||||
.usage = device->button_usage,
|
||||
.value = state == LIBINPUT_BUTTON_STATE_PRESSED ? 1 : 0,
|
||||
};
|
||||
|
||||
_unref_(evdev_frame) *button_frame = NULL;
|
||||
if (frame == NULL) {
|
||||
button_frame = evdev_frame_new(2);
|
||||
frame = button_frame;
|
||||
}
|
||||
|
||||
evdev_frame_append(frame, &button, 1);
|
||||
evdev_frame_append_one(frame,
|
||||
device->button_usage,
|
||||
state == LIBINPUT_BUTTON_STATE_PRESSED ? 1 : 0);
|
||||
evdev_frame_set_time(frame, device->button_time);
|
||||
|
||||
libinput_plugin_prepend_evdev_frame(device->parent->plugin,
|
||||
|
|
|
|||
|
|
@ -250,42 +250,30 @@ static void
|
|||
wheel_queue_scroll_events(struct plugin_device *pd, struct evdev_frame *frame)
|
||||
{
|
||||
if (pd->hi_res.y != 0) {
|
||||
struct evdev_event e = {
|
||||
.usage = evdev_usage_from(EVDEV_REL_WHEEL_HI_RES),
|
||||
.value = pd->hi_res.y,
|
||||
};
|
||||
|
||||
evdev_frame_append(frame, &e, 1);
|
||||
evdev_frame_append_one(frame,
|
||||
evdev_usage_from(EVDEV_REL_WHEEL_HI_RES),
|
||||
pd->hi_res.y);
|
||||
pd->hi_res.y = 0;
|
||||
}
|
||||
|
||||
if (pd->lo_res.y != 0) {
|
||||
struct evdev_event e = {
|
||||
.usage = evdev_usage_from(EVDEV_REL_WHEEL),
|
||||
.value = pd->lo_res.y,
|
||||
};
|
||||
|
||||
evdev_frame_append(frame, &e, 1);
|
||||
evdev_frame_append_one(frame,
|
||||
evdev_usage_from(EVDEV_REL_WHEEL),
|
||||
pd->lo_res.y);
|
||||
pd->lo_res.y = 0;
|
||||
}
|
||||
|
||||
if (pd->hi_res.x != 0) {
|
||||
struct evdev_event e = {
|
||||
.usage = evdev_usage_from(EVDEV_REL_HWHEEL_HI_RES),
|
||||
.value = pd->hi_res.x,
|
||||
};
|
||||
|
||||
evdev_frame_append(frame, &e, 1);
|
||||
evdev_frame_append_one(frame,
|
||||
evdev_usage_from(EVDEV_REL_HWHEEL_HI_RES),
|
||||
pd->hi_res.x);
|
||||
pd->hi_res.x = 0;
|
||||
}
|
||||
|
||||
if (pd->lo_res.x != 0) {
|
||||
struct evdev_event e = {
|
||||
.usage = evdev_usage_from(EVDEV_REL_HWHEEL),
|
||||
.value = pd->lo_res.x,
|
||||
};
|
||||
|
||||
evdev_frame_append(frame, &e, 1);
|
||||
evdev_frame_append_one(frame,
|
||||
evdev_usage_from(EVDEV_REL_HWHEEL),
|
||||
pd->lo_res.x);
|
||||
pd->lo_res.x = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,13 +152,9 @@ forced_tool_plugin_device_handle_frame(struct libinput_plugin *libinput_plugin,
|
|||
* stylus is def. in proximity). We don't do this for pure
|
||||
* button events because we discard those.
|
||||
*/
|
||||
const struct evdev_event prox = {
|
||||
.usage = evdev_usage_from(EVDEV_BTN_TOOL_PEN),
|
||||
.value = 1,
|
||||
};
|
||||
evdev_frame_append(frame,
|
||||
&prox,
|
||||
1); /* libinput's event frame will have space */
|
||||
evdev_frame_append_one(frame,
|
||||
evdev_usage_from(EVDEV_BTN_TOOL_PEN),
|
||||
1); /* libinput's event frame will have space */
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue