mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-26 06:22:45 +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
|
@Override
|
||||||
protected boolean handleRead(ByteBuffer buffer) {
|
protected boolean handleRead(ByteBuffer buffer) {
|
||||||
if (buffer.limit() < 14) {
|
if (buffer.remaining() < 14) {
|
||||||
LimeLog.severe("Read too small: "+buffer.limit());
|
LimeLog.severe("Read too small: "+buffer.remaining());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,11 +101,21 @@ public class XboxOneController extends AbstractXboxController {
|
|||||||
switch (buffer.get())
|
switch (buffer.get())
|
||||||
{
|
{
|
||||||
case 0x20:
|
case 0x20:
|
||||||
|
if (buffer.remaining() < 17) {
|
||||||
|
LimeLog.severe("XBone button/axis read too small: "+buffer.remaining());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
buffer.position(buffer.position()+3);
|
buffer.position(buffer.position()+3);
|
||||||
processButtons(buffer);
|
processButtons(buffer);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 0x07:
|
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
|
// The Xbox One S controller needs acks for mode reports otherwise
|
||||||
// it retransmits them forever.
|
// it retransmits them forever.
|
||||||
if (buffer.get() == 0x30) {
|
if (buffer.get() == 0x30) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user