From 81736b1deafcba76382c99c5f454e349157fc41b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 10 May 2016 17:00:38 +0200 Subject: [PATCH] clutter: Add ::n-rings and ::n-strips property to ClutterInputDevice This will only be practical for pads (and maybe generic buttonsets in the future?), we just need to know the number as the events will also contain a number as the identificator. --- .../clutter/clutter-device-manager-private.h | 4 + clutter/clutter/clutter-input-device.c | 75 +++++++++++++++++++ clutter/clutter/clutter-input-device.h | 7 ++ 3 files changed, 86 insertions(+) diff --git a/clutter/clutter/clutter-device-manager-private.h b/clutter/clutter/clutter-device-manager-private.h index 6af3295b6..12d4effa6 100644 --- a/clutter/clutter/clutter-device-manager-private.h +++ b/clutter/clutter/clutter-device-manager-private.h @@ -134,6 +134,10 @@ struct _ClutterInputDevice GPtrArray *tools; + gint n_rings; + gint n_strips; + gint n_mode_groups; + guint has_cursor : 1; guint is_enabled : 1; }; diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c index 7f9c6f7e8..b782d0bd3 100644 --- a/clutter/clutter/clutter-input-device.c +++ b/clutter/clutter/clutter-input-device.c @@ -70,6 +70,10 @@ enum PROP_VENDOR_ID, PROP_PRODUCT_ID, + PROP_N_STRIPS, + PROP_N_RINGS, + PROP_N_MODE_GROUPS, + PROP_LAST }; @@ -195,6 +199,18 @@ clutter_input_device_set_property (GObject *gobject, self->product_id = g_value_dup_string (value); break; + case PROP_N_RINGS: + self->n_rings = g_value_get_int (value); + break; + + case PROP_N_STRIPS: + self->n_strips = g_value_get_int (value); + break; + + case PROP_N_MODE_GROUPS: + self->n_mode_groups = g_value_get_int (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -255,6 +271,18 @@ clutter_input_device_get_property (GObject *gobject, g_value_set_string (value, self->product_id); break; + case PROP_N_RINGS: + g_value_set_int (value, self->n_rings); + break; + + case PROP_N_STRIPS: + g_value_set_int (value, self->n_strips); + break; + + case PROP_N_MODE_GROUPS: + g_value_set_int (value, self->n_mode_groups); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -432,6 +460,27 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass) NULL, CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + obj_props[PROP_N_RINGS] = + g_param_spec_int ("n-rings", + P_("Number of rings"), + P_("Number of rings (circular sliders) in this device"), + 0, G_MAXINT, 0, + CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + + obj_props[PROP_N_STRIPS] = + g_param_spec_int ("n-strips", + P_("Number of strips"), + P_("Number of strips (linear sliders) in this device"), + 0, G_MAXINT, 0, + CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); + + obj_props[PROP_N_MODE_GROUPS] = + g_param_spec_int ("n-mode-groups", + P_("Number of mode groups"), + P_("Number of mode groups"), + 0, G_MAXINT, 0, + 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; @@ -2066,3 +2115,29 @@ clutter_input_device_update_from_tool (ClutterInputDevice *device, if (device_class->update_from_tool) device_class->update_from_tool (device, tool); } + +gint +clutter_input_device_get_n_rings (ClutterInputDevice *device) +{ + g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0); + + return device->n_rings; +} + +gint +clutter_input_device_get_n_strips (ClutterInputDevice *device) +{ + g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0); + + return device->n_strips; +} + +gint +clutter_input_device_get_n_mode_groups (ClutterInputDevice *device) +{ + g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0); + g_return_val_if_fail (clutter_input_device_get_device_type (device) == + CLUTTER_PAD_DEVICE, 0); + + return device->n_mode_groups; +} diff --git a/clutter/clutter/clutter-input-device.h b/clutter/clutter/clutter-input-device.h index 621f44d7a..959dce0db 100644 --- a/clutter/clutter/clutter-input-device.h +++ b/clutter/clutter/clutter-input-device.h @@ -140,6 +140,13 @@ const gchar * clutter_input_device_get_vendor_id (ClutterInputDev CLUTTER_AVAILABLE_IN_1_22 const gchar * clutter_input_device_get_product_id (ClutterInputDevice *device); +CLUTTER_AVAILABLE_IN_ALL +gint clutter_input_device_get_n_rings (ClutterInputDevice *device); +CLUTTER_AVAILABLE_IN_ALL +gint clutter_input_device_get_n_strips (ClutterInputDevice *device); +CLUTTER_AVAILABLE_IN_ALL +gint clutter_input_device_get_n_mode_groups (ClutterInputDevice *device); + G_END_DECLS #endif /* __CLUTTER_INPUT_DEVICE_H__ */