Clutter Reference Manual | ||||
---|---|---|---|---|
Top | Description | Object Hierarchy | Properties |
enum ClutterInputDeviceType; enum ClutterInputAxis; enum ClutterInputMode; ClutterInputDevice; gint clutter_input_device_get_device_id (ClutterInputDevice *device
); ClutterInputDeviceType clutter_input_device_get_device_type (ClutterInputDevice *device
); const gchar * clutter_input_device_get_device_name (ClutterInputDevice *device
); ClutterInputMode clutter_input_device_get_device_mode (ClutterInputDevice *device
); gboolean clutter_input_device_get_has_cursor (ClutterInputDevice *device
); void clutter_input_device_set_enabled (ClutterInputDevice *device
,gboolean enabled
); gboolean clutter_input_device_get_enabled (ClutterInputDevice *device
); ClutterInputDevice * clutter_input_device_get_associated_device (ClutterInputDevice *device
); GList * clutter_input_device_get_slave_devices (ClutterInputDevice *device
); gboolean clutter_input_device_keycode_to_evdev (ClutterInputDevice *device
,guint hardware_keycode
,guint *evdev_keycode
); guint clutter_input_device_get_n_keys (ClutterInputDevice *device
); void clutter_input_device_set_key (ClutterInputDevice *device
,guint index_
,guint keyval
,ClutterModifierType modifiers
); gboolean clutter_input_device_get_key (ClutterInputDevice *device
,guint index_
,guint *keyval
,ClutterModifierType *modifiers
); guint clutter_input_device_get_n_axes (ClutterInputDevice *device
); ClutterInputAxis clutter_input_device_get_axis (ClutterInputDevice *device
,guint index_
); gboolean clutter_input_device_get_axis_value (ClutterInputDevice *device
,gdouble *axes
,ClutterInputAxis axis
,gdouble *value
); gboolean clutter_input_device_get_coords (ClutterInputDevice *device
,ClutterEventSequence *sequence
,ClutterPoint *point
); void clutter_input_device_get_device_coords (ClutterInputDevice *device
,gint *x
,gint *y
); ClutterActor * clutter_input_device_get_pointer_actor (ClutterInputDevice *device
); ClutterStage * clutter_input_device_get_pointer_stage (ClutterInputDevice *device
); void clutter_input_device_grab (ClutterInputDevice *device
,ClutterActor *actor
); void clutter_input_device_ungrab (ClutterInputDevice *device
); ClutterActor * clutter_input_device_get_grabbed_actor (ClutterInputDevice *device
); void clutter_input_device_sequence_grab (ClutterInputDevice *device
,ClutterEventSequence *sequence
,ClutterActor *actor
); void clutter_input_device_sequence_ungrab (ClutterInputDevice *device
,ClutterEventSequence *sequence
); ClutterActor * clutter_input_device_sequence_get_grabbed_actor (ClutterInputDevice *device
,ClutterEventSequence *sequence
); void clutter_input_device_update_from_event (ClutterInputDevice *device
,ClutterEvent *event
,gboolean update_stage
);
"backend" ClutterBackend* : Read / Write / Construct Only "device-manager" ClutterDeviceManager* : Read / Write / Construct Only "device-mode" ClutterInputMode : Read / Write / Construct Only "device-type" ClutterInputDeviceType : Read / Write / Construct Only "enabled" gboolean : Read / Write "has-cursor" gboolean : Read / Write / Construct Only "id" gint : Read / Write / Construct Only "n-axes" guint : Read "name" gchar* : Read / Write / Construct Only
ClutterInputDevice represents an input device known to Clutter.
The ClutterInputDevice class holds the state of the device, but its contents are usually defined by the Clutter backend in use.
typedef enum { CLUTTER_POINTER_DEVICE, CLUTTER_KEYBOARD_DEVICE, CLUTTER_EXTENSION_DEVICE, CLUTTER_JOYSTICK_DEVICE, CLUTTER_TABLET_DEVICE, CLUTTER_TOUCHPAD_DEVICE, CLUTTER_TOUCHSCREEN_DEVICE, CLUTTER_PEN_DEVICE, CLUTTER_ERASER_DEVICE, CLUTTER_CURSOR_DEVICE, CLUTTER_N_DEVICE_TYPES } ClutterInputDeviceType;
The types of input devices available.
The ClutterInputDeviceType enumeration can be extended at later date; not every platform supports every input device type.
A pointer device | |
A keyboard device | |
A generic extension device | |
A joystick device | |
A tablet device | |
A touchpad device | |
A touch screen device | |
A pen device | |
An eraser device | |
A cursor device | |
The number of device types |
Since 1.0
typedef enum { CLUTTER_INPUT_AXIS_IGNORE, CLUTTER_INPUT_AXIS_X, CLUTTER_INPUT_AXIS_Y, CLUTTER_INPUT_AXIS_PRESSURE, CLUTTER_INPUT_AXIS_XTILT, CLUTTER_INPUT_AXIS_YTILT, CLUTTER_INPUT_AXIS_WHEEL, CLUTTER_INPUT_AXIS_DISTANCE, CLUTTER_INPUT_AXIS_LAST } ClutterInputAxis;
The type of axes Clutter recognizes on a ClutterInputDevice
Unused axis | |
The position on the X axis | |
The position of the Y axis | |
The pressure information | |
The tilt on the X axis | |
The tile on the Y axis | |
A wheel | |
Distance (Since 1.12) | |
Last value of the enumeration; this value is useful when iterating over the enumeration values (Since 1.12) |
Since 1.6
typedef enum { CLUTTER_INPUT_MODE_MASTER, CLUTTER_INPUT_MODE_SLAVE, CLUTTER_INPUT_MODE_FLOATING } ClutterInputMode;
The mode for input devices available.
A master, virtual device | |
A slave, physical device, attached to a master device | |
A slave, physical device, not attached to a master device |
Since 1.6
typedef struct _ClutterInputDevice ClutterInputDevice;
Generic representation of an input device. The actual contents of this structure depend on the backend used.
gint clutter_input_device_get_device_id (ClutterInputDevice *device
);
Retrieves the unique identifier of device
|
a ClutterInputDevice |
Returns : |
the identifier of the device |
Since 1.0
ClutterInputDeviceType clutter_input_device_get_device_type
(ClutterInputDevice *device
);
Retrieves the type of device
|
a ClutterInputDevice |
Returns : |
the type of the device |
Since 1.0
const gchar * clutter_input_device_get_device_name
(ClutterInputDevice *device
);
Retrieves the name of the device
|
a ClutterInputDevice |
Returns : |
the name of the device, or NULL . The returned string
is owned by the ClutterInputDevice and should never be modified
or freed |
Since 1.2
ClutterInputMode clutter_input_device_get_device_mode
(ClutterInputDevice *device
);
Retrieves the ClutterInputMode of device
.
|
a ClutterInputDevice |
Returns : |
the device mode |
Since 1.6
gboolean clutter_input_device_get_has_cursor (ClutterInputDevice *device
);
Retrieves whether device
has a pointer that follows the
device motion.
|
a ClutterInputDevice |
Returns : |
TRUE if the device has a cursor |
Since 1.6
void clutter_input_device_set_enabled (ClutterInputDevice *device
,gboolean enabled
);
Enables or disables a ClutterInputDevice.
Only devices with a "device-mode" property set
to CLUTTER_INPUT_MODE_SLAVE
or CLUTTER_INPUT_MODE_FLOATING
can
be disabled.
|
a ClutterInputDevice |
|
TRUE to enable the device
|
Since 1.6
gboolean clutter_input_device_get_enabled (ClutterInputDevice *device
);
Retrieves whether device
is enabled.
|
a ClutterInputDevice |
Returns : |
TRUE if the device is enabled |
Since 1.6
ClutterInputDevice * clutter_input_device_get_associated_device
(ClutterInputDevice *device
);
Retrieves a pointer to the ClutterInputDevice that has been
associated to device
.
If the "device-mode" property of device
is
set to CLUTTER_INPUT_MODE_MASTER
, this function will return
NULL
.
|
a ClutterInputDevice |
Returns : |
a ClutterInputDevice, or NULL . [transfer none]
|
Since 1.6
GList * clutter_input_device_get_slave_devices
(ClutterInputDevice *device
);
Retrieves the slave devices attached to device
.
|
a ClutterInputDevice |
Returns : |
a
list of ClutterInputDevice, or NULL . The contents of the list are
owned by the device. Use g_list_free() when done. [transfer container][element-type Clutter.InputDevice]
|
Since 1.6
gboolean clutter_input_device_keycode_to_evdev (ClutterInputDevice *device
,guint hardware_keycode
,guint *evdev_keycode
);
Translates a hardware keycode from a ClutterKeyEvent to the equivalent evdev keycode. Note that depending on the input backend used by Clutter this function can fail if there is no obvious mapping between the key codes. The hardware keycode can be taken from the ClutterKeyEvent.hardware_keycode member of ClutterKeyEvent.
|
A ClutterInputDevice |
|
The hardware keycode from a ClutterKeyEvent |
|
The return location for the evdev keycode |
Returns : |
TRUE if the conversion succeeded, FALSE otherwise. |
Since 1.10
guint clutter_input_device_get_n_keys (ClutterInputDevice *device
);
Retrieves the number of keys registered for device
.
|
a ClutterInputDevice |
Returns : |
the number of registered keys |
Since 1.6
void clutter_input_device_set_key (ClutterInputDevice *device
,guint index_
,guint keyval
,ClutterModifierType modifiers
);
Sets the keyval and modifiers at the given index_
for device
.
Clutter will use the keyval and modifiers set when filling out an event coming from the same input device.
|
a ClutterInputDevice |
|
the index of the key |
|
the keyval |
|
a bitmask of modifiers |
Since 1.6
gboolean clutter_input_device_get_key (ClutterInputDevice *device
,guint index_
,guint *keyval
,ClutterModifierType *modifiers
);
Retrieves the key set using clutter_input_device_set_key()
|
a ClutterInputDevice |
|
the index of the key |
|
return location for the keyval at index_ . [out]
|
|
return location for the modifiers at index_ . [out]
|
Returns : |
TRUE if a key was set at the given index |
Since 1.6
guint clutter_input_device_get_n_axes (ClutterInputDevice *device
);
Retrieves the number of axes available on device
.
|
a ClutterInputDevice |
Returns : |
the number of axes on the device |
Since 1.6
ClutterInputAxis clutter_input_device_get_axis (ClutterInputDevice *device
,guint index_
);
Retrieves the type of axis on device
at the given index.
|
a ClutterInputDevice |
|
the index of the axis |
Returns : |
the axis type |
Since 1.6
gboolean clutter_input_device_get_axis_value (ClutterInputDevice *device
,gdouble *axes
,ClutterInputAxis axis
,gdouble *value
);
Extracts the value of the given axis
of a ClutterInputDevice from
an array of axis values.
An example of typical usage for this function is:
1 2 3 4 5 6 7 |
ClutterInputDevice *device = clutter_event_get_device (event); gdouble *axes = clutter_event_get_axes (event, NULL); gdouble pressure_value = 0; clutter_input_device_get_axis_value (device, axes, CLUTTER_INPUT_AXIS_PRESSURE, &pressure_value); |
|
a ClutterInputDevice |
|
an array of axes values, typically
coming from clutter_event_get_axes() . [array]
|
|
the axis to extract |
|
return location for the axis value. [out] |
Returns : |
TRUE if the value was set, and FALSE otherwise |
Since 1.6
gboolean clutter_input_device_get_coords (ClutterInputDevice *device
,ClutterEventSequence *sequence
,ClutterPoint *point
);
Retrieves the latest coordinates of a pointer or touch point of
device
.
|
a ClutterInputDevice |
|
a ClutterEventSequence, or NULL if
the device is not touch-based. [allow-none]
|
|
return location for the pointer or touch point. [out caller-allocates] |
Returns : |
FALSE if the device's sequence hasn't been found,
and TRUE otherwise. |
Since 1.12
void clutter_input_device_get_device_coords (ClutterInputDevice *device
,gint *x
,gint *y
);
clutter_input_device_get_device_coords
has been deprecated since version 1.12 and should not be used in newly-written code. Use clutter_input_device_get_coords()
instead.
Retrieves the latest coordinates of the pointer of device
|
a ClutterInputDevice of type CLUTTER_POINTER_DEVICE
|
|
return location for the X coordinate. [out] |
|
return location for the Y coordinate. [out] |
Since 1.2
ClutterActor * clutter_input_device_get_pointer_actor
(ClutterInputDevice *device
);
Retrieves the ClutterActor underneath the pointer of device
|
a ClutterInputDevice of type CLUTTER_POINTER_DEVICE
|
Returns : |
a pointer to the ClutterActor or NULL . [transfer none]
|
Since 1.2
ClutterStage * clutter_input_device_get_pointer_stage
(ClutterInputDevice *device
);
Retrieves the ClutterStage underneath the pointer of device
|
a ClutterInputDevice of type CLUTTER_POINTER_DEVICE
|
Returns : |
a pointer to the ClutterStage or NULL . [transfer none]
|
Since 1.2
void clutter_input_device_grab (ClutterInputDevice *device
,ClutterActor *actor
);
Acquires a grab on actor
for the given device
.
Any event coming from device
will be delivered to actor
, bypassing
the usual event delivery mechanism, until the grab is released by
calling clutter_input_device_ungrab()
.
The grab is client-side: even if the windowing system used by the Clutter backend has the concept of "device grabs", Clutter will not use them.
Only ClutterInputDevice of types CLUTTER_POINTER_DEVICE
and
CLUTTER_KEYBOARD_DEVICE
can hold a grab.
|
a ClutterInputDevice |
|
a ClutterActor |
Since 1.10
void clutter_input_device_ungrab (ClutterInputDevice *device
);
Releases the grab on the device
, if one is in place.
|
a ClutterInputDevice |
Since 1.10
ClutterActor * clutter_input_device_get_grabbed_actor
(ClutterInputDevice *device
);
Retrieves a pointer to the ClutterActor currently grabbing all
the events coming from device
.
|
a ClutterInputDevice |
Returns : |
a ClutterActor, or NULL . [transfer none]
|
Since 1.10
void clutter_input_device_sequence_grab (ClutterInputDevice *device
,ClutterEventSequence *sequence
,ClutterActor *actor
);
Acquires a grab on actor
for the given device
and the given touch
sequence
.
Any touch event coming from device
and from sequence
will be
delivered to actor
, bypassing the usual event delivery mechanism,
until the grab is released by calling
clutter_input_device_sequence_ungrab()
.
The grab is client-side: even if the windowing system used by the Clutter backend has the concept of "device grabs", Clutter will not use them.
|
a ClutterInputDevice |
|
a ClutterEventSequence |
|
a ClutterActor |
Since 1.12
void clutter_input_device_sequence_ungrab (ClutterInputDevice *device
,ClutterEventSequence *sequence
);
Releases the grab on the device
for the given sequence
, if one is
in place.
|
a ClutterInputDevice |
|
a ClutterEventSequence |
Since 1.12
ClutterActor * clutter_input_device_sequence_get_grabbed_actor (ClutterInputDevice *device
,ClutterEventSequence *sequence
);
Retrieves a pointer to the ClutterActor currently grabbing the
touch events coming from device
given the sequence
.
|
a ClutterInputDevice |
|
a ClutterEventSequence |
Returns : |
a ClutterActor, or NULL . [transfer none]
|
Since 1.12
void clutter_input_device_update_from_event (ClutterInputDevice *device
,ClutterEvent *event
,gboolean update_stage
);
Forcibly updates the state of the device
using a ClutterEvent
This function should never be used by applications: it is meant for integration with embedding toolkits, like clutter-gtk
Embedding toolkits that disable the event collection inside Clutter
need to use this function to update the state of input devices depending
on a ClutterEvent that they are going to submit to the event handling code
in Clutter though clutter_do_event()
. Since the input devices hold the state
that is going to be used to fill in fields like the ClutterButtonEvent
click count, or to emit synthesized events like CLUTTER_ENTER
and
CLUTTER_LEAVE
, it is necessary for embedding toolkits to also be
responsible of updating the input device state.
For instance, this might be the code to translate an embedding toolkit native motion notification into a Clutter ClutterMotionEvent and ask Clutter to process it:
1 2 3 4 5 |
ClutterEvent c_event; translate_native_event_to_clutter (native_event, &c_event); clutter_do_event (&c_event); |
Before letting clutter_do_event()
process the event, it is necessary to call
clutter_input_device_update_from_event()
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
ClutterEvent c_event; ClutterDeviceManager *manager; ClutterInputDevice *device; translate_native_event_to_clutter (native_event, &c_event); /* get the device manager */ manager = clutter_device_manager_get_default (); /* use the default Core Pointer that Clutter * backends register by default */ device = clutter_device_manager_get_core_device (manager, %CLUTTER_POINTER_DEVICE); /* update the state of the input device */ clutter_input_device_update_from_event (device, &c_event, FALSE); clutter_do_event (&c_event); |
The update_stage
boolean argument should be used when the input device
enters and leaves a ClutterStage; it will use the ClutterStage field
of the passed event
to update the stage associated to the input device.
|
a ClutterInputDevice |
|
a ClutterEvent |
|
whether to update the ClutterStage of the device
using the stage of the event |
Since 1.2
"backend"
property"backend" ClutterBackend* : Read / Write / Construct Only
The ClutterBackend that created the device.
Since 1.6
"device-manager"
property"device-manager" ClutterDeviceManager* : Read / Write / Construct Only
The ClutterDeviceManager instance which owns the device
Since 1.6
"device-mode"
property"device-mode" ClutterInputMode : Read / Write / Construct Only
The mode of the device.
Default value: CLUTTER_INPUT_MODE_FLOATING
"device-type"
property"device-type" ClutterInputDeviceType : Read / Write / Construct Only
The type of the device
Default value: CLUTTER_POINTER_DEVICE
Since 1.2
"enabled"
property "enabled" gboolean : Read / Write
Whether the device is enabled.
A device with the "device-mode" property set
to CLUTTER_INPUT_MODE_MASTER
cannot be disabled.
A device must be enabled in order to receive events from it.
Default value: FALSE
Since 1.6
"has-cursor"
property "has-cursor" gboolean : Read / Write / Construct Only
Whether the device has an on screen cursor following its movement.
Default value: FALSE
Since 1.6
"id"
property "id" gint : Read / Write / Construct Only
The unique identifier of the device
Allowed values: >= G_MAXULONG
Default value: 0
Since 1.2
"n-axes"
property "n-axes" guint : Read
The number of axes of the device.
Default value: 0
Since 1.6