[PATCH/WIP xf86-input-libinput 1/3] Change creating subdevices to something more generic

Peter Hutterer peter.hutterer at who-t.net
Tue Dec 1 18:29:29 PST 2015


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

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index ee2165a..e20d821 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -1753,7 +1753,7 @@ xf86libinput_hotplug_device(ClientPtr client, pointer closure)
 }
 
 static void
-xf86libinput_create_keyboard_subdevice(InputInfoPtr pInfo)
+xf86libinput_create_subdevice(InputInfoPtr pInfo, uint32_t capabilities)
 {
 	struct xf86libinput *driver_data = pInfo->private;
 	struct xf86libinput_device *shared_device;
@@ -1768,7 +1768,13 @@ xf86libinput_create_keyboard_subdevice(InputInfoPtr pInfo)
 
 	options = xf86OptionListDuplicate(pInfo->options);
 	options = xf86ReplaceStrOption(options, "_source", "_driver/libinput");
-	options = xf86ReplaceStrOption(options, "_libinput/caps", "keyboard");
+
+	if (capabilities & CAP_KEYBOARD)
+		options = xf86ReplaceBoolOption(options, "_libinput/cap-keyboard", 1);
+	if (capabilities & CAP_POINTER)
+		options = xf86ReplaceBoolOption(options, "_libinput/cap-pointer", 1);
+	if (capabilities & CAP_TOUCH)
+		options = xf86ReplaceBoolOption(options, "_libinput/cap-touch", 1);
 
 	/* need convert from one option list to the other. woohoo. */
 	o = options;
@@ -1804,6 +1810,21 @@ xf86libinput_is_subdevice(InputInfoPtr pInfo)
 	return is_subdevice;
 }
 
+static inline uint32_t
+caps_from_options(InputInfoPtr pInfo)
+{
+	uint32_t capabilities = 0;
+
+	if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-keyboard", 0))
+		capabilities |= CAP_KEYBOARD;
+	if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-pointer", 0))
+		capabilities |= CAP_POINTER;
+	if (xf86CheckBoolOption(pInfo->options, "_libinput/cap-touch", 0))
+		capabilities |= CAP_TOUCH;
+
+	return capabilities;
+}
+
 static int
 xf86libinput_pre_init(InputDriverPtr drv,
 		      InputInfoPtr pInfo,
@@ -1898,7 +1919,7 @@ xf86libinput_pre_init(InputDriverPtr drv,
 		if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
 			driver_data->capabilities |= CAP_TOUCH;
 	} else {
-		driver_data->capabilities = CAP_KEYBOARD;
+		driver_data->capabilities = caps_from_options(pInfo);
 	}
 
 	/* Disable acceleration in the server, libinput does it for us */
@@ -1913,7 +1934,7 @@ xf86libinput_pre_init(InputDriverPtr drv,
 	    driver_data->capabilities & CAP_KEYBOARD &&
 	    driver_data->capabilities & (CAP_POINTER|CAP_TOUCH)) {
 		driver_data->capabilities &= ~CAP_KEYBOARD;
-		xf86libinput_create_keyboard_subdevice(pInfo);
+		xf86libinput_create_subdevice(pInfo, CAP_KEYBOARD);
 	}
 
 	pInfo->type_name = xf86libinput_get_type_name(device, driver_data);
-- 
2.5.0



More information about the xorg-devel mailing list