tablet: move the current tool bits into a substruct

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2019-04-01 15:10:55 +10:00
parent caadad75c0
commit 4912e7ed4a
2 changed files with 20 additions and 18 deletions

View file

@ -234,7 +234,7 @@ tablet_process_absolute(struct tablet_dispatch *tablet,
/* tool_id is the identifier for the tool we can use in libwacom /* tool_id is the identifier for the tool we can use in libwacom
* to identify it (if we have one anyway) */ * to identify it (if we have one anyway) */
case ABS_MISC: case ABS_MISC:
tablet->current_tool_id = e->value; tablet->current_tool.id = e->value;
break; break;
/* Intuos 3 strip data. Should only happen on the Pad device, not on /* Intuos 3 strip data. Should only happen on the Pad device, not on
the Pen device. */ the Pen device. */
@ -278,7 +278,7 @@ tablet_update_tool(struct tablet_dispatch *tablet,
assert(tool != LIBINPUT_TOOL_NONE); assert(tool != LIBINPUT_TOOL_NONE);
if (enabled) { if (enabled) {
tablet->current_tool_type = tool; tablet->current_tool.type = tool;
tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY); tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY); tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
} }
@ -566,8 +566,8 @@ tablet_update_rotation(struct tablet_dispatch *tablet,
{ {
/* We must check ROTATION_Z after TILT_X/Y so that the tilt axes are /* We must check ROTATION_Z after TILT_X/Y so that the tilt axes are
* already normalized and set if we have the mouse/lens tool */ * already normalized and set if we have the mouse/lens tool */
if (tablet->current_tool_type == LIBINPUT_TABLET_TOOL_TYPE_MOUSE || if (tablet->current_tool.type == LIBINPUT_TABLET_TOOL_TYPE_MOUSE ||
tablet->current_tool_type == LIBINPUT_TABLET_TOOL_TYPE_LENS) { tablet->current_tool.type == LIBINPUT_TABLET_TOOL_TYPE_LENS) {
tablet_update_mouse_rotation(tablet, device); tablet_update_mouse_rotation(tablet, device);
clear_bit(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_X); clear_bit(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
clear_bit(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y); clear_bit(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
@ -819,7 +819,7 @@ tablet_process_misc(struct tablet_dispatch *tablet,
switch (e->code) { switch (e->code) {
case MSC_SERIAL: case MSC_SERIAL:
if (e->value != -1) if (e->value != -1)
tablet->current_tool_serial = e->value; tablet->current_tool.serial = e->value;
break; break;
case MSC_SCAN: case MSC_SCAN:
@ -1192,8 +1192,8 @@ sanitize_mouse_lens_rotation(struct tablet_dispatch *tablet)
{ {
/* If we have a mouse/lens cursor and the tilt changed, the rotation /* If we have a mouse/lens cursor and the tilt changed, the rotation
changed. Mark this, calculate the angle later */ changed. Mark this, calculate the angle later */
if ((tablet->current_tool_type == LIBINPUT_TABLET_TOOL_TYPE_MOUSE || if ((tablet->current_tool.type == LIBINPUT_TABLET_TOOL_TYPE_MOUSE ||
tablet->current_tool_type == LIBINPUT_TABLET_TOOL_TYPE_LENS) && tablet->current_tool.type == LIBINPUT_TABLET_TOOL_TYPE_LENS) &&
(bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) || (bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_X) ||
bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y))) bit_is_set(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_TILT_Y)))
set_bit(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z); set_bit(tablet->changed_axes, LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
@ -1641,13 +1641,13 @@ tablet_flush(struct tablet_dispatch *tablet,
{ {
struct libinput_tablet_tool *tool; struct libinput_tablet_tool *tool;
if (tablet->current_tool_type == LIBINPUT_TOOL_NONE) if (tablet->current_tool.type == LIBINPUT_TOOL_NONE)
return; return;
tool = tablet_get_tool(tablet, tool = tablet_get_tool(tablet,
tablet->current_tool_type, tablet->current_tool.type,
tablet->current_tool_id, tablet->current_tool.id,
tablet->current_tool_serial); tablet->current_tool.serial);
if (!tool) if (!tool)
return; /* OOM */ return; /* OOM */
@ -1823,7 +1823,7 @@ tablet_proximity_quirk_update(struct tablet_dispatch *tablet,
* BTN_TOOL_PEN and move on from there. */ * BTN_TOOL_PEN and move on from there. */
if (e->type == EV_SYN && if (e->type == EV_SYN &&
tablet_has_status(tablet, TABLET_AXES_UPDATED) && tablet_has_status(tablet, TABLET_AXES_UPDATED) &&
tablet->current_tool_type == LIBINPUT_TOOL_NONE) { tablet->current_tool.type == LIBINPUT_TOOL_NONE) {
tablet->quirks.proximity_out_forced = true; tablet->quirks.proximity_out_forced = true;
tablet->quirks.need_to_force_prox_out = true; tablet->quirks.need_to_force_prox_out = true;
} }
@ -2000,7 +2000,7 @@ tablet_check_initial_proximity(struct evdev_device *device,
if (tablet->quirks.need_to_force_prox_out) if (tablet->quirks.need_to_force_prox_out)
tablet_proximity_out_quirk_set_timer(tablet, libinput_now(li)); tablet_proximity_out_quirk_set_timer(tablet, libinput_now(li));
tablet->current_tool_id = tablet->current_tool.id =
libevdev_get_event_value(device->evdev, libevdev_get_event_value(device->evdev,
EV_ABS, EV_ABS,
ABS_MISC); ABS_MISC);
@ -2009,7 +2009,7 @@ tablet_check_initial_proximity(struct evdev_device *device,
* to 0 for now. On the first real event from the device we get the * to 0 for now. On the first real event from the device we get the
* serial (if any) and that event will be converted into a proximity * serial (if any) and that event will be converted into a proximity
* event */ * event */
tablet->current_tool_serial = 0; tablet->current_tool.serial = 0;
} }
static struct evdev_dispatch_interface tablet_interface = { static struct evdev_dispatch_interface tablet_interface = {
@ -2157,7 +2157,7 @@ tablet_init(struct tablet_dispatch *tablet,
tablet->base.interface = &tablet_interface; tablet->base.interface = &tablet_interface;
tablet->device = device; tablet->device = device;
tablet->status = TABLET_NONE; tablet->status = TABLET_NONE;
tablet->current_tool_type = LIBINPUT_TOOL_NONE; tablet->current_tool.type = LIBINPUT_TOOL_NONE;
list_init(&tablet->tool_list); list_init(&tablet->tool_list);
if (tablet_reject_device(device)) if (tablet_reject_device(device))

View file

@ -74,9 +74,11 @@ struct tablet_dispatch {
struct button_state button_state; struct button_state button_state;
struct button_state prev_button_state; struct button_state prev_button_state;
enum libinput_tablet_tool_type current_tool_type; struct {
uint32_t current_tool_id; enum libinput_tablet_tool_type type;
uint32_t current_tool_serial; uint32_t id;
uint32_t serial;
} current_tool;
uint32_t cursor_proximity_threshold; uint32_t cursor_proximity_threshold;