From 431200f40dad93bcaeff76ad34f3fdd431d5a8f2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 18 Jan 2011 16:13:26 +0000 Subject: [PATCH] device: Add keys and axes accessors Allow retrieving the number of keys and axes, since we provide the API to iterate over them both. --- clutter/clutter-device-manager-private.h | 2 -- clutter/clutter-input-device.c | 30 ++++++++++++++++----- clutter/clutter-input-device.h | 3 +++ clutter/x11/clutter-device-manager-xi2.c | 2 +- clutter/x11/clutter-input-device-core-x11.c | 3 +-- doc/reference/clutter/clutter-sections.txt | 12 ++++++--- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/clutter/clutter-device-manager-private.h b/clutter/clutter-device-manager-private.h index ec5a2fc7f..67ec1a314 100644 --- a/clutter/clutter-device-manager-private.h +++ b/clutter/clutter-device-manager-private.h @@ -148,8 +148,6 @@ guint _clutter_input_device_add_axis (ClutterInputDev gdouble min_value, gdouble max_value, gdouble resolution); -ClutterInputAxis _clutter_input_device_get_axis (ClutterInputDevice *device, - guint index_); void _clutter_input_device_reset_axes (ClutterInputDevice *device); void _clutter_input_device_set_associated_device (ClutterInputDevice *device, diff --git a/clutter/clutter-input-device.c b/clutter/clutter-input-device.c index 013ce437b..824895642 100644 --- a/clutter/clutter-input-device.c +++ b/clutter/clutter-input-device.c @@ -907,9 +907,20 @@ _clutter_input_device_translate_axis (ClutterInputDevice *device, return TRUE; } +/** + * clutter_input_device_get_axis: + * @device: a #ClutterInputDevice + * @index_: the index of the axis + * + * Retrieves the type of axis on @device at the given index. + * + * Return value: the axis type + * + * Since: 1.6 + */ ClutterInputAxis -_clutter_input_device_get_axis (ClutterInputDevice *device, - guint index_) +clutter_input_device_get_axis (ClutterInputDevice *device, + guint index_) { ClutterAxisInfo *info; @@ -963,15 +974,22 @@ _clutter_input_device_set_keys (ClutterInputDevice *device, device->max_keycode = max_keycode; } +/** + * clutter_input_device_get_n_keys: + * @device: a #ClutterInputDevice + * + * Retrieves the number of keys registered for @device. + * + * Return value: the number of registered keys + * + * Since: 1.6 + */ guint clutter_input_device_get_n_keys (ClutterInputDevice *device) { g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0); - if (device->keys != NULL) - return device->keys->len; - - return 0; + return device->n_keys; } /** diff --git a/clutter/clutter-input-device.h b/clutter/clutter-input-device.h index 86621b51f..fb305263b 100644 --- a/clutter/clutter-input-device.h +++ b/clutter/clutter-input-device.h @@ -138,7 +138,10 @@ ClutterStage * clutter_input_device_get_pointer_stage (ClutterInputDev G_CONST_RETURN gchar * clutter_input_device_get_device_name (ClutterInputDevice *device); guint clutter_input_device_get_n_axes (ClutterInputDevice *device); +ClutterInputAxis clutter_input_device_get_axis (ClutterInputDevice *device, + guint index_); +guint clutter_input_device_get_n_keys (ClutterInputDevice *device); void clutter_input_device_set_key (ClutterInputDevice *device, guint index_, guint keyval, diff --git a/clutter/x11/clutter-device-manager-xi2.c b/clutter/x11/clutter-device-manager-xi2.c index 7641e37b6..afcfa8da6 100644 --- a/clutter/x11/clutter-device-manager-xi2.c +++ b/clutter/x11/clutter-device-manager-xi2.c @@ -500,7 +500,7 @@ translate_axes (ClutterInputDevice *device, if (!XIMaskIsSet (valuators->mask, i)) continue; - axis = _clutter_input_device_get_axis (device, i); + axis = clutter_input_device_get_axis (device, i); val = *values++; switch (axis) diff --git a/clutter/x11/clutter-input-device-core-x11.c b/clutter/x11/clutter-input-device-core-x11.c index fa8be52a5..d23cada39 100644 --- a/clutter/x11/clutter-input-device-core-x11.c +++ b/clutter/x11/clutter-input-device-core-x11.c @@ -258,8 +258,7 @@ translate_axes (ClutterInputDeviceX11 *device_x11, { ClutterInputAxis axis; - axis = _clutter_input_device_get_axis (device, i); - + axis = clutter_input_device_get_axis (device, i); switch (axis) { case CLUTTER_INPUT_AXIS_X: diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt index 3dbadb375..a8da544a7 100644 --- a/doc/reference/clutter/clutter-sections.txt +++ b/doc/reference/clutter/clutter-sections.txt @@ -1082,12 +1082,18 @@ clutter_input_device_get_device_name clutter_input_device_get_device_coords clutter_input_device_get_pointer_actor clutter_input_device_get_pointer_stage -clutter_input_device_set_key -clutter_input_device_get_key -clutter_input_device_get_n_axes clutter_input_device_get_associated_device clutter_input_device_get_slave_devices + +clutter_input_device_get_n_keys +clutter_input_device_set_key +clutter_input_device_get_key + + +clutter_input_device_get_n_axes +clutter_input_device_get_axis + clutter_input_device_update_from_event