mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-08 11:19:14 +02:00
Switch the totem backend to struct evdev_event
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1215>
This commit is contained in:
parent
56bad53f29
commit
4eb8ccb10d
1 changed files with 26 additions and 23 deletions
|
|
@ -179,21 +179,21 @@ totem_set_touch_device_enabled(struct totem_dispatch *totem,
|
||||||
static void
|
static void
|
||||||
totem_process_key(struct totem_dispatch *totem,
|
totem_process_key(struct totem_dispatch *totem,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct input_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
uint64_t time)
|
||||||
{
|
{
|
||||||
/* ignore kernel key repeat */
|
/* ignore kernel key repeat */
|
||||||
if (e->value == 2)
|
if (e->value == 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch(e->code) {
|
switch (evdev_usage_enum(e->usage)) {
|
||||||
case BTN_0:
|
case EVDEV_BTN_0:
|
||||||
totem->button_state_now = !!e->value;
|
totem->button_state_now = !!e->value;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
evdev_log_info(device,
|
evdev_log_info(device,
|
||||||
"Unhandled KEY event code %#x\n",
|
"Unhandled KEY event code %#x\n",
|
||||||
e->code);
|
evdev_usage_as_uint32_t(e->usage));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -201,13 +201,13 @@ totem_process_key(struct totem_dispatch *totem,
|
||||||
static void
|
static void
|
||||||
totem_process_abs(struct totem_dispatch *totem,
|
totem_process_abs(struct totem_dispatch *totem,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct input_event *e,
|
struct evdev_event *e,
|
||||||
uint64_t time)
|
uint64_t time)
|
||||||
{
|
{
|
||||||
struct totem_slot *slot = &totem->slots[totem->slot];
|
struct totem_slot *slot = &totem->slots[totem->slot];
|
||||||
|
|
||||||
switch(e->code) {
|
switch (evdev_usage_enum(e->usage)) {
|
||||||
case ABS_MT_SLOT:
|
case EVDEV_ABS_MT_SLOT:
|
||||||
if ((size_t)e->value >= totem->nslots) {
|
if ((size_t)e->value >= totem->nslots) {
|
||||||
evdev_log_bug_libinput(device,
|
evdev_log_bug_libinput(device,
|
||||||
"exceeded slot count (%d of max %zd)\n",
|
"exceeded slot count (%d of max %zd)\n",
|
||||||
|
|
@ -217,7 +217,7 @@ totem_process_abs(struct totem_dispatch *totem,
|
||||||
}
|
}
|
||||||
totem->slot = e->value;
|
totem->slot = e->value;
|
||||||
return;
|
return;
|
||||||
case ABS_MT_TRACKING_ID:
|
case EVDEV_ABS_MT_TRACKING_ID:
|
||||||
/* If the totem is already down on init, we currently
|
/* If the totem is already down on init, we currently
|
||||||
ignore it */
|
ignore it */
|
||||||
if (e->value >= 0)
|
if (e->value >= 0)
|
||||||
|
|
@ -225,35 +225,35 @@ totem_process_abs(struct totem_dispatch *totem,
|
||||||
else if (slot->state != SLOT_STATE_NONE)
|
else if (slot->state != SLOT_STATE_NONE)
|
||||||
slot->state = SLOT_STATE_END;
|
slot->state = SLOT_STATE_END;
|
||||||
break;
|
break;
|
||||||
case ABS_MT_POSITION_X:
|
case EVDEV_ABS_MT_POSITION_X:
|
||||||
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_X);
|
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_X);
|
||||||
break;
|
break;
|
||||||
case ABS_MT_POSITION_Y:
|
case EVDEV_ABS_MT_POSITION_Y:
|
||||||
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_Y);
|
set_bit(slot->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_Y);
|
||||||
break;
|
break;
|
||||||
case ABS_MT_TOUCH_MAJOR:
|
case EVDEV_ABS_MT_TOUCH_MAJOR:
|
||||||
set_bit(slot->changed_axes,
|
set_bit(slot->changed_axes,
|
||||||
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR);
|
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR);
|
||||||
break;
|
break;
|
||||||
case ABS_MT_TOUCH_MINOR:
|
case EVDEV_ABS_MT_TOUCH_MINOR:
|
||||||
set_bit(slot->changed_axes,
|
set_bit(slot->changed_axes,
|
||||||
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR);
|
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR);
|
||||||
break;
|
break;
|
||||||
case ABS_MT_ORIENTATION:
|
case EVDEV_ABS_MT_ORIENTATION:
|
||||||
set_bit(slot->changed_axes,
|
set_bit(slot->changed_axes,
|
||||||
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
|
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
|
||||||
break;
|
break;
|
||||||
case ABS_MT_TOOL_TYPE:
|
case EVDEV_ABS_MT_TOOL_TYPE:
|
||||||
if (e->value != MT_TOOL_DIAL) {
|
if (e->value != MT_TOOL_DIAL) {
|
||||||
evdev_log_info(device,
|
evdev_log_info(device,
|
||||||
"Unexpected tool type %#x, changing to dial\n",
|
"Unexpected tool type %#x, changing to dial\n",
|
||||||
e->code);
|
evdev_usage_as_uint32_t(e->usage));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
evdev_log_info(device,
|
evdev_log_info(device,
|
||||||
"Unhandled ABS event code %#x\n",
|
"Unhandled ABS event code %#x\n",
|
||||||
e->code);
|
evdev_usage_as_uint32_t(e->usage));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -527,19 +527,22 @@ totem_handle_state(struct totem_dispatch *totem,
|
||||||
static void
|
static void
|
||||||
totem_interface_process(struct evdev_dispatch *dispatch,
|
totem_interface_process(struct evdev_dispatch *dispatch,
|
||||||
struct evdev_device *device,
|
struct evdev_device *device,
|
||||||
struct input_event *e,
|
struct input_event *input_event,
|
||||||
uint64_t time)
|
uint64_t time)
|
||||||
{
|
{
|
||||||
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
struct totem_dispatch *totem = totem_dispatch(dispatch);
|
||||||
enum totem_slot_state global_state;
|
enum totem_slot_state global_state;
|
||||||
bool enable_touch;
|
bool enable_touch;
|
||||||
|
|
||||||
switch(e->type) {
|
struct evdev_event e = evdev_event_from_input_event(input_event, NULL);
|
||||||
|
|
||||||
|
uint16_t type = evdev_event_type(&e);
|
||||||
|
switch(type) {
|
||||||
case EV_ABS:
|
case EV_ABS:
|
||||||
totem_process_abs(totem, device, e, time);
|
totem_process_abs(totem, device, &e, time);
|
||||||
break;
|
break;
|
||||||
case EV_KEY:
|
case EV_KEY:
|
||||||
totem_process_key(totem, device, e, time);
|
totem_process_key(totem, device, &e, time);
|
||||||
break;
|
break;
|
||||||
case EV_MSC:
|
case EV_MSC:
|
||||||
/* timestamp, ignore */
|
/* timestamp, ignore */
|
||||||
|
|
@ -553,9 +556,9 @@ totem_interface_process(struct evdev_dispatch *dispatch,
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
evdev_log_error(device,
|
evdev_log_error(device,
|
||||||
"Unexpected event type %s (%#x)\n",
|
"Unexpected event %s (%#x)\n",
|
||||||
libevdev_event_type_get_name(e->type),
|
evdev_event_get_code_name(&e),
|
||||||
e->type);
|
evdev_usage_as_uint32_t(e.usage));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue