From 9566b53154e758c6d5647dbd89a8db4b1d484486 Mon Sep 17 00:00:00 2001 From: Ian Clawson Date: Thu, 12 Aug 2021 20:53:57 -0600 Subject: [PATCH 1/4] add handling to GameControllerStateManager so that over-active x/y analog inputs don't compete with each other --- DeltaCore/Model/GameControllerStateManager.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DeltaCore/Model/GameControllerStateManager.swift b/DeltaCore/Model/GameControllerStateManager.swift index aea635d..c2390f5 100644 --- a/DeltaCore/Model/GameControllerStateManager.swift +++ b/DeltaCore/Model/GameControllerStateManager.swift @@ -60,6 +60,11 @@ extension GameControllerStateManager { precondition(input.type == .controller(self.gameController.inputType), "input.type must match self.gameController.inputType") + // Handle edge case where some physcial controllers' (like Xbox) analog sticks report both x/y inputs incredibly granularly, + // resulting in an inability to use the analog stick for only a single directional input at a time, such as in place of a d-pad. + // TODO: ideally this would be a user-configurable threshold, but DeltaCore doesn't currently support configurable settings. + guard !input.isContinuous || (input.isContinuous && value > 0.15) else { return } + // An input may be "activated" multiple times, such as by pressing different buttons that map to same input, or moving an analog stick. self.activatedInputs[AnyInput(input)] = value From 3bd3544b33089aac209e96f048277a650a0b1ce7 Mon Sep 17 00:00:00 2001 From: Ian Clawson Date: Sat, 25 Sep 2021 13:42:28 -0600 Subject: [PATCH 2/4] add clearer note around the deadzone fix --- DeltaCore/Model/GameControllerStateManager.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DeltaCore/Model/GameControllerStateManager.swift b/DeltaCore/Model/GameControllerStateManager.swift index c2390f5..616847b 100644 --- a/DeltaCore/Model/GameControllerStateManager.swift +++ b/DeltaCore/Model/GameControllerStateManager.swift @@ -60,9 +60,10 @@ extension GameControllerStateManager { precondition(input.type == .controller(self.gameController.inputType), "input.type must match self.gameController.inputType") - // Handle edge case where some physcial controllers' (like Xbox) analog sticks report both x/y inputs incredibly granularly, - // resulting in an inability to use the analog stick for only a single directional input at a time, such as in place of a d-pad. - // TODO: ideally this would be a user-configurable threshold, but DeltaCore doesn't currently support configurable settings. + // Some external controllers' analog sticks report both x/y axis values incredibly granularly, + // hindering the ability to use the analog stick for only a single x/y axis value at a time. + // Solution: apply a higher deadzone to the analog sticks (currently the only continuous inputs) + // TODO: this could be a user-configurable threshold, but DeltaCore doesn't yet support configurable settings guard !input.isContinuous || (input.isContinuous && value > 0.15) else { return } // An input may be "activated" multiple times, such as by pressing different buttons that map to same input, or moving an analog stick. From 09f5e9d28716297547e7b584fcbdca2abcccdfea Mon Sep 17 00:00:00 2001 From: Ian Clawson Date: Sat, 25 Sep 2021 13:46:07 -0600 Subject: [PATCH 3/4] simplify check logic --- DeltaCore/Model/GameControllerStateManager.swift | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/DeltaCore/Model/GameControllerStateManager.swift b/DeltaCore/Model/GameControllerStateManager.swift index 616847b..a357efa 100644 --- a/DeltaCore/Model/GameControllerStateManager.swift +++ b/DeltaCore/Model/GameControllerStateManager.swift @@ -60,11 +60,14 @@ extension GameControllerStateManager { precondition(input.type == .controller(self.gameController.inputType), "input.type must match self.gameController.inputType") - // Some external controllers' analog sticks report both x/y axis values incredibly granularly, - // hindering the ability to use the analog stick for only a single x/y axis value at a time. - // Solution: apply a higher deadzone to the analog sticks (currently the only continuous inputs) - // TODO: this could be a user-configurable threshold, but DeltaCore doesn't yet support configurable settings - guard !input.isContinuous || (input.isContinuous && value > 0.15) else { return } + if input.isContinuous + { + // Some external controllers' analog sticks report both x/y axis values incredibly granularly, + // hindering the ability to use the analog stick for only a single x/y axis value at a time. + // Solution: apply a higher deadzone to the analog sticks (currently the only continuous inputs) + // TODO: this could be a user-configurable threshold, but DeltaCore doesn't yet support configurable settings + guard value > 0.15 else { return } + } // An input may be "activated" multiple times, such as by pressing different buttons that map to same input, or moving an analog stick. self.activatedInputs[AnyInput(input)] = value From add0eaa9cc59b4fd06fa193dd056b3caf58f5bd4 Mon Sep 17 00:00:00 2001 From: Ian Clawson Date: Thu, 18 Nov 2021 22:09:04 -0700 Subject: [PATCH 4/4] restricts deadzone to only continuous MFi controller inputs --- DeltaCore/Model/GameControllerStateManager.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DeltaCore/Model/GameControllerStateManager.swift b/DeltaCore/Model/GameControllerStateManager.swift index a357efa..8fd2220 100644 --- a/DeltaCore/Model/GameControllerStateManager.swift +++ b/DeltaCore/Model/GameControllerStateManager.swift @@ -60,7 +60,7 @@ extension GameControllerStateManager { precondition(input.type == .controller(self.gameController.inputType), "input.type must match self.gameController.inputType") - if input.isContinuous + if input.type == .controller(.mfi) && input.isContinuous { // Some external controllers' analog sticks report both x/y axis values incredibly granularly, // hindering the ability to use the analog stick for only a single x/y axis value at a time.