ManetteDevice

ManetteDevice — An object representing a physical gamepad

Functions

Signals

void absolute-axis-event Run Last
void button-press-event Run Last
void button-release-event Run Last
void disconnected Run Last
void event Run Last
void hat-axis-event Run Last

Types and Values

Object Hierarchy

    GObject
    ╰── ManetteDevice

Includes

#include <src/libmanette.h>

Description

Functions

manette_device_has_input ()

gboolean
manette_device_has_input (ManetteDevice *self,
                          guint type,
                          guint code);

Gets whether the device has the given input. If the input is present it means that the device can send events for it regardless of whether the device is mapped or not.

Parameters

self

a ManetteDevice

 

type

the input type

 

code

the input code

 

Returns

whether the device has the given input


manette_device_get_name ()

const gchar *
manette_device_get_name (ManetteDevice *self);

Gets the device's name.

Parameters

self

a ManetteDevice

 

Returns

the name of self , do not modify it or free it.

[transfer none]


manette_device_get_guid ()

const gchar *
manette_device_get_guid (ManetteDevice *self);

Gets the identifier used by SDL mappings to discriminate game controller devices.

Parameters

self

a ManetteDevice

 

Returns

the identifier used by SDL mappings.

[transfer none]

Since: 0.3


manette_device_get_mapping ()

char *
manette_device_get_mapping (ManetteDevice *self);

Gets the user mapping for self , or default mapping if there isn't any. Can return NULL if there's no mapping.

Parameters

self

a ManetteDevice

 

Returns

the mapping for self .

[transfer full][nullable]

Since: 0.3


manette_device_has_user_mapping ()

gboolean
manette_device_has_user_mapping (ManetteDevice *self);

Gets whether self has a user mapping.

Parameters

self

a ManetteDevice

 

Returns

whether self has a user mapping


manette_device_save_user_mapping ()

void
manette_device_save_user_mapping (ManetteDevice *self,
                                  const gchar *mapping_string);

Saves mapping_string as the user mapping for self .

Parameters

self

a ManetteDevice

 

mapping_string

the mapping string

 

manette_device_remove_user_mapping ()

void
manette_device_remove_user_mapping (ManetteDevice *self);

Removes the user mapping for self .

Parameters

self

a ManetteDevice

 

manette_device_has_rumble ()

gboolean
manette_device_has_rumble (ManetteDevice *self);

Gets whether self supports rumble.

Parameters

self

a ManetteDevice

 

Returns

whether self supports rumble


manette_device_rumble ()

gboolean
manette_device_rumble (ManetteDevice *self,
                       guint16 strong_magnitude,
                       guint16 weak_magnitude,
                       guint16 milliseconds);

Make self rumble during milliseconds milliseconds, with the heavy and light motors rumbling at their respectively defined magnitudes.

The duration cannot exceed 32767 milliseconds.

Parameters

self

a ManetteDevice

 

strong_magnitude

the magnitude for the heavy motor

 

weak_magnitude

the magnitude for the light motor

 

milliseconds

the rumble effect play time in milliseconds

 

Returns

whether the rumble effect was played

Types and Values

MANETTE_TYPE_DEVICE

#define MANETTE_TYPE_DEVICE (manette_device_get_type())

ManetteDevice

typedef struct _ManetteDevice ManetteDevice;

Signal Details

The “absolute-axis-event” signal

void
user_function (ManetteDevice *self,
               ManetteEvent  *event,
               gpointer       user_data)

Emitted when an absolute axis' value changes.

Parameters

self

a ManetteDevice

 

event

the event emitted by the manette device

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “button-press-event” signal

void
user_function (ManetteDevice *self,
               ManetteEvent  *event,
               gpointer       user_data)

Emitted when a button is pressed.

Parameters

self

a ManetteDevice

 

event

the event emitted by the manette device

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “button-release-event” signal

void
user_function (ManetteDevice *self,
               ManetteEvent  *event,
               gpointer       user_data)

Emitted when a button is released.

Parameters

self

a ManetteDevice

 

event

the event emitted by the manette device

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “disconnected” signal

void
user_function (ManetteDevice *self,
               gpointer       user_data)

Emitted when the device is disconnected.

Parameters

self

a ManetteDevice

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “event” signal

void
user_function (ManetteDevice *self,
               ManetteEvent  *event,
               gpointer       user_data)

Emitted for any kind of event before mapping it.

Parameters

self

a ManetteDevice

 

event

the event emitted by the manette device

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “hat-axis-event” signal

void
user_function (ManetteDevice *self,
               ManetteEvent  *event,
               gpointer       user_data)

Emitted when a hat axis' value changes.

Parameters

self

a ManetteDevice

 

event

the event emitted by the manette device

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

See Also

ManetteMonitor