|
|
@ -26,7 +26,7 @@ public class Controller implements AsyncProcessor {
|
|
|
|
|
|
|
|
|
|
|
|
private Thread thread;
|
|
|
|
private Thread thread;
|
|
|
|
|
|
|
|
|
|
|
|
private final UhidManager uhidManager;
|
|
|
|
private UhidManager uhidManager;
|
|
|
|
|
|
|
|
|
|
|
|
private final Device device;
|
|
|
|
private final Device device;
|
|
|
|
private final ControlChannel controlChannel;
|
|
|
|
private final ControlChannel controlChannel;
|
|
|
@ -52,7 +52,13 @@ public class Controller implements AsyncProcessor {
|
|
|
|
this.powerOn = powerOn;
|
|
|
|
this.powerOn = powerOn;
|
|
|
|
initPointers();
|
|
|
|
initPointers();
|
|
|
|
sender = new DeviceMessageSender(controlChannel);
|
|
|
|
sender = new DeviceMessageSender(controlChannel);
|
|
|
|
uhidManager = new UhidManager(sender);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private UhidManager getUhidManager() {
|
|
|
|
|
|
|
|
if (uhidManager == null) {
|
|
|
|
|
|
|
|
uhidManager = new UhidManager(sender);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return uhidManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void initPointers() {
|
|
|
|
private void initPointers() {
|
|
|
@ -99,7 +105,9 @@ public class Controller implements AsyncProcessor {
|
|
|
|
Ln.e("Controller error", e);
|
|
|
|
Ln.e("Controller error", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|
Ln.d("Controller stopped");
|
|
|
|
Ln.d("Controller stopped");
|
|
|
|
uhidManager.closeAll();
|
|
|
|
if (uhidManager != null) {
|
|
|
|
|
|
|
|
uhidManager.closeAll();
|
|
|
|
|
|
|
|
}
|
|
|
|
listener.onTerminated(true);
|
|
|
|
listener.onTerminated(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, "control-recv");
|
|
|
|
}, "control-recv");
|
|
|
@ -195,10 +203,10 @@ public class Controller implements AsyncProcessor {
|
|
|
|
device.rotateDevice();
|
|
|
|
device.rotateDevice();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ControlMessage.TYPE_UHID_CREATE:
|
|
|
|
case ControlMessage.TYPE_UHID_CREATE:
|
|
|
|
uhidManager.open(msg.getId(), msg.getData());
|
|
|
|
getUhidManager().open(msg.getId(), msg.getData());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case ControlMessage.TYPE_UHID_INPUT:
|
|
|
|
case ControlMessage.TYPE_UHID_INPUT:
|
|
|
|
uhidManager.writeInput(msg.getId(), msg.getData());
|
|
|
|
getUhidManager().writeInput(msg.getId(), msg.getData());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
// do nothing
|
|
|
|
// do nothing
|
|
|
|