Skip to content

Commit

Permalink
- Fixed joycons not being properly detached with the new lack of inp…
Browse files Browse the repository at this point in the history
…ut lag
  • Loading branch information
Davidobot committed May 17, 2020
1 parent 7b722dd commit 5857a44
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 0 additions & 1 deletion BetterJoyForCemu/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<!-- Default: false -->
<add key="UseHIDG" value="true" />


<!-- Determines whether or not to enable (experimental - currently default controller to pro) support for 3rd-party controllers. Adds a "Calibrate" button. -->
<!-- When "true", click "Calibrate" button once to get gyro calibrate data. -->
<!-- When enabled, can only calibrate one controller at a time. -->
Expand Down
7 changes: 4 additions & 3 deletions BetterJoyForCemu/Joycon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ public void SetFilterCoeff(float a) {
filterweight = a;
}

public void Detach() {
public void Detach(bool close = false) {
stop_polling = true;

if (xin != null) {
Expand All @@ -494,7 +494,7 @@ public void Detach() {
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;
Expand Down Expand Up @@ -646,6 +646,7 @@ private void DoThingsWithButtons() {
if ((timestamp - buttons_down_timestamp[powerOffButton]) / 10000 > 2000.0) {
if (other != null)
other.PowerOff();

PowerOff();
return;
}
Expand Down Expand Up @@ -728,7 +729,7 @@ private void Poll() {

int a = ReceiveRaw();

if (a > 0) {
if (a > 0 && state > state_.DROPPED) {
state = state_.IMU_DATA_OK;
attempts = 0;

Expand Down
4 changes: 2 additions & 2 deletions BetterJoyForCemu/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void CleanUp() { // removes dropped controllers from list
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) {
Expand All @@ -83,7 +83,7 @@ void CleanUp() { // removes dropped controllers from list
}
}

form.AppendTextBox("Removed dropped controller to list. Can be reconnected.\r\n");
form.AppendTextBox("Removed dropped controller. Can be reconnected.\r\n");
}
}

Expand Down

0 comments on commit 5857a44

Please sign in to comment.