[clutter/wip/evdev-tablet-support: 164/164] evdev: Add basic support for buttonsets
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/evdev-tablet-support: 164/164] evdev: Add basic support for buttonsets
- Date: Wed, 21 Oct 2015 18:05:08 +0000 (UTC)
commit d43e2fdb3bb42535b8a3e41bc828adedb1957c82
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jun 1 17:00:25 2015 +0100
evdev: Add basic support for buttonsets
clutter/clutter-enums.h | 20 ++++++++
clutter/evdev/clutter-device-manager-evdev.c | 56 +++++++++++++++++++++++
clutter/evdev/clutter-input-device-evdev.c | 61 ++++++++++++++++++++++++++
3 files changed, 137 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-enums.h b/clutter/clutter-enums.h
index 40acf56..544d5e4 100644
--- a/clutter/clutter-enums.h
+++ b/clutter/clutter-enums.h
@@ -896,6 +896,7 @@ typedef enum { /*< prefix=CLUTTER_FLOW >*/
* @CLUTTER_PEN_DEVICE: A pen device
* @CLUTTER_ERASER_DEVICE: An eraser device
* @CLUTTER_CURSOR_DEVICE: A cursor device
+ * @CLUTTER_BUTTONSET_DEVICE: A "buttonset" device, containing either buttons or axes.
* @CLUTTER_N_DEVICE_TYPES: The number of device types
*
* The types of input devices available.
@@ -916,6 +917,7 @@ typedef enum {
CLUTTER_PEN_DEVICE,
CLUTTER_ERASER_DEVICE,
CLUTTER_CURSOR_DEVICE,
+ CLUTTER_BUTTONSET_DEVICE,
CLUTTER_N_DEVICE_TYPES
} ClutterInputDeviceType;
@@ -948,6 +950,15 @@ typedef enum {
* @CLUTTER_INPUT_AXIS_YTILT: The tile on the Y axis
* @CLUTTER_INPUT_AXIS_WHEEL: A wheel
* @CLUTTER_INPUT_AXIS_DISTANCE: Distance (Since 1.12)
+ * @CLUTTER_INPUT_AXIS_Z: The position on the Z axis (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_RELATIVE_X: Relative X axis (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_RELATIVE_Y: Relative Y axis (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_RELATIVE_Z: Relative Z axis (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_ROTATION_X: Rotation on X axis (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_ROTATION_Y: Rotation on Y axis (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_ROTATION_Z: Rotation on Z axis (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_RING: Ring, as found in drawing tablets (Since 1.24)
+ * @CLUTTER_INPUT_AXIS_STRIP: Strip, as found in drawing tablets (Since 1.24)
* @CLUTTER_INPUT_AXIS_LAST: Last value of the enumeration; this value is
* useful when iterating over the enumeration values (Since 1.12)
*
@@ -965,6 +976,15 @@ typedef enum {
CLUTTER_INPUT_AXIS_YTILT,
CLUTTER_INPUT_AXIS_WHEEL,
CLUTTER_INPUT_AXIS_DISTANCE,
+ CLUTTER_INPUT_AXIS_Z,
+ CLUTTER_INPUT_AXIS_RELATIVE_X,
+ CLUTTER_INPUT_AXIS_RELATIVE_Y,
+ CLUTTER_INPUT_AXIS_RELATIVE_Z,
+ CLUTTER_INPUT_AXIS_ROTATION_X,
+ CLUTTER_INPUT_AXIS_ROTATION_Y,
+ CLUTTER_INPUT_AXIS_ROTATION_Z,
+ CLUTTER_INPUT_AXIS_RING,
+ CLUTTER_INPUT_AXIS_STRIP,
CLUTTER_INPUT_AXIS_LAST
} ClutterInputAxis;
diff --git a/clutter/evdev/clutter-device-manager-evdev.c b/clutter/evdev/clutter-device-manager-evdev.c
index 81c61fe..ef83fc0 100644
--- a/clutter/evdev/clutter-device-manager-evdev.c
+++ b/clutter/evdev/clutter-device-manager-evdev.c
@@ -1456,6 +1456,29 @@ translate_tablet_axes (struct libinput_event_tablet *tablet_event)
return (gdouble *) g_array_free (axes, FALSE);
}
+static gdouble *
+translate_buttonset_axes (struct libinput_event_buttonset *buttonset_event,
+ struct libinput_device *libinput_device)
+{
+ guint i, n_axes;
+ gdouble *axes;
+
+ n_axes = libinput_device_buttonset_get_num_axes (libinput_device);
+
+ if (n_axes == 0)
+ return NULL;
+
+ axes = g_new0 (gdouble, n_axes);
+
+ for (i = 0; i < n_axes; i++)
+ {
+ if (libinput_event_buttonset_axis_has_changed (buttonset_event, i))
+ axes[i] = libinput_event_buttonset_get_axis_delta_discrete (buttonset_event, i);
+ }
+
+ return axes;
+}
+
static gboolean
process_device_event (ClutterDeviceManagerEvdev *manager_evdev,
struct libinput_event *event)
@@ -1881,6 +1904,39 @@ process_device_event (ClutterDeviceManagerEvdev *manager_evdev,
notify_button (device, time, tablet_button, button_state);
break;
}
+ case LIBINPUT_EVENT_BUTTONSET_AXIS:
+ {
+ struct libinput_event_buttonset *buttonset_event =
+ libinput_event_get_buttonset_event (event);
+ double *axes;
+ guint32 time;
+
+ device = libinput_device_get_user_data (libinput_device);
+ axes = translate_buttonset_axes (buttonset_event, libinput_device);
+ time = libinput_event_buttonset_get_time (buttonset_event);
+
+ if (!axes)
+ break;
+
+ notify_absolute_motion (device, time, 0, 0, axes);
+ break;
+ }
+ case LIBINPUT_EVENT_BUTTONSET_BUTTON:
+ {
+ struct libinput_event_buttonset *buttonset_event =
+ libinput_event_get_buttonset_event (event);
+ guint32 button_state;
+
+ device = libinput_device_get_user_data (libinput_device);
+ button_state = libinput_event_buttonset_get_button_state (buttonset_event) ==
+ LIBINPUT_BUTTON_STATE_PRESSED;
+
+ notify_button (device,
+ libinput_event_buttonset_get_time (buttonset_event),
+ libinput_event_buttonset_get_button (buttonset_event),
+ button_state);
+ break;
+ }
default:
handled = FALSE;
}
diff --git a/clutter/evdev/clutter-input-device-evdev.c b/clutter/evdev/clutter-input-device-evdev.c
index 57bef05..b6bd3ef 100644
--- a/clutter/evdev/clutter-input-device-evdev.c
+++ b/clutter/evdev/clutter-input-device-evdev.c
@@ -119,6 +119,62 @@ clutter_input_device_evdev_update_from_tool (ClutterInputDevice *device,
}
static void
+clutter_input_device_evdev_update_buttonset_axes (ClutterInputDeviceEvdev *evdev_device)
+{
+ ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (evdev_device);
+ guint axis, n_axes;
+
+ n_axes = libinput_device_buttonset_get_num_axes (evdev_device->libinput_device);
+
+ for (axis = 0; axis < n_axes; axis++)
+ {
+ enum libinput_buttonset_axis_type axis_type;
+
+ axis_type = libinput_device_buttonset_get_axis_type (evdev_device->libinput_device,
+ axis);
+ switch (axis_type)
+ {
+ case LIBINPUT_BUTTONSET_AXIS_X:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_X, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_Y:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_Y, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_Z:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_Z, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_REL_X:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_RELATIVE_X, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_REL_Y:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_RELATIVE_Y, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_REL_Z:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_RELATIVE_Z, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_ROTATION_X:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_ROTATION_X, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_ROTATION_Y:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_ROTATION_Y, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_ROTATION_Z:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_ROTATION_Z, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_RING:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_RING, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_STRIP:
+ _clutter_input_device_add_axis (device, CLUTTER_INPUT_AXIS_STRIP, 0, 0, 0);
+ break;
+ case LIBINPUT_BUTTONSET_AXIS_NONE:
+ g_assert_not_reached ();
+ break;
+ }
+ }
+}
+
+static void
clutter_input_device_evdev_class_init (ClutterInputDeviceEvdevClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -168,6 +224,9 @@ _clutter_input_device_evdev_new (ClutterDeviceManager *manager,
device->seat = seat;
device->libinput_device = libinput_device;
+ if (libinput_device_has_capability (libinput_device, LIBINPUT_DEVICE_CAP_BUTTONSET))
+ clutter_input_device_evdev_update_buttonset_axes (device);
+
libinput_device_set_user_data (libinput_device, device);
libinput_device_ref (libinput_device);
g_free (vendor);
@@ -249,6 +308,8 @@ _clutter_input_device_evdev_determine_type (struct libinput_device *ldev)
return CLUTTER_POINTER_DEVICE;
else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_TOUCH))
return CLUTTER_TOUCHSCREEN_DEVICE;
+ else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_BUTTONSET))
+ return CLUTTER_BUTTONSET_DEVICE;
else if (libinput_device_has_capability (ldev, LIBINPUT_DEVICE_CAP_KEYBOARD))
return CLUTTER_KEYBOARD_DEVICE;
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]