Top | ![]() |
![]() |
![]() |
![]() |
GFlags ├── SrtInputDeviceInterfaceFlags ├── SrtInputDeviceMonitorFlags ╰── SrtInputDeviceTypeFlags GInterface ├── SrtInputDevice ╰── SrtInputDeviceMonitor
SrtInputDeviceInterfaceFlags
srt_input_device_get_interface_flags (SrtInputDevice *device
);
Return flags describing how the input device can be used.
SrtInputDeviceTypeFlags
srt_input_device_get_type_flags (SrtInputDevice *device
);
Return flags describing what sort of device this is. If possible, these will be taken from a data source such as udev's input_id builtin, which will be treated as authoritative.
const char *
srt_input_device_get_dev_node (SrtInputDevice *device
);
Return the path of the device node in /dev that is implemented by this
input device, or NULL
if not known or if the device does not have a
corresponding device node.
For processes in a container, it is not guaranteed that this path will exist in the container's /dev.
The returned string will not be freed as long as device
is referenced,
but the device node in /dev might be deleted, or even reused for a different
device.
A path in /dev that will not be
freed as long as a reference to device
is held, or NULL
.
[nullable][transfer none]
const char *
srt_input_device_get_sys_path (SrtInputDevice *device
);
Return the path of the device directory in /sys that represents this input device.
For processes in a container, it is not guaranteed that this path will exist in the container's /sys.
The returned string will not be freed as long as device
is referenced,
but the directory in /sys might be deleted, or even reused for a different
device.
A path in /sys that will not be
freed as long as a reference to device
is held, or NULL
.
[nullable][transfer none]
const char *
srt_input_device_get_subsystem (SrtInputDevice *device
);
Return the subsystem in which this device exists, typically input
or hidraw, or NULL
if not known.
A short string that will not be
freed as long as a reference to device
is held, or NULL
.
[nullable][transfer none]
gchar **
srt_input_device_dup_udev_properties (SrtInputDevice *device
);
Return the udev properties of this input device, if available, in
the same format as environ
. g_environ_getenv()
can be used to
process them.
gchar *
srt_input_device_dup_uevent (SrtInputDevice *device
);
Return the uevent
data from the kernel.
gboolean srt_input_device_get_identity (SrtInputDevice *device
,unsigned int *bus_type
,unsigned int *vendor_id
,unsigned int *product_id
,unsigned int *version
);
Attempt to identify the device. If available, return the bus type, the vendor ID, the product ID and/or the device version via "out" parameters.
The source of the information is unspecified. Use
srt_input_device_get_hid_identity()
,
srt_input_device_get_input_identity()
and/or
srt_input_device_get_usb_device_identity()
if a specific source
is desired.
device |
An object implementing SrtInputDeviceInterface |
|
bus_type |
Used to return the bus type from |
[out] |
vendor_id |
Used to return the vendor ID, namespaced by
the |
[out] |
product_id |
Used to return the product ID, namespaced by
the |
[out] |
version |
Used to return the device version, or 0 if unavailable. |
[out] |
size_t srt_input_device_get_event_capabilities (SrtInputDevice *device
,unsigned int type
,unsigned long *storage
,size_t n_longs
);
Fill a buffer with the event capabilities in the same encoding used for the EVIOCGBIT ioctl, or query how large that buffer would have to be.
Bits in storage
above the highest known event value will be zeroed.
If storage
is too small, high event values will not be represented.
For example, if type
is EV_KEY
and n_longs
is 1, then storage
will only indicate whether the first 32 or 64 key event codes are
supported, and will not indicate anything about the level of support
for KEY_RIGHTALT
(event code 100).
If type
is not a supported type, all of storage
will be zeroed and
0 will be returned.
device |
An object implementing SrtInputDeviceInterface |
|
type |
An event type from |
|
storage |
An
array of |
[optional][out caller-allocates][array length=n_longs] |
n_longs |
The length of |
size_t srt_input_device_get_event_types (SrtInputDevice *device
,unsigned long *storage
,size_t n_longs
);
Fill a buffer with the supported event types in the same encoding used
for the EVIOCGBIT ioctl, or query how large that buffer would have to be.
This is the same as
srt_input_device_get_event_capabilities (device, 0, ...)
,
except that bit numbers in storage
reflect event types, for example
bit number 3 (storage[0] & (1 << 3)
) represents
event type 3 (EV_ABS
).
device |
An object implementing SrtInputDeviceInterface |
|
storage |
An
array of |
[optional][out caller-allocates][array length=n_longs] |
n_longs |
The length of |
gboolean srt_input_device_has_event_type (SrtInputDevice *device
,unsigned int type
);
If the device
is an evdev device implementing the given event
type, return TRUE
. Otherwise return FALSE
.
device |
An object implementing SrtInputDeviceInterface |
|
type |
|
gboolean srt_input_device_has_event_capability (SrtInputDevice *device
,unsigned int type
,unsigned int code
);
If the device
is an evdev device implementing the given event
type and code, return TRUE
. Otherwise return FALSE
.
This is currently only implemented for EV_KEY
, EV_ABS
, EV_REL
and EV_FF
(the interesting event types for game controllers), and
will return FALSE
for more exotic event types.
device |
An object implementing SrtInputDeviceInterface |
|
type |
|
|
code |
A bit appropriate for the given evdev event type;
for example, if |
gboolean srt_input_device_has_input_property (SrtInputDevice *device
,unsigned int input_prop
);
If the device
is an evdev device with the given input
property, return TRUE
. Otherwise return FALSE
.
device |
An object implementing SrtInputDeviceInterface |
|
input_prop |
An input property such as |
size_t srt_input_device_get_input_properties (SrtInputDevice *device
,unsigned long *storage
,size_t n_longs
);
Fill a buffer with the input device properties in the same encoding used for the EVIOCGPROP ioctl, or query how large that buffer would have to be.
Bit numbers in storage
reflect input properties, for example
bit number 6 (storage[0] & (1 << 6)
) represents
input property 6 (INPUT_PROP_ACCELEROMETER
).
device |
An object implementing SrtInputDeviceInterface |
|
storage |
An
array of |
[optional][out caller-allocates][array length=n_longs] |
n_longs |
The length of |
SrtInputDeviceTypeFlags
srt_input_device_guess_type_flags_from_event_capabilities
(SrtInputDevice *device
);
const char *
srt_input_device_get_hid_sys_path (SrtInputDevice *device
);
Return the path of the device directory in /sys that represents this
input device's closest ancestor that is a Human Interface Device.
Many, but not all, input devices have a HID ancestor. If there is no
applicable HID device, return NULL
.
For processes in a container, it is not guaranteed that this path will exist in the container's /sys.
The returned string will not be freed as long as device
is referenced,
but the directory in /sys might be deleted, or even reused for a different
device.
A path in /sys that will not be
freed as long as a reference to device
is held, or NULL
.
[nullable][transfer none]
GBytes *
srt_input_device_dup_hid_report_descriptor
(SrtInputDevice *device
);
Return the raw HID report descriptor from the kernel.
The bytes of a HID report descriptor,
or NULL
for non-HID devices or if no HID descriptor is available.
Free with g_bytes_unref()
.
[nullable][transfer full]
gchar *
srt_input_device_dup_hid_uevent (SrtInputDevice *device
);
Return the uevent data structure similar to
srt_input_device_dup_uevent()
, but for the ancestor device returned
by srt_input_device_get_hid_sys_path()
.
gboolean srt_input_device_get_hid_identity (SrtInputDevice *device
,unsigned int *bus_type
,unsigned int *vendor_id
,unsigned int *product_id
,const char **name
,const char **phys
,const char **uniq
);
Attempt to identify the device. If available, return details via "out" parameters.
device |
An object implementing SrtInputDeviceInterface |
|
bus_type |
Used to return the bus type from |
[out] |
vendor_id |
Used to return the vendor ID, namespaced by
the |
[out] |
product_id |
Used to return the product ID, namespaced by
the |
[out] |
name |
Used to return a human-readable name
that usually combines the vendor and product, or empty or |
[out][transfer none] |
phys |
Used to return how the device is
physically attached, or empty or |
[out][transfer none] |
uniq |
Used to return the device's serial number
or other unique identifier, or empty or |
[out][transfer none] |
const char *
srt_input_device_get_input_sys_path (SrtInputDevice *device
);
If the device
has an ancestor device that advertises evdev input
capabilities, return the path in /sys for that device. Otherwise
return NULL
.
For processes in a container, it is not guaranteed that this path will exist in the container's /sys.
The returned string will not be freed as long as device
is referenced,
but the directory in /sys might be deleted, or even reused for a different
device.
A path in /sys that will not be
freed as long as a reference to device
is held, or NULL
.
[nullable][transfer none]
gchar *
srt_input_device_dup_input_uevent (SrtInputDevice *device
);
Return the uevent data structure similar to
srt_input_device_dup_uevent()
, but for the ancestor device returned
by srt_input_device_get_input_sys_path()
.
gboolean srt_input_device_get_input_identity (SrtInputDevice *device
,unsigned int *bus_type
,unsigned int *vendor_id
,unsigned int *product_id
,unsigned int *version
,const char **name
,const char **phys
,const char **uniq
);
Attempt to identify the device. If available, return details via "out" parameters.
device |
An object implementing SrtInputDeviceInterface |
|
bus_type |
Used to return the bus type from |
[out] |
vendor_id |
Used to return the vendor ID, namespaced by
the |
[out] |
product_id |
Used to return the product ID, namespaced by
the |
[out] |
version |
Used to return the product version, or 0 if unavailable. |
[out] |
name |
Used to return a human-readable name
that usually combines the vendor and product, or empty or |
[out][transfer none] |
phys |
Used to return how the device is
physically attached, or empty or |
[out][transfer none] |
uniq |
Used to return the device's serial number
or other unique identifier, or empty or |
[out][transfer none] |
const char *
srt_input_device_get_usb_device_sys_path
(SrtInputDevice *device
);
If the device
is associated with a USB device, return the path in
/sys representing the Linux usb_device
. If not, return NULL
.
For processes in a container, it is not guaranteed that this path will exist in the container's /sys.
The returned string will not be freed as long as device
is referenced,
but the directory in /sys might be deleted, or even reused for a different
device.
A path in /sys that will not be
freed as long as a reference to device
is held, or NULL
.
[nullable][transfer none]
gchar *
srt_input_device_dup_usb_device_uevent
(SrtInputDevice *device
);
Return the uevent data structure similar to
srt_input_device_dup_uevent()
, but for the ancestor device returned
by srt_input_device_get_usb_device_sys_path()
.
gboolean srt_input_device_get_usb_device_identity (SrtInputDevice *device
,unsigned int *vendor_id
,unsigned int *product_id
,unsigned int *device_version
,const char **manufacturer
,const char **product
,const char **serial
);
Attempt to identify the device. If available, return details via "out" parameters.
device |
An object implementing SrtInputDeviceInterface |
|
vendor_id |
Used to return the vendor ID, namespaced by
the |
[out] |
product_id |
Used to return the product ID, namespaced by
the |
[out] |
device_version |
Used to return the product version, or 0 if unavailable. |
[out] |
manufacturer |
Used to return the human-readable name
of the manufacturer, or empty or |
[out][transfer none] |
product |
Used to return the human-readable name
of the product, or empty or |
[out][transfer none] |
serial |
Used to return the device's serial number
or other unique identifier, or empty or |
[out][transfer none] |
int srt_input_device_open (SrtInputDevice *device
,int flags
,GError **error
);
flags
must include one of: O_RDONLY, O_WRONLY, or O_RDWR.
flags
may include zero or more of: O_NONBLOCK.
The file descriptor is always opened with O_CLOEXEC and O_NOCTTY. Explicitly specifying those flags is not allowed.
device |
An object implementing SrtInputDeviceInterface |
|
flags |
Flags affecting how the device is opened |
|
error |
Used to report the error on failure |
SrtInputDeviceMonitor *
srt_input_device_monitor_new (SrtInputDeviceMonitorFlags flags
);
Return an object that can be used to enumerate and monitor input devices.
Take additional references with g_object_ref()
, release references
with g_object_unref()
.
SrtInputDeviceMonitorFlags
srt_input_device_monitor_get_flags (SrtInputDeviceMonitor *monitor
);
Return flags describing the input device monitor.
void
srt_input_device_monitor_request_raw_hid
(SrtInputDeviceMonitor *monitor
);
Tell the input device monitor to return all raw HID devices.
If neither this method nor srt_input_device_monitor_request_evdev()
is
called, no devices will be found.
This function cannot be called if srt_input_device_monitor_start()
or srt_input_device_monitor_stop()
have already been called.
void
srt_input_device_monitor_request_evdev
(SrtInputDeviceMonitor *monitor
);
Tell the input device monitor to return all evdev (event) devices.
If neither this method nor srt_input_device_monitor_request_raw_hid()
is
called, no devices will be found.
This function cannot be called if srt_input_device_monitor_start()
or srt_input_device_monitor_stop()
have already been called.
gboolean
srt_input_device_monitor_is_active (SrtInputDeviceMonitor *monitor
);
Return TRUE
if srt_input_device_monitor_start()
has been called
successfully, and srt_input_device_monitor_stop()
has not subsequently
been called.
gboolean srt_input_device_monitor_start (SrtInputDeviceMonitor *monitor
,GError **error
);
Start to watch for input devices.
The device monitor will emit signals in the thread-default main
context of the thread where this function was called
(see g_main_context_push_thread_default()
for details).
The SrtInputDeviceMonitor::added signal will be emitted when
a matching input device is detected.
If the monitor is watching for both SRT_INPUT_DEVICE_INTERFACE_FLAGS_EVENT
and SRT_INPUT_DEVICE_INTERFACE_FLAGS_RAW_HID
devices, one signal will be
emitted for each one.
The SrtInputDeviceMonitor::removed signal will be emitted when a matching input device is removed.
This function cannot be called if srt_input_device_monitor_start()
or srt_input_device_monitor_stop()
have already been called.
void
srt_input_device_monitor_stop (SrtInputDeviceMonitor *monitor
);
Stop the input device monitor. It still exists in memory until all references are released, but will stop signalling new events.
Flags describing a type of input device. An input device can fall into one or more of these categories.
A joystick, gamepad, steering wheel or other game controller (udev ID_INPUT_JOYSTICK) |
||
An accelerometer, either motion controls in a game controller such as Playstation 3 "sixaxis" controllers or in the computer itself (udev ID_INPUT_ACCELEROMETER). Note that unlike SDL, SrtInputDeviceMonitor always considers accelerometers to be their own device type distinct from joysticks; there is no equivalent of SDL_HINT_ACCELEROMETER_AS_JOYSTICK. |
||
Keyboards with a somewhat full set of keys (udev ID_INPUT_KEYBOARD) |
||
Any device with keyboard keys, however incomplete (udev ID_INPUT_KEY) |
||
A mouse or mouse-like pointer controller (udev ID_INPUT_MOUSE) |
||
A touchpad, perhaps built in to a game controller like the Playstation 4 controller, or perhaps used as a mouse replacement as in most laptops (udev ID_INPUT_TOUCHPAD) |
||
A touchscreen (udev ID_INPUT_TOUCHSCREEN) |
||
A graphics tablet (udev ID_INPUT_TABLET) |
||
A graphics tablet with buttons (udev ID_INPUT_TABLET_PAD) |
||
A mouse-like control similar to the IBM/Lenovo Trackpoint (udev ID_INPUT_POINTINGSTICK) |
||
A switch, such as a laptop lid being opened (udev ID_INPUT_SWITCH) |
||
None of the above |
Flags describing the interface offered by an input device.
Flags affecting the behaviour of the input device monitor.
typedef struct _SrtInputDeviceMonitorInterface SrtInputDeviceMonitorInterface;
The interface implemented by each SrtInputDeviceMonitor.
“flags”
property“flags” SrtInputDeviceMonitorFlags
Flags affecting the input device monitor.
Flags: Read / Write / Construct Only
“is-active”
property“is-active” gboolean
TRUE if started and not stopped.
Flags: Read
Default value: FALSE
“added”
signalvoid user_function (SrtInputDeviceMonitor *monitor, SrtInputDevice *device, gpointer user_data)
Emitted when an input device is added.
monitor |
The input device monitor |
|
device |
The device |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“all-for-now”
signalvoid user_function (SrtInputDeviceMonitor *monitor, gpointer user_data)
Emitted when the initial batch of input devices has been discovered.
monitor |
The input device monitor |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last
“removed”
signalvoid user_function (SrtInputDeviceMonitor *monitor, SrtInputDevice *device, gpointer user_data)
Emitted when an input device is removed.
monitor |
The input device monitor |
|
device |
The device |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last