[PATCH libinput 4/4] config: Allow setting non-default device DPI

Derek Foreman derekf at osg.samsung.com
Thu Oct 30 14:34:16 PDT 2014


This allows changing a device's DPI from the default 400
---
 src/evdev.c    |  7 +++++++
 src/evdev.h    |  3 +++
 src/libinput.c |  7 +++++++
 src/libinput.h | 22 ++++++++++++++++++++++
 4 files changed, 39 insertions(+)

diff --git a/src/evdev.c b/src/evdev.c
index 8efa21a..e267320 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1360,6 +1360,13 @@ evdev_device_get_id_vendor(struct evdev_device *device)
 	return libevdev_get_id_vendor(device->evdev);
 }
 
+enum libinput_config_status
+evdev_device_set_dpi(struct evdev_device *device, uint32_t dpi)
+{
+	device->dpi = dpi;
+	return LIBINPUT_CONFIG_STATUS_SUCCESS;
+}
+
 void
 evdev_device_set_default_calibration(struct evdev_device *device,
 				     const float calibration[6])
diff --git a/src/evdev.h b/src/evdev.h
index 81dc140..db462c6 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -309,4 +309,7 @@ evdev_to_left_handed(struct evdev_device *device,
 	return button;
 }
 
+enum libinput_config_status
+evdev_device_set_dpi(struct evdev_device *device, uint32_t dpi);
+
 #endif /* EVDEV_H */
diff --git a/src/libinput.c b/src/libinput.c
index 5780a92..88efae3 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1501,3 +1501,10 @@ libinput_device_config_buttons_get_default_left_handed(struct libinput_device *d
 
 	return device->config.left_handed->get_default(device);
 }
+
+LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_override_dpi(struct libinput_device *device,
+				    uint32_t dpi)
+{
+	return evdev_device_set_dpi((struct evdev_device *) device, dpi);
+}
diff --git a/src/libinput.h b/src/libinput.h
index 9cc6f52..a721fc2 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -2007,6 +2007,28 @@ libinput_device_config_buttons_get_left_handed(struct libinput_device *device);
 int
 libinput_device_config_buttons_get_default_left_handed(struct libinput_device *device);
 
+
+/**
+ * @ingroup config
+ *
+ * Change the DPI setting of the device.
+ *
+ * Libinput assumes a "normal" mouse is 400DPI for some of its calculations.
+ * Ideally we would query mouse DPI from the device, but that isn't actually
+ * possible. To make things worse, some mice support multiple DPIs configured
+ * by a hardware switch, so even maintaining a database of mice becomes
+ * difficult. This function allows overriding the setting for mice we can't
+ * deal with any other way.
+ *
+ * @param device The device to configure
+ * @param dpi The device DPI
+ *
+ * @return A config status code
+ */
+enum libinput_config_status
+libinput_device_config_override_dpi(struct libinput_device *device,
+				    uint32_t dpi);
+
 #ifdef __cplusplus
 }
 #endif
-- 
2.1.1



More information about the wayland-devel mailing list