[clutter] input-device: Add vendor/product ID properties and getters
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] input-device: Add vendor/product ID properties and getters
- Date: Fri, 9 Jan 2015 16:02:22 +0000 (UTC)
commit 78fdefcf0cf917f47ef18d4ea9ce1064d86ffc54
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Nov 25 21:09:32 2014 +0100
input-device: Add vendor/product ID properties and getters
This may be useful when trying to identify the device across sessions.
https://bugzilla.gnome.org/show_bug.cgi?id=740759
clutter/clutter-device-manager-private.h | 3 +
clutter/clutter-input-device.c | 87 ++++++++++++++++++++++++++++
clutter/clutter-input-device.h | 5 ++
doc/reference/clutter/clutter-sections.txt | 2 +
4 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-device-manager-private.h b/clutter/clutter-device-manager-private.h
index 2f18b6e..3e09288 100644
--- a/clutter/clutter-device-manager-private.h
+++ b/clutter/clutter-device-manager-private.h
@@ -129,6 +129,9 @@ struct _ClutterInputDevice
GArray *scroll_info;
+ gchar *vendor_id;
+ gchar *product_id;
+
guint has_cursor : 1;
guint is_enabled : 1;
};
diff --git a/clutter/clutter-input-device.c b/clutter/clutter-input-device.c
index b7de586..b6a1010 100644
--- a/clutter/clutter-input-device.c
+++ b/clutter/clutter-input-device.c
@@ -66,6 +66,9 @@ enum
PROP_N_AXES,
+ PROP_VENDOR_ID,
+ PROP_PRODUCT_ID,
+
PROP_LAST
};
@@ -82,6 +85,8 @@ clutter_input_device_dispose (GObject *gobject)
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (gobject);
g_clear_pointer (&device->device_name, g_free);
+ g_clear_pointer (&device->vendor_id, g_free);
+ g_clear_pointer (&device->product_id, g_free);
if (device->associated != NULL)
{
@@ -156,6 +161,14 @@ clutter_input_device_set_property (GObject *gobject,
clutter_input_device_set_enabled (self, g_value_get_boolean (value));
break;
+ case PROP_VENDOR_ID:
+ self->vendor_id = g_value_dup_string (value);
+ break;
+
+ case PROP_PRODUCT_ID:
+ self->product_id = g_value_dup_string (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -208,6 +221,14 @@ clutter_input_device_get_property (GObject *gobject,
g_value_set_boolean (value, self->is_enabled);
break;
+ case PROP_VENDOR_ID:
+ g_value_set_string (value, self->vendor_id);
+ break;
+
+ case PROP_PRODUCT_ID:
+ g_value_set_string (value, self->product_id);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -357,6 +378,34 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
CLUTTER_TYPE_BACKEND,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+ /**
+ * ClutterInputDevice:vendor-id:
+ *
+ * Vendor ID of this device.
+ *
+ * Since: 1.22
+ */
+ obj_props[PROP_VENDOR_ID] =
+ g_param_spec_string ("vendor-id",
+ P_("Vendor ID"),
+ P_("Vendor ID"),
+ NULL,
+ CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * ClutterInputDevice:product-id:
+ *
+ * Product ID of this device.
+ *
+ * Since: 1.22
+ */
+ obj_props[PROP_PRODUCT_ID] =
+ g_param_spec_string ("product-id",
+ P_("Product ID"),
+ P_("Product ID"),
+ NULL,
+ CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
gobject_class->dispose = clutter_input_device_dispose;
gobject_class->set_property = clutter_input_device_set_property;
gobject_class->get_property = clutter_input_device_get_property;
@@ -1887,3 +1936,41 @@ clutter_input_device_sequence_get_grabbed_actor (ClutterInputDevice *device,
return g_hash_table_lookup (device->sequence_grab_actors, sequence);
}
+
+/**
+ * clutter_input_device_get_vendor_id:
+ * @device: a slave #ClutterInputDevice
+ *
+ * Gets the vendor ID of this device.
+ *
+ * Returns: the vendor ID
+ *
+ * Since: 1.22
+ */
+const gchar *
+clutter_input_device_get_vendor_id (ClutterInputDevice *device)
+{
+ g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
+ g_return_val_if_fail (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER, NULL);
+
+ return device->vendor_id;
+}
+
+/**
+ * clutter_input_device_get_product_id:
+ * @device: a slave #ClutterInputDevice
+ *
+ * Gets the product ID of this device.
+ *
+ * Returns: the product ID
+ *
+ * Since: 1.22
+ */
+const gchar *
+clutter_input_device_get_product_id (ClutterInputDevice *device)
+{
+ g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
+ g_return_val_if_fail (clutter_input_device_get_device_mode (device) != CLUTTER_INPUT_MODE_MASTER, NULL);
+
+ return device->product_id;
+}
diff --git a/clutter/clutter-input-device.h b/clutter/clutter-input-device.h
index 4fcdfc7..3019993 100644
--- a/clutter/clutter-input-device.h
+++ b/clutter/clutter-input-device.h
@@ -135,6 +135,11 @@ gboolean clutter_input_device_keycode_to_evdev (ClutterInputDev
guint hardware_keycode,
guint *evdev_keycode);
+CLUTTER_AVAILABLE_IN_1_22
+const gchar * clutter_input_device_get_vendor_id (ClutterInputDevice *device);
+CLUTTER_AVAILABLE_IN_1_22
+const gchar * clutter_input_device_get_product_id (ClutterInputDevice *device);
+
G_END_DECLS
#endif /* __CLUTTER_INPUT_DEVICE_H__ */
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index 5248a05..9777d59 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -1201,6 +1201,8 @@ clutter_input_device_get_associated_device
clutter_input_device_get_slave_devices
clutter_input_device_get_modifier_state
clutter_input_device_keycode_to_evdev
+clutter_input_device_get_vendor_id
+clutter_input_device_get_product_id
<SUBSECTION>
clutter_input_device_get_n_keys
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]