Skip to content

Commit

Permalink
Steam Deck: fix regressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Jun 23, 2023
1 parent b16e81a commit 990a89d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 4 additions & 3 deletions HandheldCompanion/Controllers/NeptuneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ public NeptuneController(PnPDetails details)
try
{
Controller = new neptune_hidapi.net.NeptuneController();
Controller.OnControllerInputReceived = input => Task.Run(() => OnControllerInputReceived(input));

Controller.Open();
isConnected = true;
isConnected = !string.IsNullOrEmpty(Controller.SerialNumber);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -332,7 +334,7 @@ public override void Plug()
TimerManager.Tick += UpdateInputs;
TimerManager.Tick += UpdateMovements;

Controller.OnControllerInputReceived = input => Task.Run(() => OnControllerInputReceived(input));
Controller.Open();

SetHDRumble(UseHDRumble);

Expand All @@ -354,7 +356,6 @@ public override void Unplug()
SetLizardMouse(true);

Controller.Close();
isConnected = false;
}
catch
{
Expand Down
4 changes: 2 additions & 2 deletions HandheldCompanion/Managers/ControllerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ private static void HidDeviceArrived(PnPDetails details, DeviceEventArgs obj)
Controllers[path] = controller;

// first controller logic
if (!controller.IsVirtual() && GetTargetController() is null)
if (!controller.IsVirtual() && GetTargetController() is null && DeviceManager.IsInitialized)
SetTargetController(controller.GetInstancePath());

// raise event
Expand Down Expand Up @@ -424,7 +424,7 @@ private static void XUsbDeviceArrived(PnPDetails details, DeviceEventArgs obj)
Controllers[path] = controller;

// first controller logic
if (!controller.IsVirtual() && GetTargetController() is null)
if (!controller.IsVirtual() && GetTargetController() is null && DeviceManager.IsInitialized)
SetTargetController(controller.GetInstancePath());

// raise event
Expand Down
1 change: 1 addition & 0 deletions neptune-hidapi.net/NeptuneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public void Close()
_hidDevice.EndRead();
_hidDevice.Dispose();
_active = false;
_configureTask.Dispose();
}
}
}

0 comments on commit 990a89d

Please sign in to comment.