libgaminggear
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Typedefs | Functions
gaminggear_device.h File Reference

Device. More...

Data Structures

struct  _GaminggearDevice
 
struct  _GaminggearDeviceClass
 

Macros

#define GAMINGGEAR_DEVICE_TYPE   (gaminggear_device_get_type())
 
#define GAMINGGEAR_DEVICE(obj)   (G_TYPE_CHECK_INSTANCE_CAST((obj), GAMINGGEAR_DEVICE_TYPE, GaminggearDevice))
 
#define IS_GAMINGGEAR_DEVICE(obj)   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GAMINGGEAR_DEVICE_TYPE))
 
#define GAMINGGEAR_DEVICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST((klass), GAMINGGEAR_DEVICE_TYPE, GaminggearDeviceClass))
 
#define IS_GAMINGGEAR_DEVICE_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE((klass), GAMINGGEAR_DEVICE_TYPE))
 

Typedefs

typedef struct _GaminggearDevice GaminggearDevice
 
typedef struct
_GaminggearDeviceClass 
GaminggearDeviceClass
 
typedef struct
_GaminggearDevicePrivate 
GaminggearDevicePrivate
 

Functions

GType gaminggear_device_get_type (void)
 
GaminggearDevicegaminggear_device_new (gchar const *identifier, guint vendor_id, guint product_id, guint num_interfaces)
 Creates new GaminggearDevice. More...
 
gchar const * gaminggear_device_get_identifier (GaminggearDevice const *gaminggear_dev)
 Get identifier. More...
 
guint gaminggear_device_get_product_id (GaminggearDevice const *gaminggear_dev)
 Get product id. More...
 
guint gaminggear_device_get_vendor_id (GaminggearDevice const *gaminggear_dev)
 Get vendor id. More...
 
guint gaminggear_device_get_num_interfaces (GaminggearDevice const *gaminggear_dev)
 Get number of interfaces. More...
 
gboolean gaminggear_device_matches (GaminggearDevice const *gaminggear_dev, guint vendor_id, guint product_id)
 Match device agains vendor/product id. More...
 
int gaminggear_device_open (GaminggearDevice *gaminggear_device, gchar const *key, gint flags, GError **error)
 Open file. More...
 
gboolean gaminggear_device_close (GaminggearDevice *gaminggear_device, gchar const *key, GError **error)
 Close file. More...
 
void gaminggear_device_set_path (GaminggearDevice *gaminggear_device, gchar const *key, gchar const *path)
 Store a path. More...
 
gchar const * gaminggear_device_get_path (GaminggearDevice *gaminggear_device, gchar const *key)
 Get a previously stored path. More...
 
void gaminggear_device_lock (GaminggearDevice *gaminggear_dev)
 Lock recursive lock. More...
 
void gaminggear_device_unlock (GaminggearDevice *gaminggear_dev)
 Unlock recursive lock. More...
 
gboolean gaminggear_device_equal (GaminggearDevice const *one, GaminggearDevice const *other)
 Tests if two GaminggearDevices point to the same device. More...
 

Detailed Description

Device.

Macro Definition Documentation

#define GAMINGGEAR_DEVICE (   obj)    (G_TYPE_CHECK_INSTANCE_CAST((obj), GAMINGGEAR_DEVICE_TYPE, GaminggearDevice))
#define GAMINGGEAR_DEVICE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_CAST((klass), GAMINGGEAR_DEVICE_TYPE, GaminggearDeviceClass))
#define GAMINGGEAR_DEVICE_TYPE   (gaminggear_device_get_type())
#define IS_GAMINGGEAR_DEVICE (   obj)    (G_TYPE_CHECK_INSTANCE_TYPE((obj), GAMINGGEAR_DEVICE_TYPE))
#define IS_GAMINGGEAR_DEVICE_CLASS (   klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), GAMINGGEAR_DEVICE_TYPE))

Typedef Documentation

typedef struct _GaminggearDevicePrivate GaminggearDevicePrivate

Function Documentation

