QXDevice Class Reference

The QXDevice class provides convenient access to properties of XInput devices. More...

#include <qxdevice.h>

List of all members.

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 >
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.

Detailed Description

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.


Member Typedef Documentation

typedef QList<QSharedPointer<QXDevice> > QXDevice::List

A list of devices.


Member Enumeration Documentation

The format of a single property item defined as its size in bytes.

Enumerator:
ShortFormat 

An item consists of one single byte

WordFormat 

An item consists of two bytes

The property data type.

The numeric values correspond to the atom types.

Enumerator:
IntegerType 

An integral property.

FloatType 

A float property


Constructor & Destructor Documentation

QXDevice::QXDevice ( const QByteArray &  name,
const ID  id 
)

Create a device from the given device id.

Parameters:
name the device name
id a X11 device id
QXDevice::~QXDevice (  ) 

Destroy this instance.


Member Function Documentation

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.

Parameters:
property the property name
Returns:
a list of devices
bool QXDevice::hasProperty ( const QByteArray &  name  )  const

Check, if a property exists.

Parameters:
name the property name
Returns:
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.

Parameters:
name the property name
Returns:
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.

Returns:
true, if input device properties are supported, false otherwise
QByteArray QXDevice::name (  )  const

Return the name of this device.

Returns:
the device name.
template<class T >
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.

Parameters:
name the property name
index the index of the value
Returns:
the value
Exceptions:
PropertyIndexError if there is no item at the given index
See also:
property(const QByteArray &)
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
Parameters:
name the property
type the type of the property value
Returns:
a list of all values, or empty, if an error occurred
Exceptions:
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.

Parameters:
name the property name
type expected property type
format expected property format
Returns:
the list of items as byte arrays
Exceptions:
NoSuchPropertyError if the given property is not defined
QXDeviceError if the property could not be retrieved
See also:
PropertyType
PropertyFormat
setProperty(const char*, PropertyType, PropertyFormat, const QList<QByteArray>&)
template<class T >
void QXDevice::setProperty ( const QByteArray &  name,
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.

Parameters:
name the property name
value the value
index the index at which to set the value
Exceptions:
PropertyIndexError if there is no item at the given index
See also:
setProperty(const char*, const QList<T> &)
template<class T >
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
Parameters:
name the property name
values the property values
Returns:
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.

Parameters:
name the property name
type the property type
format the property format
values the list of items
Exceptions:
NoSuchPropertyError if the given property is not defined
QXDeviceError if the property could not be retrieved
See also:
PropertyType
PropertyFormat
property(const char*, PropertyType, PropertyFormat)

The documentation for this class was generated from the following files:
 All Classes Files Functions Typedefs Enumerations Enumerator Properties
Generated on Tue Apr 20 13:25:22 2010 for synaptiks by  doxygen 1.6.3