mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-28 21:20:07 +01:00
tablet: add helper function to access the libinput context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
45d23a6b0e
commit
3824e161ed
2 changed files with 22 additions and 15 deletions
|
|
@ -161,7 +161,7 @@ tablet_process_absolute(struct tablet_dispatch *tablet,
|
|||
case ABS_WHEEL:
|
||||
axis = evcode_to_axis(e->code);
|
||||
if (axis == LIBINPUT_TABLET_TOOL_AXIS_NONE) {
|
||||
log_bug_libinput(device->base.seat->libinput,
|
||||
log_bug_libinput(tablet_libinput_context(tablet),
|
||||
"Invalid ABS event code %#x\n",
|
||||
e->code);
|
||||
break;
|
||||
|
|
@ -192,7 +192,7 @@ tablet_process_absolute(struct tablet_dispatch *tablet,
|
|||
*/
|
||||
case ABS_THROTTLE:
|
||||
default:
|
||||
log_info(device->base.seat->libinput,
|
||||
log_info(tablet_libinput_context(tablet),
|
||||
"Unhandled ABS event code %#x\n", e->code);
|
||||
break;
|
||||
}
|
||||
|
|
@ -595,7 +595,7 @@ tablet_update_button(struct tablet_dispatch *tablet,
|
|||
case BTN_STYLUS2:
|
||||
break;
|
||||
default:
|
||||
log_info(tablet->device->base.seat->libinput,
|
||||
log_info(tablet_libinput_context(tablet),
|
||||
"Unhandled button %s (%#x)\n",
|
||||
libevdev_event_code_get_name(EV_KEY, evcode), evcode);
|
||||
return;
|
||||
|
|
@ -638,7 +638,7 @@ tablet_process_key(struct tablet_dispatch *tablet,
|
|||
{
|
||||
switch (e->code) {
|
||||
case BTN_TOOL_FINGER:
|
||||
log_bug_libinput(device->base.seat->libinput,
|
||||
log_bug_libinput(tablet_libinput_context(tablet),
|
||||
"Invalid tool 'finger' on tablet interface\n");
|
||||
break;
|
||||
case BTN_TOOL_PEN:
|
||||
|
|
@ -692,7 +692,7 @@ tablet_process_relative(struct tablet_dispatch *tablet,
|
|||
case REL_WHEEL:
|
||||
axis = rel_evcode_to_axis(e->code);
|
||||
if (axis == LIBINPUT_TABLET_TOOL_AXIS_NONE) {
|
||||
log_bug_libinput(device->base.seat->libinput,
|
||||
log_bug_libinput(tablet_libinput_context(tablet),
|
||||
"Invalid ABS event code %#x\n",
|
||||
e->code);
|
||||
break;
|
||||
|
|
@ -702,7 +702,7 @@ tablet_process_relative(struct tablet_dispatch *tablet,
|
|||
tablet_set_status(tablet, TABLET_AXES_UPDATED);
|
||||
break;
|
||||
default:
|
||||
log_info(tablet->device->base.seat->libinput,
|
||||
log_info(tablet_libinput_context(tablet),
|
||||
"Unhandled relative axis %s (%#x)\n",
|
||||
libevdev_event_code_get_name(EV_REL, e->code),
|
||||
e->code);
|
||||
|
|
@ -723,7 +723,7 @@ tablet_process_misc(struct tablet_dispatch *tablet,
|
|||
|
||||
break;
|
||||
default:
|
||||
log_info(device->base.seat->libinput,
|
||||
log_info(tablet_libinput_context(tablet),
|
||||
"Unhandled MSC event code %s (%#x)\n",
|
||||
libevdev_event_code_get_name(EV_MSC, e->code),
|
||||
e->code);
|
||||
|
|
@ -757,7 +757,7 @@ tool_set_bits_from_libwacom(const struct tablet_dispatch *tablet,
|
|||
int rc = 1;
|
||||
|
||||
#if HAVE_LIBWACOM
|
||||
struct libinput *libinput = tablet->device->base.seat->libinput;
|
||||
struct libinput *libinput = tablet_libinput_context(tablet);
|
||||
WacomDeviceDatabase *db;
|
||||
const WacomStylus *s = NULL;
|
||||
int code;
|
||||
|
|
@ -902,7 +902,8 @@ tablet_get_tool(struct tablet_dispatch *tablet,
|
|||
struct list *tool_list;
|
||||
|
||||
if (serial) {
|
||||
tool_list = &tablet->device->base.seat->libinput->tool_list;
|
||||
struct libinput *libinput = tablet_libinput_context(tablet);
|
||||
tool_list = &libinput->tool_list;
|
||||
|
||||
/* Check if we already have the tool in our list of tools */
|
||||
list_for_each(t, tool_list, link) {
|
||||
|
|
@ -1124,7 +1125,7 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
|
|||
return;
|
||||
|
||||
if (offset > axis_range_percentage(pressure, 20)) {
|
||||
log_error(device->base.seat->libinput,
|
||||
log_error(tablet_libinput_context(tablet),
|
||||
"Ignoring pressure offset greater than 20%% detected on tool %s (serial %#x). "
|
||||
"See http://wayland.freedesktop.org/libinput/doc/%s/tablet-support.html\n",
|
||||
tablet_tool_type_to_string(tool->type),
|
||||
|
|
@ -1133,7 +1134,7 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
|
|||
return;
|
||||
}
|
||||
|
||||
log_info(device->base.seat->libinput,
|
||||
log_info(tablet_libinput_context(tablet),
|
||||
"Pressure offset detected on tool %s (serial %#x). "
|
||||
"See http://wayland.freedesktop.org/libinput/doc/%s/tablet-support.html\n",
|
||||
tablet_tool_type_to_string(tool->type),
|
||||
|
|
@ -1156,16 +1157,16 @@ detect_tool_contact(struct tablet_dispatch *tablet,
|
|||
|
||||
/* if we have pressure, always use that for contact, not BTN_TOUCH */
|
||||
if (tablet_has_status(tablet, TABLET_TOOL_ENTERING_CONTACT))
|
||||
log_bug_libinput(device->base.seat->libinput,
|
||||
log_bug_libinput(tablet_libinput_context(tablet),
|
||||
"Invalid status: entering contact\n");
|
||||
if (tablet_has_status(tablet, TABLET_TOOL_LEAVING_CONTACT) &&
|
||||
!tablet_has_status(tablet, TABLET_TOOL_LEAVING_PROXIMITY))
|
||||
log_bug_libinput(device->base.seat->libinput,
|
||||
log_bug_libinput(tablet_libinput_context(tablet),
|
||||
"Invalid status: leaving contact\n");
|
||||
|
||||
p = libevdev_get_abs_info(tablet->device->evdev, ABS_PRESSURE);
|
||||
if (!p) {
|
||||
log_bug_libinput(device->base.seat->libinput,
|
||||
log_bug_libinput(tablet_libinput_context(tablet),
|
||||
"Missing pressure axis\n");
|
||||
return;
|
||||
}
|
||||
|
|
@ -1455,7 +1456,7 @@ tablet_process(struct evdev_dispatch *dispatch,
|
|||
tablet_reset_state(tablet);
|
||||
break;
|
||||
default:
|
||||
log_error(device->base.seat->libinput,
|
||||
log_error(tablet_libinput_context(tablet),
|
||||
"Unexpected event type %s (%#x)\n",
|
||||
libevdev_event_type_get_name(e->type),
|
||||
e->type);
|
||||
|
|
|
|||
|
|
@ -203,4 +203,10 @@ tablet_tool_type_to_string(enum libinput_tablet_tool_type type)
|
|||
return str;
|
||||
}
|
||||
|
||||
static inline struct libinput *
|
||||
tablet_libinput_context(const struct tablet_dispatch *tablet)
|
||||
{
|
||||
return evdev_libinput_context(tablet->device);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue