mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-18 10:32:43 +00:00
Delay a bit before reporting USB devices to allow the old InputDevice to go away
This commit is contained in:
parent
26b992726c
commit
832e7197c5
@ -30,6 +30,18 @@ public abstract class AbstractXboxController extends AbstractController {
|
|||||||
private Thread createInputThread() {
|
private Thread createInputThread() {
|
||||||
return new Thread() {
|
return new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
try {
|
||||||
|
// Delay for a moment before reporting the new gamepad and
|
||||||
|
// accepting new input. This allows time for the old InputDevice
|
||||||
|
// to go away before we reclaim its spot. If the old device is still
|
||||||
|
// around when we call notifyDeviceAdded(), we won't be able to claim
|
||||||
|
// the controller number used by the original InputDevice.
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
|
||||||
|
// Report that we're added _before_ reporting input
|
||||||
|
notifyDeviceAdded();
|
||||||
|
|
||||||
while (!isInterrupted() && !stopped) {
|
while (!isInterrupted() && !stopped) {
|
||||||
byte[] buffer = new byte[64];
|
byte[] buffer = new byte[64];
|
||||||
|
|
||||||
@ -114,9 +126,6 @@ public abstract class AbstractXboxController extends AbstractController {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report that we're added _before_ starting the input thread
|
|
||||||
notifyDeviceAdded();
|
|
||||||
|
|
||||||
// Start listening for controller input
|
// Start listening for controller input
|
||||||
inputThread = createInputThread();
|
inputThread = createInputThread();
|
||||||
inputThread.start();
|
inputThread.start();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user