From af3761ab3e43603dc5e3ebf08e5845b6f38e6e5c Mon Sep 17 00:00:00 2001 From: shukenmg <18000205+shukenmg@users.noreply.github.com> Date: Mon, 2 Nov 2020 22:55:23 +0800 Subject: [PATCH] Adds an option to switch between controller calibrated joystick and a predetermined value (#527) * Fixes an issue some users where having when they enabled Non Original Controller #524 * Update Joycon.cs Overwite deadzone 2 * Using enum to switch between Co-authored-by: Shuken Co-authored-by: David Khachaturov --- BetterJoyForCemu/App.config | 10 ++++++++-- BetterJoyForCemu/Joycon.cs | 7 ++++--- BetterJoyForCemu/MainForm.cs | 30 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/BetterJoyForCemu/App.config b/BetterJoyForCemu/App.config index b3dad1f..aa0ad43 100644 --- a/BetterJoyForCemu/App.config +++ b/BetterJoyForCemu/App.config @@ -72,8 +72,14 @@ - - + + + + + + + + diff --git a/BetterJoyForCemu/Joycon.cs b/BetterJoyForCemu/Joycon.cs index 3af46b9..15269ae 100644 --- a/BetterJoyForCemu/Joycon.cs +++ b/BetterJoyForCemu/Joycon.cs @@ -834,14 +834,15 @@ namespace BetterJoyForCemu { stick_precal[0] = (UInt16)(stick_raw[0] | ((stick_raw[1] & 0xf) << 8)); stick_precal[1] = (UInt16)((stick_raw[1] >> 4) | (stick_raw[2] << 4)); - ushort[] cal = form.nonOriginal ? new ushort[6] { 2048, 2048, 2048, 2048, 2048, 2048 } : stick_cal; - ushort dz = form.nonOriginal ? (ushort)200 : deadzone; + ushort[] cal = form.useControllerStickCalibration ? stick_cal : new ushort[6] { 2048, 2048, 2048, 2048, 2048, 2048 }; + ushort dz = form.useControllerStickCalibration ? deadzone : (ushort)200; stick = CenterSticks(stick_precal, cal, dz); if (isPro) { stick2_precal[0] = (UInt16)(stick2_raw[0] | ((stick2_raw[1] & 0xf) << 8)); stick2_precal[1] = (UInt16)((stick2_raw[1] >> 4) | (stick2_raw[2] << 4)); - stick2 = CenterSticks(stick2_precal, form.nonOriginal ? cal : stick2_cal, deadzone2); + ushort dz2 = form.useControllerStickCalibration ? deadzone2 : (ushort)200; + stick2 = CenterSticks(stick2_precal, form.useControllerStickCalibration ? stick2_cal : cal, dz2); } // Read other Joycon's sticks diff --git a/BetterJoyForCemu/MainForm.cs b/BetterJoyForCemu/MainForm.cs index 5102287..70e9216 100644 --- a/BetterJoyForCemu/MainForm.cs +++ b/BetterJoyForCemu/MainForm.cs @@ -15,6 +15,7 @@ using System.Xml.Linq; namespace BetterJoyForCemu { public partial class MainForm : Form { + public bool useControllerStickCalibration; public bool nonOriginal = Boolean.Parse(ConfigurationManager.AppSettings["NonOriginalController"]); public bool allowCalibration = Boolean.Parse(ConfigurationManager.AppSettings["AllowCalibration"]); public List