Sorry I have not the answer but I have the same problem .
In my case the problem only occurs:
-With a Xbox One (Non Official) gamepad.
-In Unity 2022.2.10
-With Input System 1.5 and 1.5.1
Are you in the same case?
Do you have the problem with the same type of device?
Below some info about the tests I have made:
I tested with 3 gamepads: Xbox one (non Official), Xbox 360 and PS3:
Unity 2022.2.10 | Input System 1.5 1.5.1 (works except for Xbox One gamepad)
Unity 2022.1.0 | Input System 1.3 (works with all my gamepads)
Unity 2021.3.15 | Input System 1.4.4 (works with all my gamepads)
Expected result:
When a device is disconnected the device should be:
-Removed from the Devices list (spot 1)
-Added to the Disconnected list (spot 2)
Result with the Xbox One device in Unity 2022.2.10
With a script similar to yours: There is no message sent when the Xbox One device is disconnected.
In the Input Debug window the device stays in the Devices list and it never moved to the Disconnected list.
I find a wait to receive the Disconnected callback in Unity 2022.2.10+
In the Project Settings set Active Input Handling to Input System Package (New)
(Project Settings → Player → Configuration → Active input Handling → Input System Package (New)).
Pros: You receive the callback.
Cons: You can’t use Old and New input system at the same time.
This help’s me for determine witch device is disconnected or reconnected.
I put this code at awake method for registration, an it’s execute when device is changed.
I must to create my own List os devices, because unity doesn’t update at the moment. I know that this isn’t the best way, but i hope that i can help a little bit with this.
InputSystem.onDeviceChange +=
(device, change) =>
{
switch (change)
{
case InputDeviceChange.Added:
myDeviceList.Add(device);
break;
case InputDeviceChange.Removed:
myDeviceList.Remove(device);
break;
}
};