From 02253ce37b86cfe808608827fded9fbd7b80df4e Mon Sep 17 00:00:00 2001 From: vertigra Date: Sun, 1 Oct 2023 00:51:13 +1000 Subject: [PATCH] Fix issue #22 #30 part 5 #33 (In windows) --- Configs/buttons.binding.default.json | 19 +++++++++++++++++-- .../BindingButtonsService.cs | 12 ++++++++++-- .../ConfigButtons.cs | 4 ++-- .../JsonModel/GamepadActionBinding.cs | 3 +++ XpadControl.csproj | 3 +++ 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Configs/buttons.binding.default.json b/Configs/buttons.binding.default.json index 781a276..3c850a8 100644 --- a/Configs/buttons.binding.default.json +++ b/Configs/buttons.binding.default.json @@ -115,12 +115,27 @@ "axis": "left_stick_y" }, { - "action": "head_left_right", + "action": "none", "axis": "right_stick_x" }, { - "action": "neck_up_down", + "action": "none", "axis": "right_stick_y" } + ], + + /* possible sticks buttons values: + left_stick_button + right_stick_button + */ + "sticks_buttons": [ + { + "action": "head_left_right", + "button": "left_stick_button" + }, + { + "action": "neck_up_down", + "button": "right_stick_button" + } ] } \ No newline at end of file diff --git a/XpadControl.Common.Services/BindingButtonsService/BindingButtonsService.cs b/XpadControl.Common.Services/BindingButtonsService/BindingButtonsService.cs index 894f1a1..a113e34 100644 --- a/XpadControl.Common.Services/BindingButtonsService/BindingButtonsService.cs +++ b/XpadControl.Common.Services/BindingButtonsService/BindingButtonsService.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Xml; using XpadControl.Interfaces; using XpadControl.Interfaces.BindingButtonsService.Dependencies; using XpadControl.Interfaces.BindingButtonsService.Dependencies.EventArgs; @@ -7,6 +8,7 @@ using XpadControl.Interfaces.GamepadService.Dependencies.EventArgs; using XpadControl.Interfaces.GamepadService.Dependencies.EventArgs.PropertyChangedArgs; + namespace XpadControl.Common.Services.BindingButtonsService { public class BindingButtonsService : IBindingButtonsService @@ -19,9 +21,15 @@ public class BindingButtonsService : IBindingButtonsService public BindingButtonsService(ILoggerService loggerService, IGamepadService gamepadService, string jsonConfigPath) { - var gamepadActionBinding = jsonConfigPath.ToGamepadAction(); + GamepadActionBinding gamepadActionBinding = jsonConfigPath.ToGamepadAction(); + + List buttonBindings = gamepadActionBinding.ButtonsAction; + buttonBindings.AddRange(gamepadActionBinding.SticksButtonsAction); + buttonBindings.AddRange(gamepadActionBinding.ButtonsBumper); + buttonBindings.AddRange(gamepadActionBinding.ButtonsDpad); + buttonBindings.AddRange(gamepadActionBinding.ButtonsOption); - mButtonBindings = gamepadActionBinding.ButtonsAction; + mButtonBindings = buttonBindings; mSticksActions = gamepadActionBinding.SticksAction; mTriggerAction = gamepadActionBinding.TriggerAction; diff --git a/XpadControl.Interfaces/BindingButtonsService.Dependencies/ConfigButtons.cs b/XpadControl.Interfaces/BindingButtonsService.Dependencies/ConfigButtons.cs index ddf91f3..05adac5 100644 --- a/XpadControl.Interfaces/BindingButtonsService.Dependencies/ConfigButtons.cs +++ b/XpadControl.Interfaces/BindingButtonsService.Dependencies/ConfigButtons.cs @@ -30,10 +30,10 @@ public enum ConfigButtons [EnumMember(Value = "button_back")] Back = 0x20, - // The LS (Left Stick) button. + [EnumMember(Value = "left_stick_button")] LS = 0x40, - // The RS (Right Stick) button. + [EnumMember(Value = "right_stick_button")] RS = 0x80, [EnumMember(Value = "left_bamper")] diff --git a/XpadControl.Interfaces/BindingButtonsService.Dependencies/JsonModel/GamepadActionBinding.cs b/XpadControl.Interfaces/BindingButtonsService.Dependencies/JsonModel/GamepadActionBinding.cs index 50141a0..8ec5a70 100644 --- a/XpadControl.Interfaces/BindingButtonsService.Dependencies/JsonModel/GamepadActionBinding.cs +++ b/XpadControl.Interfaces/BindingButtonsService.Dependencies/JsonModel/GamepadActionBinding.cs @@ -20,6 +20,9 @@ public class GamepadActionBinding [JsonPropertyName("sticks")] public List SticksAction { get; set; } + [JsonPropertyName("sticks_buttons")] + public List SticksButtonsAction { get; set; } + [JsonPropertyName("triggers")] public List TriggerAction { get; set; } } diff --git a/XpadControl.csproj b/XpadControl.csproj index 1154a94..f4e2aab 100644 --- a/XpadControl.csproj +++ b/XpadControl.csproj @@ -12,6 +12,7 @@ + @@ -22,6 +23,7 @@ + @@ -32,6 +34,7 @@ +