Commit 3ef5bcc1 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

gamepad: Remove custom types

Remove StandardGamepadButton, StandardGamepadAxis and GamepadInputType
and directly use the corresponding Linux event types and codes.

https://bugzilla.gnome.org/show_bug.cgi?id=782611
parent 30104a2f
......@@ -77,7 +77,6 @@ gnome_games_SOURCES = \
\
gamepad/gamepad.c \
gamepad/gamepad-dpad.c \
gamepad/gamepad-input-type.c \
gamepad/gamepad-mapped-event.c \
gamepad/gamepad-mapping.c \
gamepad/gamepad-mapping-error.c \
......@@ -85,8 +84,6 @@ gnome_games_SOURCES = \
gamepad/gamepad-monitor.c \
gamepad/raw-gamepad.c \
gamepad/raw-gamepad-monitor.c \
gamepad/standard-gamepad-axis.c \
gamepad/standard-gamepad-button.c \
\
generic/generic-game.vala \
generic/generic-game-uri-adapter.vala \
......
......@@ -4,16 +4,15 @@
#define GAMES_GAMEPAD_DPAD_H
#include <glib-object.h>
#include "gamepad-input-type.h"
G_BEGIN_DECLS
#define GAMES_TYPE_GAMEPAD_DPAD (games_gamepad_dpad_get_type ())
typedef struct {
GamesGamepadInputType types[4];
gint values[4];
gint axis_values[2];
guint16 types[4];
guint16 values[4];
gint32 axis_values[2];
} GamesGamepadDPad;
GType games_gamepad_dpad_get_type (void) G_GNUC_CONST;
......
// This file is part of GNOME Games. License: GPL-3.0+.
#include "gamepad-input-type.h"
GType
games_gamepad_input_type_get_type (void)
{
static volatile gsize type_id = 0;
static const GEnumValue values[] = {
{ GAMES_GAMEPAD_INPUT_TYPE_INVALID, "GAMES_GAMEPAD_INPUT_TYPE_INVALID", "invalid" },
{ GAMES_GAMEPAD_INPUT_TYPE_AXIS, "GAMES_GAMEPAD_INPUT_TYPE_AXIS", "axis" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "GAMES_GAMEPAD_INPUT_TYPE_BUTTON", "button" },
{ 0, NULL, NULL },
};
if (g_once_init_enter (&type_id))
g_once_init_leave (&type_id,
g_enum_register_static ("GamesGamepadInputType",
values));
return type_id;
}
// This file is part of GNOME Games. License: GPL-3.0+.
#ifndef GAMES_GAMEPAD_INPUT_TYPE_H
#define GAMES_GAMEPAD_INPUT_TYPE_H
#include <glib-object.h>
#include <linux/input-event-codes.h>
G_BEGIN_DECLS
#define GAMES_TYPE_GAMEPAD_INPUT_TYPE (games_gamepad_input_type_get_type ())
/**
* GamesGamepadInputType:
* @GAMES_GAMEPAD_INPUT_TYPE_INVALID: an invalid input type
* @GAMES_GAMEPAD_INPUT_TYPE_AXIS: an axis
* @GAMES_GAMEPAD_INPUT_TYPE_BUTTON: a button
*
* The input types of a standard gamepad.
**/
typedef guint16 GamesGamepadInputType;
#define GAMES_GAMEPAD_INPUT_TYPE_INVALID EV_MAX
#define GAMES_GAMEPAD_INPUT_TYPE_AXIS EV_ABS
#define GAMES_GAMEPAD_INPUT_TYPE_BUTTON EV_KEY
GType games_gamepad_input_type_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GAMES_GAMEPAD_INPUT_TYPE_H */
......@@ -4,18 +4,15 @@
#define GAMES_GAMEPAD_MAPPED_EVENT_H
#include <glib-object.h>
#include "gamepad-input-type.h"
#include "standard-gamepad-axis.h"
#include "standard-gamepad-button.h"
G_BEGIN_DECLS
#define GAMES_TYPE_GAMEPAD_MAPPED_EVENT (games_gamepad_mapped_event_get_type ())
typedef struct {
GamesGamepadInputType type;
GamesStandardGamepadAxis axis;
GamesStandardGamepadButton button;
guint16 type;
guint16 axis;
guint16 button;
} GamesGamepadMappedEvent;
GType games_gamepad_mapped_event_get_type (void) G_GNUC_CONST;
......
......@@ -3,13 +3,14 @@
#include "gamepad-mapping.h"
#include <glib/gi18n-lib.h>
#include <linux/input-event-codes.h>
#include <stdlib.h>
#include "gamepad-dpad.h"
#include "gamepad-mapping-error.h"
typedef struct {
GamesGamepadInputType type;
gint value;
guint16 type;
guint16 value;
} input_t;
struct _GamesGamepadMapping {
......@@ -118,34 +119,34 @@ parse_axis_value (GamesGamepadMapping *self,
g_array_index (self->axes, input_t, axis) = input;
}
static GamesGamepadInputType
static guint16
parse_input_type (const gchar *mapping_string)
{
const static struct {
GamesGamepadInputType enum_value;
guint16 enum_value;
const gchar *string_value;
} values[] = {
{ GAMES_GAMEPAD_INPUT_TYPE_AXIS, "leftx" },
{ GAMES_GAMEPAD_INPUT_TYPE_AXIS, "lefty" },
{ GAMES_GAMEPAD_INPUT_TYPE_AXIS, "rightx" },
{ GAMES_GAMEPAD_INPUT_TYPE_AXIS, "righty" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "a" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "b" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "back" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "dpdown" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "dpleft" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "dpright" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "dpup" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "guide" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "leftshoulder" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "leftstick" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "lefttrigger" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "rightshoulder" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "rightstick" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "righttrigger" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "start" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "x" },
{ GAMES_GAMEPAD_INPUT_TYPE_BUTTON, "y" },
{ EV_ABS, "leftx" },
{ EV_ABS, "lefty" },
{ EV_ABS, "rightx" },
{ EV_ABS, "righty" },
{ EV_KEY, "a" },
{ EV_KEY, "b" },
{ EV_KEY, "back" },
{ EV_KEY, "dpdown" },
{ EV_KEY, "dpleft" },
{ EV_KEY, "dpright" },
{ EV_KEY, "dpup" },
{ EV_KEY, "guide" },
{ EV_KEY, "leftshoulder" },
{ EV_KEY, "leftstick" },
{ EV_KEY, "lefttrigger" },
{ EV_KEY, "rightshoulder" },
{ EV_KEY, "rightstick" },
{ EV_KEY, "righttrigger" },
{ EV_KEY, "start" },
{ EV_KEY, "x" },
{ EV_KEY, "y" },
};
const gint length = sizeof (values) / sizeof (values[0]);
gint i;
......@@ -154,20 +155,20 @@ parse_input_type (const gchar *mapping_string)
if (g_strcmp0 (mapping_string, values[i].string_value) == 0)
return values[i].enum_value;
return GAMES_GAMEPAD_INPUT_TYPE_INVALID;
return EV_MAX;
}
static GamesStandardGamepadAxis
static guint16
parse_axis (const gchar *mapping_string)
{
const static struct {
GamesStandardGamepadAxis enum_value;
guint16 enum_value;
const gchar *string_value;
} values[] = {
{ GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X, "leftx" },
{ GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y, "lefty" },
{ GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X, "rightx" },
{ GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y, "righty" },
{ ABS_X, "leftx" },
{ ABS_Y, "lefty" },
{ ABS_RX, "rightx" },
{ ABS_RY, "righty" },
};
const gint length = sizeof (values) / sizeof (values[0]);
gint i;
......@@ -176,33 +177,33 @@ parse_axis (const gchar *mapping_string)
if (g_strcmp0 (mapping_string, values[i].string_value) == 0)
return values[i].enum_value;
return GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN;
return ABS_MAX;
}
static GamesStandardGamepadButton
static guint16
parse_button (const gchar *mapping_string)
{
const static struct {
GamesStandardGamepadButton enum_value;
guint16 enum_value;
const gchar *string_value;
} values[] = {
{ GAMES_STANDARD_GAMEPAD_BUTTON_A, "a" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_B, "b" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN, "dpdown" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT, "dpleft" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT, "dpright" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP, "dpup" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_HOME, "guide" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_SELECT, "back" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L, "leftshoulder" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R, "rightshoulder" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_START, "start" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L, "leftstick" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R, "rightstick" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L, "lefttrigger" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R, "righttrigger" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_X, "x" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_Y, "y" },
{ BTN_A, "a" },
{ BTN_B, "b" },
{ BTN_DPAD_DOWN, "dpdown" },
{ BTN_DPAD_LEFT, "dpleft" },
{ BTN_DPAD_RIGHT, "dpright" },
{ BTN_DPAD_UP, "dpup" },
{ BTN_MODE, "guide" },
{ BTN_SELECT, "back" },
{ BTN_TL, "leftshoulder" },
{ BTN_TR, "rightshoulder" },
{ BTN_START, "start" },
{ BTN_THUMBL, "leftstick" },
{ BTN_THUMBR, "rightstick" },
{ BTN_TL2, "lefttrigger" },
{ BTN_TR2, "righttrigger" },
{ BTN_Y, "x" },
{ BTN_X, "y" },
};
const gint length = sizeof (values) / sizeof (values[0]);
gint i;
......@@ -211,7 +212,7 @@ parse_button (const gchar *mapping_string)
if (g_strcmp0 (mapping_string, values[i].string_value) == 0)
return values[i].enum_value;
return GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN;
return KEY_MAX;
}
// This function doesn't take care of cleaning up the object's state before
......@@ -248,15 +249,15 @@ set_from_sdl_string (GamesGamepadMapping *self,
g_strfreev (splitted_mapping);
switch (input.type) {
case GAMES_GAMEPAD_INPUT_TYPE_BUTTON:
case EV_KEY:
input.value = (gint) parse_button (mapping_key);
break;
case GAMES_GAMEPAD_INPUT_TYPE_AXIS:
case EV_ABS:
input.value = (gint) parse_axis (mapping_key);
break;
case GAMES_GAMEPAD_INPUT_TYPE_INVALID:
case EV_MAX:
if (g_strcmp0 (mapping_key, "platform") != 0)
g_debug ("Invalid token: %s", mapping_key);
......@@ -359,12 +360,12 @@ games_gamepad_mapping_get_dpad_mapping (GamesGamepadMapping *self,
event->type = dpad->types[dpad_position];
switch (event->type) {
case GAMES_GAMEPAD_INPUT_TYPE_AXIS:
event->axis = (GamesStandardGamepadAxis) dpad->values[dpad_position];
case EV_ABS:
event->axis = dpad->values[dpad_position];
break;
case GAMES_GAMEPAD_INPUT_TYPE_BUTTON:
event->button = (GamesStandardGamepadButton) dpad->values[dpad_position];
case EV_KEY:
event->button = dpad->values[dpad_position];
break;
default:
......@@ -384,15 +385,15 @@ games_gamepad_mapping_get_axis_mapping (GamesGamepadMapping *self,
event->type = (axis_number < self->axes->len) ?
g_array_index (self->axes, input_t, axis_number).type :
GAMES_GAMEPAD_INPUT_TYPE_INVALID;
EV_MAX;
switch (event->type) {
case GAMES_GAMEPAD_INPUT_TYPE_AXIS:
event->axis = (GamesStandardGamepadAxis) g_array_index (self->axes, input_t, axis_number).value;
case EV_ABS:
event->axis = g_array_index (self->axes, input_t, axis_number).value;
break;
case GAMES_GAMEPAD_INPUT_TYPE_BUTTON:
event->button = (GamesStandardGamepadButton) g_array_index (self->axes, input_t, axis_number).value;
case EV_KEY:
event->button = g_array_index (self->axes, input_t, axis_number).value;
break;
default:
......@@ -412,15 +413,15 @@ games_gamepad_mapping_get_button_mapping (GamesGamepadMapping *self,
event->type = (button_number < self->buttons->len) ?
g_array_index (self->buttons, input_t, button_number).type :
GAMES_GAMEPAD_INPUT_TYPE_INVALID;
EV_MAX;
switch (event->type) {
case GAMES_GAMEPAD_INPUT_TYPE_AXIS:
event->axis = (GamesStandardGamepadAxis) g_array_index (self->buttons, input_t, button_number).value;
case EV_ABS:
event->axis = g_array_index (self->buttons, input_t, button_number).value;
break;
case GAMES_GAMEPAD_INPUT_TYPE_BUTTON:
event->button = (GamesStandardGamepadButton) g_array_index (self->buttons, input_t, button_number).value;
case EV_KEY:
event->button = g_array_index (self->buttons, input_t, button_number).value;
break;
default:
......
......@@ -2,6 +2,7 @@
#include "gamepad.h"
#include <linux/input-event-codes.h>
#include <stdlib.h>
#include "../event/event.h"
#include "gamepad-mapping.h"
......@@ -63,13 +64,13 @@ on_button_event (GamesRawGamepad *sender,
&event);
switch (event.type) {
case GAMES_GAMEPAD_INPUT_TYPE_AXIS:
case EV_ABS:
g_signal_emit (self,
signals[SIGNAL_AXIS_EVENT],
0, event.axis, value ? 1 : 0);
break;
case GAMES_GAMEPAD_INPUT_TYPE_BUTTON:
case EV_KEY:
g_signal_emit (self,
signals[SIGNAL_BUTTON_EVENT],
0, event.button, value);
......@@ -96,11 +97,11 @@ on_axis_event (GamesRawGamepad *sender,
games_gamepad_mapping_get_axis_mapping (self->mapping, games_event->index, &event);
switch (event.type) {
case GAMES_GAMEPAD_INPUT_TYPE_AXIS:
case EV_ABS:
g_signal_emit (self, signals[SIGNAL_AXIS_EVENT],
0, event.axis, games_event->value);
break;
case GAMES_GAMEPAD_INPUT_TYPE_BUTTON:
case EV_KEY:
g_signal_emit (self, signals[SIGNAL_BUTTON_EVENT],
0, event.button, games_event->value > 0.);
......@@ -129,16 +130,16 @@ on_hat_event (GamesRawGamepad *sender,
switch (games_event->axis) {
case 0:
g_signal_emit (self, signals[SIGNAL_BUTTON_EVENT],
0, GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT, games_event->value < 0);
0, BTN_DPAD_LEFT, games_event->value < 0);
g_signal_emit (self, signals[SIGNAL_BUTTON_EVENT],
0, GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT, games_event->value > 0);
0, BTN_DPAD_RIGHT, games_event->value > 0);
break;
case 1:
g_signal_emit (self, signals[SIGNAL_BUTTON_EVENT],
0, GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP, games_event->value < 0);
0, BTN_DPAD_UP, games_event->value < 0);
g_signal_emit (self, signals[SIGNAL_BUTTON_EVENT],
0, GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN, games_event->value > 0);
0, BTN_DPAD_DOWN, games_event->value > 0);
break;
default:
......@@ -152,12 +153,12 @@ on_hat_event (GamesRawGamepad *sender,
games_gamepad_mapping_get_dpad_mapping (self->mapping, games_event->index, games_event->axis, games_event->value, &event);
switch (event.type) {
case GAMES_GAMEPAD_INPUT_TYPE_AXIS:
case EV_ABS:
g_signal_emit (self, signals[SIGNAL_AXIS_EVENT],
0, event.axis, (gdouble) abs (games_event->value));
break;
case GAMES_GAMEPAD_INPUT_TYPE_BUTTON:
case EV_KEY:
g_signal_emit (self, signals[SIGNAL_BUTTON_EVENT],
0, event.button, (gboolean) abs (games_event->value));
......
// This file is part of GNOME Games. License: GPL-3.0+.
#include "standard-gamepad-axis.h"
GType
games_standard_gamepad_axis_get_type (void)
{
static volatile gsize type_id = 0;
static const GEnumValue values[] = {
{ GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN, "GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN", "unknown" },
{ GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X, "GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X", "left-x" },
{ GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y, "GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y", "left-y" },
{ GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X, "GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X", "right-x" },
{ GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y, "GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y", "right-y" },
{ 0, NULL, NULL },
};
if (g_once_init_enter (&type_id))
g_once_init_leave (&type_id,
g_enum_register_static ("GamesStandardGamepadAxis",
values));
return type_id;
}
// This file is part of GNOME Games. License: GPL-3.0+.
#ifndef GAMES_STANDARD_GAMEPAD_AXIS_H
#define GAMES_STANDARD_GAMEPAD_AXIS_H
#include <glib-object.h>
#include <linux/input-event-codes.h>
G_BEGIN_DECLS
#define GAMES_TYPE_STANDARD_GAMEPAD_AXIS (games_standard_gamepad_axis_get_type ())
/**
* GamesStandardGamepadAxis:
* @GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN: an unknown axis
* @GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X: the horizontal axis of the left stick
* @GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y: the vertical axis of the left stick
* @GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X: the horizontal axis of the right stick
* @GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y: the vertical axis of the right stick
*
* The axes of a standard gamepad.
*
* For horizontal axes, left is -1 and right is 1; for vertical axes,
* top is -1 and bottom is 1.
**/
typedef guint16 GamesStandardGamepadAxis;
#define GAMES_STANDARD_GAMEPAD_AXIS_UNKNOWN ABS_MAX
#define GAMES_STANDARD_GAMEPAD_AXIS_LEFT_X ABS_X
#define GAMES_STANDARD_GAMEPAD_AXIS_LEFT_Y ABS_Y
#define GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_X ABS_RX
#define GAMES_STANDARD_GAMEPAD_AXIS_RIGHT_Y ABS_RY
GType games_standard_gamepad_axis_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GAMES_STANDARD_GAMEPAD_AXIS_H */
// This file is part of GNOME Games. License: GPL-3.0+.
#include "standard-gamepad-button.h"
GType
games_standard_gamepad_button_get_type (void)
{
static volatile gsize type_id = 0;
static const GEnumValue values[] = {
{ GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN, "GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN", "unknown" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_A, "GAMES_STANDARD_GAMEPAD_BUTTON_A", "a" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_B, "GAMES_STANDARD_GAMEPAD_BUTTON_B", "b" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_X, "GAMES_STANDARD_GAMEPAD_BUTTON_X", "x" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_Y, "GAMES_STANDARD_GAMEPAD_BUTTON_Y", "y" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L, "GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L", "shoulder-l" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R, "GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R", "shoulder-r" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L, "GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L", "trigger-l" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R, "GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R", "trigger-r" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_SELECT, "GAMES_STANDARD_GAMEPAD_BUTTON_SELECT", "select" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_START, "GAMES_STANDARD_GAMEPAD_BUTTON_START", "start" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L, "GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L", "stick-l" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R, "GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R", "stick-r" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP", "dpad-up" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN", "dpad-down" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT", "dpad-left" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT, "GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT", "dpad-right" },
{ GAMES_STANDARD_GAMEPAD_BUTTON_HOME, "GAMES_STANDARD_GAMEPAD_BUTTON_HOME", "home" },
{ 0, NULL, NULL },
};
if (g_once_init_enter (&type_id))
g_once_init_leave (&type_id,
g_enum_register_static ("GamesStandardGamepadButton",
values));
return type_id;
}
// This file is part of GNOME Games. License: GPL-3.0+.
#ifndef GAMES_STANDARD_GAMEPAD_BUTTON_H
#define GAMES_STANDARD_GAMEPAD_BUTTON_H
#include <glib-object.h>
#include <linux/input-event-codes.h>
G_BEGIN_DECLS
#define GAMES_TYPE_STANDARD_GAMEPAD_BUTTON (games_standard_gamepad_button_get_type ())
/**
* GamesStandardGamepadButton:
* @GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN: an unknown button
* @GAMES_STANDARD_GAMEPAD_BUTTON_A: the A (south) button
* @GAMES_STANDARD_GAMEPAD_BUTTON_B: the B (east) button
* @GAMES_STANDARD_GAMEPAD_BUTTON_X: the X (west) button
* @GAMES_STANDARD_GAMEPAD_BUTTON_Y: the Y (north) button
* @GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L: the left shoulder button
* @GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R: the right shoulder button
* @GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L: the left trigger
* @GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R: the right trigger
* @GAMES_STANDARD_GAMEPAD_BUTTON_SELECT: the Select button
* @GAMES_STANDARD_GAMEPAD_BUTTON_START: the Start button
* @GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L: the left stick's button
* @GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R: the right stick's button
* @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP: the up button of the d-pad
* @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN: the down button of the d-pad
* @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT: the left button of the d-pad
* @GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT: the right button of the d-pad
* @GAMES_STANDARD_GAMEPAD_BUTTON_HOME: the Home button
*
* The buttons of a standard gamepad.
**/
typedef guint16 GamesStandardGamepadButton;
#define GAMES_STANDARD_GAMEPAD_BUTTON_UNKNOWN KEY_MAX
#define GAMES_STANDARD_GAMEPAD_BUTTON_A BTN_A
#define GAMES_STANDARD_GAMEPAD_BUTTON_B BTN_B
#define GAMES_STANDARD_GAMEPAD_BUTTON_X BTN_Y
#define GAMES_STANDARD_GAMEPAD_BUTTON_Y BTN_X
#define GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_L BTN_TL
#define GAMES_STANDARD_GAMEPAD_BUTTON_SHOULDER_R BTN_TR
#define GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_L BTN_TL2
#define GAMES_STANDARD_GAMEPAD_BUTTON_TRIGGER_R BTN_TR2
#define GAMES_STANDARD_GAMEPAD_BUTTON_SELECT BTN_SELECT
#define GAMES_STANDARD_GAMEPAD_BUTTON_START BTN_START
#define GAMES_STANDARD_GAMEPAD_BUTTON_STICK_L BTN_THUMBL
#define GAMES_STANDARD_GAMEPAD_BUTTON_STICK_R BTN_THUMBR
#define GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_UP BTN_DPAD_UP
#define GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_DOWN BTN_DPAD_DOWN
#define GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_LEFT BTN_DPAD_LEFT
#define GAMES_STANDARD_GAMEPAD_BUTTON_DPAD_RIGHT BTN_DPAD_RIGHT
#define GAMES_STANDARD_GAMEPAD_BUTTON_HOME BTN_MODE
GType games_standard_gamepad_button_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* GAMES_STANDARD_GAMEPAD_BUTTON_H */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment