[PATCH xf86-input-libinput 1/3] Split type_name detection out into a helper function

Peter Hutterer peter.hutterer at who-t.net
Wed Nov 11 16:27:03 PST 2015


No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/xf86libinput.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index 95e2d20..be0ec5d 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -1480,6 +1480,26 @@ xf86libinput_parse_options(InputInfoPtr pInfo,
 	}
 }
 
+static const char*
+xf86libinput_get_type_name(struct libinput_device *device)
+{
+	const char *type_name;
+
+	/* now pick an actual type */
+	if (libinput_device_config_tap_get_finger_count(device) > 0)
+		type_name = XI_TOUCHPAD;
+	else if (libinput_device_has_capability(device,
+						LIBINPUT_DEVICE_CAP_TOUCH))
+		type_name = XI_TOUCHSCREEN;
+	else if (libinput_device_has_capability(device,
+						LIBINPUT_DEVICE_CAP_POINTER))
+		type_name = XI_MOUSE;
+	else
+		type_name = XI_KEYBOARD;
+
+	return type_name;
+}
+
 static int
 xf86libinput_pre_init(InputDriverPtr drv,
 		      InputInfoPtr pInfo,
@@ -1556,17 +1576,7 @@ xf86libinput_pre_init(InputDriverPtr drv,
 
 	xf86libinput_parse_options(pInfo, driver_data, device);
 
-	/* now pick an actual type */
-	if (libinput_device_config_tap_get_finger_count(device) > 0)
-		pInfo->type_name = XI_TOUCHPAD;
-	else if (libinput_device_has_capability(device,
-						LIBINPUT_DEVICE_CAP_TOUCH))
-		pInfo->type_name = XI_TOUCHSCREEN;
-	else if (libinput_device_has_capability(device,
-						LIBINPUT_DEVICE_CAP_POINTER))
-		pInfo->type_name = XI_MOUSE;
-	else
-		pInfo->type_name = XI_KEYBOARD;
+	pInfo->type_name = xf86libinput_get_type_name(device);
 
 	return Success;
 fail:
-- 
2.4.3



More information about the xorg-devel mailing list