From 6a68c7f52159909ee70d844548bd278cdc0ce28e Mon Sep 17 00:00:00 2001 From: alyosha-tas Date: Mon, 30 Dec 2019 17:28:48 -0500 Subject: [PATCH] Controller: fix physical controller input, fixes #1166 --- BizHawk.Client.Common/ControllerBinding.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.Common/ControllerBinding.cs b/BizHawk.Client.Common/ControllerBinding.cs index 88952e7559..fc322b4a66 100644 --- a/BizHawk.Client.Common/ControllerBinding.cs +++ b/BizHawk.Client.Common/ControllerBinding.cs @@ -84,10 +84,18 @@ namespace BizHawk.Client.Common absInput /= 10000.0f - zeroPoint; input = absInput * Math.Sign(input); } - // zero 09-mar-2015 - not sure if adding + 1 here is correct.. but... maybe? - var output = (((input * multiplier) + 10000.0f) * (range.Max - range.Min + 1) / 20000.0f) + range.Min; + float output = 0; + + if (range.Max < range.Min) + { + output = (((input * multiplier) + 10000.0f) * (range.Min - range.Max + 1) / 20000.0f) + range.Max; + } + else + { + output = (((input * multiplier) + 10000.0f) * (range.Max - range.Min + 1) / 20000.0f) + range.Min; + } // zero 09-mar-2015 - at this point, we should only have integers, since that's all 100% of consoles ever see // if this becomes a problem we can add flags to the range and update GUIs to be able to display floats