summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-06-09 11:15:51 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-06-10 06:57:41 +1000
commit3824e161ed35fbc59e83d8727a3c90ddc9e3d8cd (patch)
treebec14fe1198a31baac52d1e7c56cf6c691ccd27a /src
parent45d23a6b0ead7ae653c736451573de4f3fde63dd (diff)
tablet: add helper function to access the libinput context
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-tablet.c31
-rw-r--r--src/evdev-tablet.h6
2 files changed, 22 insertions, 15 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index 4f580e3d..395e5a0f 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -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);
diff --git a/src/evdev-tablet.h b/src/evdev-tablet.h
index d12c6752..57d627c9 100644
--- a/src/evdev-tablet.h
+++ b/src/evdev-tablet.h
@@ -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