1
0
forked from Clones/Controlify

store current controller in config

This commit is contained in:
isXander
2023-02-17 02:02:42 +00:00
parent 7e53fac611
commit 23c048f401
5 changed files with 60 additions and 14 deletions

View File

@ -20,6 +20,7 @@ public class ControllerHIDService implements HidServicesListener {
private final HidServicesSpecification specification;
private final Queue<Consumer<HidDevice>> deviceQueue;
private Runnable onQueueEmpty = () -> {};
private boolean disabled = false;
@ -59,6 +60,10 @@ public class ControllerHIDService implements HidServicesListener {
if (deviceQueue.peek() != null) {
try {
deviceQueue.poll().accept(device);
if (deviceQueue.isEmpty()) {
onQueueEmpty.run();
}
} catch (Throwable e) {
Controlify.LOGGER.error("Failed to handle controller device attach event.", e);
}
@ -75,6 +80,10 @@ public class ControllerHIDService implements HidServicesListener {
return isGenericDesktopControlOrGameControl && isController;
}
public void setOnQueueEmptyEvent(Runnable runnable) {
this.onQueueEmpty = runnable;
}
public boolean isDisabled() {
return disabled;
}