From 5857a44f65235440dbc968b19135d5a05e9718ae Mon Sep 17 00:00:00 2001 From: David Khachaturov Date: Sun, 17 May 2020 17:44:12 +0100 Subject: [PATCH] - Fixed joycons not being properly detached with the new lack of input lag --- BetterJoyForCemu/App.config | 1 - BetterJoyForCemu/Joycon.cs | 7 ++++--- BetterJoyForCemu/Program.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BetterJoyForCemu/App.config b/BetterJoyForCemu/App.config index 6ae34cc..dd1887a 100644 --- a/BetterJoyForCemu/App.config +++ b/BetterJoyForCemu/App.config @@ -46,7 +46,6 @@ - diff --git a/BetterJoyForCemu/Joycon.cs b/BetterJoyForCemu/Joycon.cs index 2ed44b4..e1f8e1f 100644 --- a/BetterJoyForCemu/Joycon.cs +++ b/BetterJoyForCemu/Joycon.cs @@ -469,7 +469,7 @@ namespace BetterJoyForCemu { filterweight = a; } - public void Detach() { + public void Detach(bool close = false) { stop_polling = true; if (xin != null) { @@ -494,7 +494,7 @@ namespace BetterJoyForCemu { HIDapi.hid_write(handle, a, new UIntPtr(2)); } } - if (state > state_.DROPPED) { + if (close || state > state_.DROPPED) { HIDapi.hid_close(handle); } state = state_.NOT_ATTACHED; @@ -646,6 +646,7 @@ namespace BetterJoyForCemu { if ((timestamp - buttons_down_timestamp[powerOffButton]) / 10000 > 2000.0) { if (other != null) other.PowerOff(); + PowerOff(); return; } @@ -728,7 +729,7 @@ namespace BetterJoyForCemu { int a = ReceiveRaw(); - if (a > 0) { + if (a > 0 && state > state_.DROPPED) { state = state_.IMU_DATA_OK; attempts = 0; diff --git a/BetterJoyForCemu/Program.cs b/BetterJoyForCemu/Program.cs index 85a3e7f..7380de5 100644 --- a/BetterJoyForCemu/Program.cs +++ b/BetterJoyForCemu/Program.cs @@ -70,7 +70,7 @@ namespace BetterJoyForCemu { if (v.other != null) v.other.other = null; // The other of the other is the joycon itself - v.Detach(); rem.Add(v); + v.Detach(true); rem.Add(v); foreach (Button b in form.con) { if (b.Enabled & b.Tag == v) { @@ -83,7 +83,7 @@ namespace BetterJoyForCemu { } } - form.AppendTextBox("Removed dropped controller to list. Can be reconnected.\r\n"); + form.AppendTextBox("Removed dropped controller. Can be reconnected.\r\n"); } }