[gnome-games] retro-gamepad: Adapt to changes in retro-gtk



commit e8e03bb860756f32b109239df8f83ae52b89d203
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Oct 29 23:46:16 2017 +0100

    retro-gamepad: Adapt to changes in retro-gtk

 src/retro/retro-gamepad.vala |   21 +++++++++++++++------
 1 files changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/src/retro/retro-gamepad.vala b/src/retro/retro-gamepad.vala
index 3055f62..402e10b 100644
--- a/src/retro/retro-gamepad.vala
+++ b/src/retro/retro-gamepad.vala
@@ -22,12 +22,21 @@ private class Games.RetroGamepad: Object, Retro.Controller {
 
        public void poll () {}
 
-       public int16 get_input_state (Retro.ControllerType controller_type, uint index, uint id) {
-               switch (controller_type) {
+       public int16 get_input_state (Retro.Input input) {
+               switch (input.get_controller_type ()) {
                case Retro.ControllerType.JOYPAD:
-                       return get_button_pressed ((Retro.JoypadId) id) ? int16.MAX : 0;
+                       Retro.JoypadId id;
+                       if (!input.get_joypad (out id))
+                               return 0;
+
+                       return get_button_pressed (id) ? int16.MAX : 0;
                case Retro.ControllerType.ANALOG:
-                       return get_analog_value ((Retro.AnalogIndex) index, (Retro.AnalogId) id);
+                       Retro.AnalogId id;
+                       Retro.AnalogIndex index;
+                       if (!input.get_analog (out id, out index))
+                               return 0;
+
+                       return get_analog_value (index, id);
                default:
                        return 0;
                }
@@ -44,7 +53,7 @@ private class Games.RetroGamepad: Object, Retro.Controller {
                return (1 << Retro.ControllerType.JOYPAD) | (1 << Retro.ControllerType.ANALOG);
        }
 
-       public bool get_button_pressed (Retro.JoypadId button) {
+       private bool get_button_pressed (Retro.JoypadId button) {
                switch (button) {
                case Retro.JoypadId.B:
                        return buttons[EventCode.BTN_A];
@@ -83,7 +92,7 @@ private class Games.RetroGamepad: Object, Retro.Controller {
                }
        }
 
-       public int16 get_analog_value (Retro.AnalogIndex index, Retro.AnalogId id) {
+       private int16 get_analog_value (Retro.AnalogIndex index, Retro.AnalogId id) {
                switch (index) {
                case Retro.AnalogIndex.LEFT:
                        switch (id) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]