mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-25 05:53:05 +00:00
Fixed crash if we get a short read from the Xbox One controller
This commit is contained in:
parent
57b507ad50
commit
bdac2df4b9
@ -66,8 +66,8 @@ public class Xbox360Controller extends AbstractXboxController {
|
||||
|
||||
@Override
|
||||
protected boolean handleRead(ByteBuffer buffer) {
|
||||
if (buffer.limit() < 14) {
|
||||
LimeLog.severe("Read too small: "+buffer.limit());
|
||||
if (buffer.remaining() < 14) {
|
||||
LimeLog.severe("Read too small: "+buffer.remaining());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -101,11 +101,21 @@ public class XboxOneController extends AbstractXboxController {
|
||||
switch (buffer.get())
|
||||
{
|
||||
case 0x20:
|
||||
if (buffer.remaining() < 17) {
|
||||
LimeLog.severe("XBone button/axis read too small: "+buffer.remaining());
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer.position(buffer.position()+3);
|
||||
processButtons(buffer);
|
||||
return true;
|
||||
|
||||
case 0x07:
|
||||
if (buffer.remaining() < 4) {
|
||||
LimeLog.severe("XBone mode read too small: "+buffer.remaining());
|
||||
return false;
|
||||
}
|
||||
|
||||
// The Xbox One S controller needs acks for mode reports otherwise
|
||||
// it retransmits them forever.
|
||||
if (buffer.get() == 0x30) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user