[retro-gtk] input: Remove GamepadButtonType
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] input: Remove GamepadButtonType
- Date: Sun, 30 Jul 2017 13:27:26 +0000 (UTC)
commit 6d075a4b34589408b528c5995db8357dd57a8e54
Author: Adrien Plazas <kekun plazas laposte net>
Date: Tue Jul 25 12:10:30 2017 +0200
input: Remove GamepadButtonType
This type is useless as it is a copy of JoypadId with an extra useless
value.
https://bugzilla.gnome.org/show_bug.cgi?id=777489
retro-gtk/Makefile.am | 1 -
retro-gtk/input/device.vala | 3 +-
retro-gtk/input/gamepad-button-type.vala | 25 ------------------
retro-gtk/input/gamepad-configuration.vala | 39 +++++++++++++--------------
retro-gtk/input/virtual-gamepad.vala | 4 +-
5 files changed, 23 insertions(+), 49 deletions(-)
---
diff --git a/retro-gtk/Makefile.am b/retro-gtk/Makefile.am
index 7315fc7..344b4f9 100644
--- a/retro-gtk/Makefile.am
+++ b/retro-gtk/Makefile.am
@@ -31,7 +31,6 @@ libretro_gtk_la_SOURCES = \
\
input/controller.vala \
input/device.vala \
- input/gamepad-button-type.vala \
input/gamepad-configuration.vala \
input/input.vala \
input/input-device.vala \
diff --git a/retro-gtk/input/device.vala b/retro-gtk/input/device.vala
index af86eb2..ce8a5bf 100644
--- a/retro-gtk/input/device.vala
+++ b/retro-gtk/input/device.vala
@@ -53,7 +53,8 @@ public enum JoypadId {
L2,
R2,
L3,
- R3
+ R3,
+ COUNT,
}
/**
diff --git a/retro-gtk/input/gamepad-configuration.vala b/retro-gtk/input/gamepad-configuration.vala
index 6bef8d4..d7709c0 100644
--- a/retro-gtk/input/gamepad-configuration.vala
+++ b/retro-gtk/input/gamepad-configuration.vala
@@ -4,34 +4,33 @@ public class Retro.GamepadConfiguration : Object {
private uint16[] gamepad_keys;
construct {
- gamepad_keys = new uint16[17];
+ gamepad_keys = new uint16[JoypadId.COUNT];
}
public void set_to_default () {
- set_button_key (GamepadButtonType.ACTION_DOWN, 39); // QWERTY S
- set_button_key (GamepadButtonType.ACTION_LEFT, 38); // QWERTY A
- set_button_key (GamepadButtonType.SELECT, 22); // Backspace
- set_button_key (GamepadButtonType.START, 36); // Enter
- set_button_key (GamepadButtonType.DIRECTION_UP, 111); // Up arrow
- set_button_key (GamepadButtonType.DIRECTION_DOWN, 116); // Down arrow
- set_button_key (GamepadButtonType.DIRECTION_LEFT, 113); // Left arrow
- set_button_key (GamepadButtonType.DIRECTION_RIGHT, 114); // Right arrow
- set_button_key (GamepadButtonType.ACTION_RIGHT, 40); // QWERTY D
- set_button_key (GamepadButtonType.ACTION_UP, 25); // QWERTY W
- set_button_key (GamepadButtonType.SHOULDER_L, 24); // QWERTY Q
- set_button_key (GamepadButtonType.SHOULDER_R, 26); // QWERTY E
- set_button_key (GamepadButtonType.SHOULDER_L2, 52); // QWERTY Z
- set_button_key (GamepadButtonType.SHOULDER_R2, 54); // QWERTY C
- set_button_key (GamepadButtonType.STICK_L, 10); // QWERTY 1
- set_button_key (GamepadButtonType.STICK_R, 12); // QWERTY 3
- set_button_key (GamepadButtonType.HOME, 110); // Home
+ set_button_key (JoypadId.B, 39); // QWERTY S
+ set_button_key (JoypadId.Y, 38); // QWERTY A
+ set_button_key (JoypadId.SELECT, 22); // Backspace
+ set_button_key (JoypadId.START, 36); // Enter
+ set_button_key (JoypadId.UP, 111); // Up arrow
+ set_button_key (JoypadId.DOWN, 116); // Down arrow
+ set_button_key (JoypadId.LEFT, 113); // Left arrow
+ set_button_key (JoypadId.RIGHT, 114); // Right arrow
+ set_button_key (JoypadId.A, 40); // QWERTY D
+ set_button_key (JoypadId.X, 25); // QWERTY W
+ set_button_key (JoypadId.L, 24); // QWERTY Q
+ set_button_key (JoypadId.R, 26); // QWERTY E
+ set_button_key (JoypadId.L2, 52); // QWERTY Z
+ set_button_key (JoypadId.R2, 54); // QWERTY C
+ set_button_key (JoypadId.L3, 10); // QWERTY 1
+ set_button_key (JoypadId.R3, 12); // QWERTY 3
}
- public void set_button_key (GamepadButtonType button, uint16 key) {
+ public void set_button_key (JoypadId button, uint16 key) {
gamepad_keys[button] = key;
}
- public uint16 get_button_key (GamepadButtonType button) {
+ public uint16 get_button_key (JoypadId button) {
return gamepad_keys[button];
}
}
diff --git a/retro-gtk/input/virtual-gamepad.vala b/retro-gtk/input/virtual-gamepad.vala
index 77d7b79..37eefee 100644
--- a/retro-gtk/input/virtual-gamepad.vala
+++ b/retro-gtk/input/virtual-gamepad.vala
@@ -28,7 +28,7 @@ public class Retro.VirtualGamepad : Object, InputDevice {
public int16 get_input_state (DeviceType device, uint index, uint id) {
if ((DeviceType) device != DeviceType.JOYPAD) return 0;
- return get_button_pressed ((GamepadButtonType) id) ? int16.MAX : 0;
+ return get_button_pressed ((JoypadId) id) ? int16.MAX : 0;
}
public DeviceType get_device_type () {
@@ -39,7 +39,7 @@ public class Retro.VirtualGamepad : Object, InputDevice {
return 1 << DeviceType.JOYPAD;
}
- public bool get_button_pressed (GamepadButtonType button) {
+ public bool get_button_pressed (JoypadId button) {
return keyboard.get_key_state (configuration.get_button_key (button));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]