[gnome-games/wip/aplazas/gamepad-config: 2/26] gamepad: Add get_standard_inputs() to GamepadInput
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/aplazas/gamepad-config: 2/26] gamepad: Add get_standard_inputs() to GamepadInput
- Date: Mon, 10 Jul 2017 11:37:19 +0000 (UTC)
commit 013f0d0523c7e3823a28c3d64107e1ad88895a81
Author: theawless <theawless gmail com>
Date: Sun May 28 05:50:02 2017 +0530
gamepad: Add get_standard_inputs() to GamepadInput
This will ease getting standard inputs in users of this class.
https://bugzilla.gnome.org/show_bug.cgi?id=780754
src/gamepad/gamepad-input.c | 37 +++++++++++++++++++++++++++++++++++++
src/gamepad/gamepad-input.h | 1 +
src/gamepad/gamepad-input.vapi | 1 +
3 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/gamepad/gamepad-input.c b/src/gamepad/gamepad-input.c
index 4cb8a6b..72c4e6b 100644
--- a/src/gamepad/gamepad-input.c
+++ b/src/gamepad/gamepad-input.c
@@ -3,6 +3,7 @@
#include "gamepad-input.h"
#include <string.h>
+#include "linux/input-event-codes.h"
GamesGamepadInput *
games_gamepad_input_dup (const GamesGamepadInput *self)
@@ -34,3 +35,39 @@ games_gamepad_input_get_type (void)
return type_id;
}
+
+GamesGamepadInput *
+games_gamepad_input_get_standard_inputs (int *length)
+{
+ GamesGamepadInput *inputs = NULL;
+ GamesGamepadInput values[] = {
+ { EV_KEY, BTN_A },
+ { EV_KEY, BTN_B },
+ { EV_KEY, BTN_X },
+ { EV_KEY, BTN_Y },
+ { EV_KEY, BTN_THUMBL },
+ { EV_KEY, BTN_THUMBR },
+ { EV_KEY, BTN_TL },
+ { EV_KEY, BTN_TR },
+ { EV_KEY, BTN_TL2 },
+ { EV_KEY, BTN_TR2 },
+ { EV_KEY, BTN_DPAD_UP },
+ { EV_KEY, BTN_DPAD_LEFT },
+ { EV_KEY, BTN_DPAD_DOWN },
+ { EV_KEY, BTN_DPAD_RIGHT },
+ { EV_KEY, BTN_SELECT },
+ { EV_KEY, BTN_MODE },
+ { EV_KEY, BTN_START },
+
+ { EV_ABS, ABS_X },
+ { EV_ABS, ABS_RX },
+ { EV_ABS, ABS_Y },
+ { EV_ABS, ABS_RY },
+ };
+
+ *length = sizeof (values) / sizeof (values[0]);
+ inputs = g_malloc_n (*length, sizeof (values[0]));
+ memcpy (inputs, values, *length * sizeof (values[0]));
+
+ return inputs;
+}
diff --git a/src/gamepad/gamepad-input.h b/src/gamepad/gamepad-input.h
index 7f6d9b8..83e18a7 100644
--- a/src/gamepad/gamepad-input.h
+++ b/src/gamepad/gamepad-input.h
@@ -17,6 +17,7 @@ typedef struct {
GType games_gamepad_input_get_type (void) G_GNUC_CONST;
GamesGamepadInput *games_gamepad_input_dup (const GamesGamepadInput *self);
void games_gamepad_input_free (GamesGamepadInput *self);
+GamesGamepadInput *games_gamepad_input_get_standard_inputs (int *length);
G_END_DECLS
diff --git a/src/gamepad/gamepad-input.vapi b/src/gamepad/gamepad-input.vapi
index 835e895..e78565a 100644
--- a/src/gamepad/gamepad-input.vapi
+++ b/src/gamepad/gamepad-input.vapi
@@ -4,4 +4,5 @@
private struct Games.GamepadInput {
uint16 type;
uint16 code;
+ public static GamepadInput[] get_standard_inputs ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]