## GcmUsb

GcmUsb — GLib mainloop integration for libusb

## Synopsis

    #define             GCM_USB_ERROR
    enum                GcmUsbError;
    struct              GcmUsb;
    struct              GcmUsbClass;
    gboolean            gcm_usb_load                        (GcmUsb *usb,
                                                             GError **error);
    gboolean            gcm_usb_connect                     (GcmUsb *usb,
                                                             guint vendor_id,
                                                             guint product_id,
                                                             guint configuration,
                                                             guint interface,
                                                             GError **error);
    gboolean            gcm_usb_get_connected               (GcmUsb *usb);
    void                gcm_usb_attach_to_context           (GcmUsb *usb,
                                                             GMainContext *context);
    libusb_device_handle * gcm_usb_get_device_handle        (GcmUsb *usb);
    GcmUsb *            gcm_usb_new                         (void);
                        GcmUsbPrivate;

## Object Hierarchy

      GObject
       +----GcmUsb

## Properties

      "connected"                gboolean              : Read / Write

## Description

This object can be used to integrate libusb into the GLib event loop.

## Details

### GCM_USB_ERROR

    #define GCM_USB_ERROR 1

### enum GcmUsbError

    typedef enum {
    	GCM_USB_ERROR_INTERNAL
    } GcmUsbError;

### struct GcmUsb

    struct GcmUsb;

### struct GcmUsbClass

    struct GcmUsbClass {
    	GObjectClass parent_class;
    };

### gcm_usb_load ()

    gboolean            gcm_usb_load                        (GcmUsb *usb,
                                                             GError **error);

Connects to libusb. You normally don't have to call this method manually.

`usb` : | a GcmUsb instance
`error` : | a GError, or `NULL`
Returns : | `TRUE` for success

Since 2.91.1

### gcm_usb_connect ()

    gboolean            gcm_usb_connect                     (GcmUsb *usb,
                                                             guint vendor_id,
                                                             guint product_id,
                                                             guint configuration,
                                                             guint interface,
                                                             GError **error);

Connects to a specific device.

`usb` : | a GcmUsb instance
`vendor_id` : | the vendor ID to connect to
`product_id` : | the product ID to connect to
`configuration` : | the configuration index to use, usually '1'
`interface` : | the configuration interface to use, usually '0'
`error` : | a GError, or `NULL`
Returns : | `TRUE` for success

Since 2.91.1

### gcm_usb_get_connected ()

    gboolean            gcm_usb_get_connected               (GcmUsb *usb);

Since 2.91.1

### gcm_usb_attach_to_context ()

    void                gcm_usb_attach_to_context           (GcmUsb *usb,
                                                             GMainContext *context);

Connects up usb-1 with the GLib event loop. This functionality allows you to submit async requests using usb, and the callbacks just kinda happen at the right time.

`usb` : | a GcmUsb instance
`context` : | a GMainContext or `NULL`

Since 2.91.1

### gcm_usb_get_device_handle ()

    libusb_device_handle * gcm_usb_get_device_handle        (GcmUsb *usb);

Gets the low-level device handle

`usb` : | a GcmUsb instance
Returns : | The libusb_device_handle or `NULL`. Do not unref this value.

Since 2.91.1

### gcm_usb_new ()

    GcmUsb *            gcm_usb_new                         (void);

Returns : | a new GcmUsb object.

Since 2.91.1

### GcmUsbPrivate

    typedef struct _GcmUsbPrivate GcmUsbPrivate;

Private GcmUsb data

## Property Details

### The `"connected"` property

      "connected"                gboolean              : Read / Write

Default value: FALSE