clutter: Add clutter_input_device_[gs]et_mapping()
This function call only applies to tablets, and thus will error out unless it's called with CLUTTER_TABLET_DEVICEs. This will allow setting absolute/relative mapping on those on the fly, as this is optional.
This commit is contained in:
parent
73958aeb59
commit
9587a60da4
@ -139,6 +139,8 @@ struct _ClutterInputDevice
|
||||
gint n_strips;
|
||||
gint n_mode_groups;
|
||||
|
||||
ClutterInputDeviceMapping mapping_mode;
|
||||
|
||||
guint has_cursor : 1;
|
||||
guint is_enabled : 1;
|
||||
};
|
||||
|
@ -1531,6 +1531,11 @@ typedef enum {
|
||||
CLUTTER_INPUT_DEVICE_PAD_SOURCE_FINGER,
|
||||
} ClutterInputDevicePadSource;
|
||||
|
||||
typedef enum {
|
||||
CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE,
|
||||
CLUTTER_INPUT_DEVICE_MAPPING_RELATIVE,
|
||||
} ClutterInputDeviceMapping;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_ENUMS_H__ */
|
||||
|
@ -74,6 +74,7 @@ enum
|
||||
PROP_N_RINGS,
|
||||
PROP_N_MODE_GROUPS,
|
||||
PROP_DEVICE_NODE,
|
||||
PROP_MAPPING_MODE,
|
||||
|
||||
PROP_LAST
|
||||
};
|
||||
@ -216,6 +217,10 @@ clutter_input_device_set_property (GObject *gobject,
|
||||
self->node_path = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_MAPPING_MODE:
|
||||
self->mapping_mode = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@ -292,6 +297,10 @@ clutter_input_device_get_property (GObject *gobject,
|
||||
g_value_set_string (value, self->node_path);
|
||||
break;
|
||||
|
||||
case PROP_MAPPING_MODE:
|
||||
g_value_set_enum (value, self->mapping_mode);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||
break;
|
||||
@ -497,6 +506,14 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
|
||||
NULL,
|
||||
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
|
||||
obj_props[PROP_MAPPING_MODE] =
|
||||
g_param_spec_enum ("mapping-mode",
|
||||
P_("Device mapping mode"),
|
||||
P_("Device mapping mode"),
|
||||
CLUTTER_TYPE_INPUT_DEVICE_MAPPING,
|
||||
CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE,
|
||||
CLUTTER_PARAM_READWRITE);
|
||||
|
||||
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;
|
||||
@ -2165,3 +2182,30 @@ clutter_input_device_get_device_node (ClutterInputDevice *device)
|
||||
|
||||
return device->node_path;
|
||||
}
|
||||
|
||||
ClutterInputDeviceMapping
|
||||
clutter_input_device_get_mapping_mode (ClutterInputDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device),
|
||||
CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE);
|
||||
g_return_val_if_fail (clutter_input_device_get_device_type (device) ==
|
||||
CLUTTER_TABLET_DEVICE,
|
||||
CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE);
|
||||
|
||||
return device->mapping_mode;
|
||||
}
|
||||
|
||||
void
|
||||
clutter_input_device_set_mapping_mode (ClutterInputDevice *device,
|
||||
ClutterInputDeviceMapping mapping)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
||||
g_return_if_fail (clutter_input_device_get_device_type (device) ==
|
||||
CLUTTER_TABLET_DEVICE);
|
||||
|
||||
if (device->mapping_mode == mapping)
|
||||
return;
|
||||
|
||||
device->mapping_mode = mapping;
|
||||
g_object_notify (G_OBJECT (device), "mapping-mode");
|
||||
}
|
||||
|
@ -150,6 +150,13 @@ gint clutter_input_device_get_n_mode_groups (ClutterInputDev
|
||||
CLUTTER_AVAILABLE_IN_ALL
|
||||
const gchar * clutter_input_device_get_device_node (ClutterInputDevice *device);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_ALL
|
||||
ClutterInputDeviceMapping clutter_input_device_get_mapping_mode (ClutterInputDevice *device);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_ALL
|
||||
void clutter_input_device_set_mapping_mode (ClutterInputDevice *device,
|
||||
ClutterInputDeviceMapping mapping);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_INPUT_DEVICE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user