[gnome-games] retro: Add 'present_analog_sticks' prop to RetroGamepad



commit 2ad960f1e494c009df240fece755252113d12764
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Aug 30 15:00:22 2016 +0200

    retro: Add 'present_analog_sticks' prop to RetroGamepad
    
    This will be used in the next commits to present gamepads as classic
    gamepads or as gamepads with analog sticks.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770192

 src/retro/retro-gamepad.vala       |   10 +++++++---
 src/retro/retro-input-manager.vala |    4 ++--
 2 files changed, 9 insertions(+), 5 deletions(-)
---
diff --git a/src/retro/retro-gamepad.vala b/src/retro/retro-gamepad.vala
index 7341958..d730228 100644
--- a/src/retro/retro-gamepad.vala
+++ b/src/retro/retro-gamepad.vala
@@ -2,12 +2,13 @@
 
 private class Games.RetroGamepad: Object, Retro.InputDevice {
        public Gamepad gamepad { get; construct; }
+       public bool present_analog_sticks { get; construct; }
 
        private bool[] buttons;
        private int16[] axes;
 
-       public RetroGamepad (Gamepad gamepad) {
-               Object (gamepad: gamepad);
+       public RetroGamepad (Gamepad gamepad, bool present_analog_sticks) {
+               Object (gamepad: gamepad, present_analog_sticks: present_analog_sticks);
        }
 
        construct {
@@ -32,7 +33,10 @@ private class Games.RetroGamepad: Object, Retro.InputDevice {
        }
 
        public Retro.DeviceType get_device_type () {
-               return Retro.DeviceType.ANALOG;
+               if (present_analog_sticks)
+                       return Retro.DeviceType.ANALOG;
+
+               return Retro.DeviceType.JOYPAD;
        }
 
        public uint64 get_device_capabilities () {
diff --git a/src/retro/retro-input-manager.vala b/src/retro/retro-input-manager.vala
index 0829519..c1d9215 100644
--- a/src/retro/retro-input-manager.vala
+++ b/src/retro/retro-input-manager.vala
@@ -17,7 +17,7 @@ private class Games.RetroInputManager : RetroGtk.InputDeviceManager, Retro.Rumbl
                        var port = is_port_plugged.length;
                        is_port_plugged += true;
                        gamepads += gamepad;
-                       set_controller_device (port, new RetroGamepad (gamepad));
+                       set_controller_device (port, new RetroGamepad (gamepad, true));
                        gamepad.unplugged.connect (() => handle_gamepad_unplugged (port));
                });
 
@@ -32,7 +32,7 @@ private class Games.RetroInputManager : RetroGtk.InputDeviceManager, Retro.Rumbl
                // Plug this gamepad to the port where the keyboard was plugged as a last resort
                var port = keyboard_port;
                gamepad.unplugged.connect (() => handle_gamepad_unplugged (port));
-               set_controller_device (keyboard_port, new RetroGamepad (gamepad));
+               set_controller_device (keyboard_port, new RetroGamepad (gamepad, true));
                gamepads[port] = gamepad;
 
                // Assign keyboard to another unplugged port if exists and return


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