[gnome-games/wip/abhinavsingh/gamepad-config: 12/21] gamepad: Add get_standard_inputs() to GamepadInput
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/abhinavsingh/gamepad-config: 12/21] gamepad: Add get_standard_inputs() to GamepadInput
- Date: Fri, 2 Jun 2017 19:22:28 +0000 (UTC)
commit a9c66891380a1a133be043de46d4e267a3907060
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 for other classes.
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]