The QXDevice class provides convenient access to properties of XInput devices. More...
#include <qxdevice.h>
Public Types | |
| enum | PropertyType { IntegerType, FloatType } |
The property data type. More... | |
| enum | PropertyFormat { ByteFormat = 8, ShortFormat = 16, WordFormat = 32 } |
The format of a single property item defined as its size in bytes. More... | |
| typedef unsigned long | ID |
| A device ID. | |
| typedef QList< QSharedPointer < QXDevice > > | List |
Public Member Functions | |
| QXDevice (const QByteArray &name, const ID id) | |
Create a device from the given device id. | |
| ~QXDevice () | |
| QByteArray | name () const |
| Return the name of this device. | |
| QList< QByteArray > | property (const QByteArray &name, PropertyType type, PropertyFormat format) const |
| Return the raw values of the given property. | |
| void | setProperty (const QByteArray &name, PropertyType type, PropertyFormat format, const QList< QByteArray > &values) |
| Set the raw values of the given property. | |
| template<class T > | |
| QList< T > | property (const QByteArray &name) const |
| Query the values of a property. | |
| template<class T > | |
| T | property (const QByteArray &name, int index) |
| Query a single value. | |
| template<class T > | |
| void | setProperty (const QByteArray &name, const QList< T > &values) |
| Set the values of a property. | |
| template<class T > | |
| void | setProperty (const QByteArray &name, T value, int index=0) |
| Set a single value. | |
| bool | hasProperty (const QByteArray &name) const |
| Check, if a property exists. | |
| template<> | |
| void | setProperty (const QByteArray &name, const QList< bool > &values) |
| Set a boolean property. | |
| template<> | |
| void | setProperty (const QByteArray &name, const QList< uchar > &values) |
| Set a property as byte list. | |
| template<> | |
| void | setProperty (const QByteArray &name, const QList< int > &values) |
Set a property as list of int integers. | |
| template<> | |
| void | setProperty (const QByteArray &name, const QList< float > &values) |
Set a property as list of float values. | |
Static Public Member Functions | |
| static bool | isSupported () |
| Check for XInput support on the server side. | |
| static bool | isPropertyDefined (const QByteArray &name) |
| Check, if the given property is defined. | |
| static List | findDevicesWithProperty (const QByteArray &property) |
List devices which have the given property. | |
The QXDevice class provides convenient access to properties of XInput devices.
Since Xorg 1.6 XInput supports device-specific properties. This class provides a simple, Qt-compatible interface to get and set these properties. Use isSupported() and isPropertyDefined(const QByteArray&) to check, whether the current X server supports properties and knows about specific properties.
| typedef QList<QSharedPointer<QXDevice> > QXDevice::List |
A list of devices.
| QXDevice::QXDevice | ( | const QByteArray & | name, | |
| const ID | id | |||
| ) |
Create a device from the given device id.
| name | the device name | |
| id | a X11 device id |
| QXDevice::~QXDevice | ( | ) |
Destroy this instance.
| QXDevice::List QXDevice::findDevicesWithProperty | ( | const QByteArray & | property | ) | [static] |
List devices which have the given property.
This function enumerates all server-side devices and returns a list of devices with the given property.
| property | the property name |
| bool QXDevice::hasProperty | ( | const QByteArray & | name | ) | const |
Check, if a property exists.
| name | the property name |
true, if the property is defined for this device, false otherwise. | bool QXDevice::isPropertyDefined | ( | const QByteArray & | name | ) | [static] |
Check, if the given property is defined.
This function tries to construct an X11 Atom for the given property. If this fails, the property is most likely not supported by the server.
| name | the property name |
true, if the property is defined, false otherwise | bool QXDevice::isSupported | ( | ) | [static] |
Check for XInput support on the server side.
This function checks the XInput version reported by the server. If no display is available or XInput is too old, it returns false.
true, if input device properties are supported, false otherwise | QByteArray QXDevice::name | ( | ) | const |
Return the name of this device.
| T QXDevice::property | ( | const QByteArray & | name, | |
| int | index | |||
| ) | [inline] |
Query a single value.
This is an overloaded member function. It simply returns the value at the given index (0-based). If the property contains too few values, the default-constructed value is returned.
| name | the property name | |
| index | the index of the value |
| PropertyIndexError | if there is no item at the given index |
| QList< float > QXDevice::property< float > | ( | const QByteArray & | name | ) | const [inline] |
Query the values of a property.
Get a property as a list of float values.
Get a property as a list of int integers.
Get a property as list of single bytes.
Get a property as list of boolean values.
The server-side property with the given name is queried. The return value is interpreted according to the template argument.
If the property is not defined for this device or cannot be interpreted correctly, an empty list is returned.
This method is implemented for these types:
bool char | name | the property | |
| type | the type of the property value |
| NoSuchPropertyError | if the given property is not defined | |
| QXDeviceError | if the property could not be retrieved |
| QList< QByteArray > QXDevice::property | ( | const QByteArray & | name, | |
| PropertyType | type, | |||
| PropertyFormat | format | |||
| ) | const |
Return the raw values of the given property.
The returned list is empty, if the actual property type or format do not match type and format or if this device is invalid.
| name | the property name | |
| type | expected property type | |
| format | expected property format |
| NoSuchPropertyError | if the given property is not defined | |
| QXDeviceError | if the property could not be retrieved |
| void QXDevice::setProperty | ( | const QByteArray & | name, | |
| T | value, | |||
| int | index = 0 | |||
| ) | [inline] |
Set a single value.
This is an overloaded member function. It simply sets the value at the given index (0-based). If the property contains too few values, false is returned.
| name | the property name | |
| value | the value | |
| index | the index at which to set the value |
| PropertyIndexError | if there is no item at the given index |
| void QXDevice::setProperty | ( | const QByteArray & | name, | |
| const QList< T > & | values | |||
| ) | [inline] |
Set the values of a property.
The server-side property with the given name is set to the given list of values.
This method is implemented for these types:
bool char | name | the property name | |
| values | the property values |
true, if the property was set, false otherwise | void QXDevice::setProperty | ( | const QByteArray & | name, | |
| PropertyType | type, | |||
| PropertyFormat | format, | |||
| const QList< QByteArray > & | values | |||
| ) |
Set the raw values of the given property.
The returned list is empty, if the actual property type or format do not match type and format or if this device is invalid.
| name | the property name | |
| type | the property type | |
| format | the property format | |
| values | the list of items |
| NoSuchPropertyError | if the given property is not defined | |
| QXDeviceError | if the property could not be retrieved |
1.6.3