[PATCH libinput 2/6] tablet: use require_event_type instead of direct type check

Peter Hutterer peter.hutterer at who-t.net
Thu Nov 5 20:55:29 PST 2015


Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/libinput.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/libinput.c b/src/libinput.c
index 65dd0d9..c1f2700 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -925,9 +925,11 @@ libinput_event_tablet_get_axis_value(struct libinput_event_tablet *event,
 	struct evdev_device *device =
 		(struct evdev_device *) event->base.device;
 
-	if (event->base.type != LIBINPUT_EVENT_TABLET_AXIS &&
-	    event->base.type != LIBINPUT_EVENT_TABLET_PROXIMITY)
-		return 0;
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_AXIS,
+			   LIBINPUT_EVENT_TABLET_PROXIMITY);
 
 	switch(axis) {
 		case LIBINPUT_TABLET_AXIS_X:
@@ -956,9 +958,11 @@ libinput_event_tablet_get_axis_delta(struct libinput_event_tablet *event,
 	struct evdev_device *device =
 		(struct evdev_device *) event->base.device;
 
-	if (event->base.type != LIBINPUT_EVENT_TABLET_AXIS &&
-	    event->base.type != LIBINPUT_EVENT_TABLET_PROXIMITY)
-		return 0;
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_AXIS,
+			   LIBINPUT_EVENT_TABLET_PROXIMITY);
 
 	switch(axis) {
 		case LIBINPUT_TABLET_AXIS_X:
@@ -985,9 +989,11 @@ libinput_event_tablet_get_axis_delta_discrete(
 				      struct libinput_event_tablet *event,
 				      enum libinput_tablet_axis axis)
 {
-	if (event->base.type != LIBINPUT_EVENT_TABLET_AXIS &&
-	    event->base.type != LIBINPUT_EVENT_TABLET_PROXIMITY)
-		return 0;
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_AXIS,
+			   LIBINPUT_EVENT_TABLET_PROXIMITY);
 
 	switch(axis) {
 		case LIBINPUT_TABLET_AXIS_X:
@@ -1012,8 +1018,10 @@ libinput_event_tablet_get_x_transformed(struct libinput_event_tablet *event,
 	struct evdev_device *device =
 		(struct evdev_device *) event->base.device;
 
-	if (event->base.type != LIBINPUT_EVENT_TABLET_AXIS)
-		return 0;
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_AXIS);
 
 	return evdev_device_transform_x(device,
 					event->axes[LIBINPUT_TABLET_AXIS_X],
@@ -1027,8 +1035,10 @@ libinput_event_tablet_get_y_transformed(struct libinput_event_tablet *event,
 	struct evdev_device *device =
 		(struct evdev_device *) event->base.device;
 
-	if (event->base.type != LIBINPUT_EVENT_TABLET_AXIS)
-		return 0;
+	require_event_type(libinput_event_get_context(&event->base),
+			   event->base.type,
+			   0,
+			   LIBINPUT_EVENT_TABLET_AXIS);
 
 	return evdev_device_transform_y(device,
 					event->axes[LIBINPUT_TABLET_AXIS_Y],
-- 
2.4.3



More information about the wayland-devel mailing list