gboolean gaminggear_device_close ( GaminggearDevice gaminggear_device,
gchar const *  key,
GError **  error 
)

Close file.

Parameters
gaminggear_deviceA GaminggearDevice.
keyA key to identify path.
errorReturn location for error or NULL.
Return values
conditionTRUE on success, FALSE else.
Since
1.0
gboolean gaminggear_device_equal ( GaminggearDevice const *  one,
GaminggearDevice const *  other 
)

Tests if two GaminggearDevices point to the same device.

Parameters
oneA GaminggearDevice.
otherAnother GaminggearDevice.
Return values
boolTRUE if devices are equal, FALSE else.
Since
1.0
gchar const* gaminggear_device_get_identifier ( GaminggearDevice const *  gaminggear_dev)

Get identifier.

Parameters
gaminggear_devA GaminggearDevice.
Return values
identifierAn identifier that was given at construction time and is unique for the usb device.
Since
1.0
guint gaminggear_device_get_num_interfaces ( GaminggearDevice const *  gaminggear_dev)

Get number of interfaces.

Parameters
gaminggear_devA GaminggearDevice.
Return values
num_interfacesThe number of interfaces of the device given at construction time.
Since
1.0
gchar const* gaminggear_device_get_path ( GaminggearDevice gaminggear_device,
gchar const *  key 
)

Get a previously stored path.

Parameters
gaminggear_deviceA GaminggearDevice.
keyA key to identify path.
Return values
pathor NULL. This path is property of the device and should no be freed!
Since
1.0
guint gaminggear_device_get_product_id ( GaminggearDevice const *  gaminggear_dev)

Get product id.

Parameters
gaminggear_devA GaminggearDevice.
Return values
product_idThe product id given at construction time.
Since
1.0
GType gaminggear_device_get_type ( void  )
guint gaminggear_device_get_vendor_id ( GaminggearDevice const *  gaminggear_dev)

Get vendor id.

Parameters
gaminggear_devA GaminggearDevice.
Return values
vendor_idThe vendor id given at construction time.
Since
1.0
void gaminggear_device_lock ( GaminggearDevice gaminggear_dev)

Lock recursive lock.

Parameters
gaminggear_devA GaminggearDevice.
Since
1.0
gboolean gaminggear_device_matches ( GaminggearDevice const *  gaminggear_dev,
guint  vendor_id,
guint  product_id 
)

Match device agains vendor/product id.

Parameters
gaminggear_devA GaminggearDevice.
vendor_idThe vendor id to match against.
product_idThe product id to match against.
Return values
boolTRUE if vendor and product ids match, else FALSE.
Since
1.0
GaminggearDevice* gaminggear_device_new ( gchar const *  identifier,
guint  vendor_id,
guint  product_id,
guint  num_interfaces 
)

Creates new GaminggearDevice.

Parameters
identifierThe unique identifier of the device.
vendor_idThe vendor id of the device.
product_idThe product id of the device.
num_interfacesThe number of interfaces of the device.
Return values
deviceThe new GaminggearDevice which should be freed with g_object_unref().
Since
1.0
int gaminggear_device_open ( GaminggearDevice gaminggear_device,
gchar const *  key,
gint  flags,
GError **  error 
)

Open file.

Once successfully opened, the file descriptor is stored and just returned on subsequent calls. File should be closed with gaminggear_device_close() instead of close(). The using code is responsible for closing all files prior to unref of GaminggearDevice.

Parameters
gaminggear_deviceA GaminggearDevice.
keyA key to identify path.
flagsFlags for open.
errorReturn location for error or NULL.
Return values
fdFile descriptor.
Since
1.0
void gaminggear_device_set_path ( GaminggearDevice gaminggear_device,
gchar const *  key,
gchar const *  path 
)

Store a path.

Parameters
gaminggear_deviceA GaminggearDevice.
keyA key to identify path.
pathThe path to be stored.
Since
1.0
void gaminggear_device_unlock ( GaminggearDevice gaminggear_dev)

Unlock recursive lock.

Parameters
gaminggear_devA GaminggearDevice.
Since
1.0