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

Peter Hutterer peter.hutterer at who-t.net
Tue Nov 17 00:36:14 PST 2015


No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
No changes to v1

 src/xf86libinput.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index a4d9bd5..250e115 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -1481,6 +1481,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.5.0



More information about the xorg-devel mailing list