[PATCH libinput 09/10] Add config API for pointer modes
Peter Hutterer
peter.hutterer at who-t.net
Mon Jun 2 22:35:02 PDT 2014
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/libinput-private.h | 9 ++++++
src/libinput.c | 37 ++++++++++++++++++++++++
src/libinput.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 123 insertions(+)
diff --git a/src/libinput-private.h b/src/libinput-private.h
index 9a3e629..22220de 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -112,12 +112,21 @@ struct libinput_device_config_disable_while_typing {
void (*reset)(struct libinput_device *device);
};
+struct libinput_device_config_pointer_mode {
+ int (*modes)(struct libinput_device *device);
+ enum libinput_config_status (*set)(struct libinput_device *device,
+ enum libinput_device_pointer_mode);
+ enum libinput_device_pointer_mode (*get)(struct libinput_device *device);
+ void (*reset)(struct libinput_device *device);
+};
+
struct libinput_device_config {
struct libinput_device_config_tap *tap;
struct libinput_device_config_scroll *scroll;
struct libinput_device_config_rotation *rotation;
struct libinput_device_config_accel *accel;
struct libinput_device_config_disable_while_typing *dwt;
+ struct libinput_device_config_pointer_mode *mode;
};
struct libinput_device {
diff --git a/src/libinput.c b/src/libinput.c
index 33a8e90..5324407 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -1369,3 +1369,40 @@ libinput_device_config_disable_while_typing_reset(struct libinput_device *device
if (device->config.dwt)
device->config.dwt->reset(device);
}
+
+LIBINPUT_EXPORT unsigned int
+libinput_device_config_pointer_mode_get_modes(struct libinput_device *device)
+{
+ return device->config.mode ?
+ device->config.mode->modes(device) :
+ LIBINPUT_POINTER_MODE_NATIVE_ONLY;
+}
+
+LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_pointer_mode_set_mode(struct libinput_device *device,
+ enum libinput_device_pointer_mode mode)
+{
+ if (libinput_device_config_pointer_mode_get_modes(device) ==
+ LIBINPUT_POINTER_MODE_NATIVE_ONLY &&
+ mode != LIBINPUT_POINTER_MODE_NATIVE_ONLY)
+ return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
+
+ return device->config.mode->set(device, mode);
+}
+
+LIBINPUT_EXPORT enum libinput_device_pointer_mode
+libinput_device_config_pointer_mode_get_mode(struct libinput_device *device)
+{
+ if (libinput_device_config_pointer_mode_get_modes(device) ==
+ LIBINPUT_POINTER_MODE_NATIVE_ONLY)
+ return LIBINPUT_POINTER_MODE_NATIVE_ONLY;
+
+ return device->config.mode->get(device);
+}
+
+LIBINPUT_EXPORT void
+libinput_device_config_pointer_mode_reset(struct libinput_device *device)
+{
+ if (device->config.mode)
+ device->config.mode->reset(device);
+}
diff --git a/src/libinput.h b/src/libinput.h
index 62d0c0f..1a51b82 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -1713,6 +1713,83 @@ libinput_device_config_disable_while_typing_is_enabled(struct libinput_device *d
void
libinput_device_config_disable_while_typing_reset(struct libinput_device *device);
+/**
+ * @ingroup config
+ */
+enum libinput_device_pointer_mode {
+ /**
+ * The device only works in native mode and does not support mode
+ * switching. Native mode may be absolute or relative, depending on
+ * the device.
+ */
+ LIBINPUT_POINTER_MODE_NATIVE_ONLY = 0,
+ /**
+ * The device behaves like an absolute input device, e.g. like a
+ * touchscreen.
+ */
+ LIBINPUT_POINTER_MODE_ABSOLUTE = (1 << 0),
+ /**
+ * The device behaves like a relative input device, e.g. like a
+ * touchpad.
+ */
+ LIBINPUT_POINTER_MODE_RELATIVE = (1 << 1),
+};
+
+/**
+ * @ingroup config
+ *
+ * Get the supported device modes for this device. Absolute pointer devices
+ * such as graphics tablet may be used in absolute mode or relative mode.
+ *
+ * @note A device that supports relative and absolute mode may be
+ * pointer-accelerated in relative mode.
+ *
+ * @param device The device to configure
+ *
+ * @return A bitmask of the available pointer modes, or
+ * POINTER_MODE_NATIVE_ONLY if the device does not allow mode switching
+ */
+unsigned int
+libinput_device_config_pointer_mode_get_modes(struct libinput_device *device);
+
+/**
+ * @ingroup config
+ *
+ * Set the pointer mode for this device.
+ *
+ * @param device The device to configure
+ * @param mode The pointer mode to switch the device to
+ *
+ * @return A config status code
+ */
+enum libinput_config_status
+libinput_device_config_pointer_mode_set_mode(struct libinput_device *device,
+ enum libinput_device_pointer_mode mode);
+
+/**
+ * @ingroup config
+ *
+ * Get the current pointer mode for this device.
+ *
+ * @param device The device to configure
+ *
+ * @return The current pointer mode this device is in
+ */
+enum libinput_device_pointer_mode
+libinput_device_config_pointer_mode_get_mode(struct libinput_device *device);
+
+/**
+ * @ingroup config
+ *
+ * Reset to the default mode. If the device only supports native mode, this
+ * function does nothing.
+ *
+ * @param device The device to configure
+ */
+void
+libinput_device_config_pointer_mode_reset(struct libinput_device *device);
+
+
#ifdef __cplusplus
}
#endif
--
1.9.0
More information about the wayland-devel
mailing list