Turn the XB360 controller LED on at init

This commit is contained in:
Cameron Gutman 2016-01-27 14:00:14 -05:00
parent 23c54f6813
commit ee01a8b5a0

View File

@ -70,7 +70,7 @@ public class Xbox360Controller extends AbstractXboxController {
@Override @Override
protected boolean handleRead(ByteBuffer buffer) { protected boolean handleRead(ByteBuffer buffer) {
// Skip first byte // Skip first byte
buffer.position(buffer.position()+1); buffer.position(buffer.position() + 1);
// DPAD // DPAD
byte b = buffer.get(); byte b = buffer.get();
@ -117,9 +117,24 @@ public class Xbox360Controller extends AbstractXboxController {
return true; return true;
} }
private boolean sendLedCommand(byte command) {
byte[] commandBuffer = {0x01, 0x03, command};
int res = connection.bulkTransfer(outEndpt, commandBuffer, commandBuffer.length, 3000);
if (res != commandBuffer.length) {
LimeLog.warning("LED set transfer failed: "+res);
return false;
}
return true;
}
@Override @Override
protected boolean doInit() { protected boolean doInit() {
// Xbox 360 wired controller requires no initialization // Turn the LED on corresponding to our device ID
sendLedCommand((byte)(2 + (getControllerId() % 4)));
// No need to fail init if the LED command fails
return true; return true;
} }