[gnome-games/wip/exalm/dpad: 44/44] gamepad-mapper: Bind half axes for dpad



commit d979b9d4f8ed66f58c2fb3f9ae48e63d3effcfa0
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Fri Oct 12 02:07:59 2018 +0500

    gamepad-mapper: Bind half axes for dpad

 src/ui/gamepad-mapper.vala | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
---
diff --git a/src/ui/gamepad-mapper.vala b/src/ui/gamepad-mapper.vala
index 2af64125..280bb7a3 100644
--- a/src/ui/gamepad-mapper.vala
+++ b/src/ui/gamepad-mapper.vala
@@ -76,8 +76,16 @@ private class Games.GamepadMapper : Gtk.Bin {
                        if (-0.8 < value < 0.8)
                                return;
 
+                       int range = 0;
+
+                       if (input.code == EventCode.BTN_DPAD_UP ||
+                           input.code == EventCode.BTN_DPAD_DOWN ||
+                           input.code == EventCode.BTN_DPAD_LEFT ||
+                           input.code == EventCode.BTN_DPAD_RIGHT)
+                               range = value > 0 ? 1 : -1;
+
                        if (!mapping_builder.set_axis_mapping ((uint8) event.get_hardware_index (),
-                                                              0, input))
+                                                              range, input))
                                return;
 
                        break;


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