mirror of
https://github.com/brl/mutter.git
synced 2025-02-02 14:53:03 +00:00
device: Add get_axis_value()
We need a convenience function for extracting the value of a specific axis type out of the array of axis values attached to events.
This commit is contained in:
parent
d805237c31
commit
333ca35cec
@ -924,6 +924,9 @@ clutter_input_device_get_axis (ClutterInputDevice *device,
|
|||||||
{
|
{
|
||||||
ClutterAxisInfo *info;
|
ClutterAxisInfo *info;
|
||||||
|
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device),
|
||||||
|
CLUTTER_INPUT_AXIS_IGNORE);
|
||||||
|
|
||||||
if (device->axes == NULL)
|
if (device->axes == NULL)
|
||||||
return CLUTTER_INPUT_AXIS_IGNORE;
|
return CLUTTER_INPUT_AXIS_IGNORE;
|
||||||
|
|
||||||
@ -935,6 +938,50 @@ clutter_input_device_get_axis (ClutterInputDevice *device,
|
|||||||
return info->axis;
|
return info->axis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clutter_input_device_get_axis_value:
|
||||||
|
* @device: a #ClutterInputDevice
|
||||||
|
* @axes: (array): an array of axes values, typically
|
||||||
|
* coming from clutter_event_get_axes()
|
||||||
|
* @axis: the axis to extract
|
||||||
|
* @value: (out): return location for the axis value
|
||||||
|
*
|
||||||
|
* Extracts the value of the given @axis of a #ClutterInputDevice from
|
||||||
|
* an array of axis values.
|
||||||
|
*
|
||||||
|
* Return value: %TRUE if the value was set, and %FALSE otherwise
|
||||||
|
*
|
||||||
|
* Since: 1.6
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
clutter_input_device_get_axis_value (ClutterInputDevice *device,
|
||||||
|
gdouble *axes,
|
||||||
|
ClutterInputAxis axis,
|
||||||
|
gdouble *value)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
||||||
|
g_return_val_if_fail (device->axes != NULL, FALSE);
|
||||||
|
|
||||||
|
for (i = 0; i < device->axes->len; i++)
|
||||||
|
{
|
||||||
|
ClutterAxisInfo *info;
|
||||||
|
|
||||||
|
info = &g_array_index (device->axes, ClutterAxisInfo, i);
|
||||||
|
|
||||||
|
if (info->axis == axis)
|
||||||
|
{
|
||||||
|
if (value)
|
||||||
|
*value = axes[i];
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_input_device_get_n_axes:
|
* clutter_input_device_get_n_axes:
|
||||||
* @device: a #ClutterInputDevice
|
* @device: a #ClutterInputDevice
|
||||||
|
@ -140,6 +140,10 @@ G_CONST_RETURN gchar * clutter_input_device_get_device_name (ClutterInputDev
|
|||||||
guint clutter_input_device_get_n_axes (ClutterInputDevice *device);
|
guint clutter_input_device_get_n_axes (ClutterInputDevice *device);
|
||||||
ClutterInputAxis clutter_input_device_get_axis (ClutterInputDevice *device,
|
ClutterInputAxis clutter_input_device_get_axis (ClutterInputDevice *device,
|
||||||
guint index_);
|
guint index_);
|
||||||
|
gboolean clutter_input_device_get_axis_value (ClutterInputDevice *device,
|
||||||
|
gdouble *axes,
|
||||||
|
ClutterInputAxis axis,
|
||||||
|
gdouble *value);
|
||||||
|
|
||||||
guint clutter_input_device_get_n_keys (ClutterInputDevice *device);
|
guint clutter_input_device_get_n_keys (ClutterInputDevice *device);
|
||||||
void clutter_input_device_set_key (ClutterInputDevice *device,
|
void clutter_input_device_set_key (ClutterInputDevice *device,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user