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.
This commit is contained in:
Carlos Garnacho 2016-05-10 17:00:38 +02:00
parent 379c6fb81a
commit d5459427d5
3 changed files with 86 additions and 0 deletions

View File

@ -134,6 +134,10 @@ struct _ClutterInputDevice
GPtrArray *tools; GPtrArray *tools;
gint n_rings;
gint n_strips;
gint n_mode_groups;
guint has_cursor : 1; guint has_cursor : 1;
guint is_enabled : 1; guint is_enabled : 1;
}; };

View File

@ -70,6 +70,10 @@ enum
PROP_VENDOR_ID, PROP_VENDOR_ID,
PROP_PRODUCT_ID, PROP_PRODUCT_ID,
PROP_N_STRIPS,
PROP_N_RINGS,
PROP_N_MODE_GROUPS,
PROP_LAST PROP_LAST
}; };
@ -195,6 +199,18 @@ clutter_input_device_set_property (GObject *gobject,
self->product_id = g_value_dup_string (value); self->product_id = g_value_dup_string (value);
break; 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: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@ -255,6 +271,18 @@ clutter_input_device_get_property (GObject *gobject,
g_value_set_string (value, self->product_id); g_value_set_string (value, self->product_id);
break; 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: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@ -432,6 +460,27 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
NULL, NULL,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); 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->dispose = clutter_input_device_dispose;
gobject_class->set_property = clutter_input_device_set_property; gobject_class->set_property = clutter_input_device_set_property;
gobject_class->get_property = clutter_input_device_get_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) if (device_class->update_from_tool)
device_class->update_from_tool (device, 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;
}

View File

@ -140,6 +140,13 @@ const gchar * clutter_input_device_get_vendor_id (ClutterInputDev
CLUTTER_AVAILABLE_IN_1_22 CLUTTER_AVAILABLE_IN_1_22
const gchar * clutter_input_device_get_product_id (ClutterInputDevice *device); 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 G_END_DECLS
#endif /* __CLUTTER_INPUT_DEVICE_H__ */ #endif /* __CLUTTER_INPUT_DEVICE_H__ */