mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-18 14:50:56 +00:00
Don't send controller input when receiving non mapped event
This commit is contained in:
@@ -81,6 +81,7 @@ public class EvdevHandler implements Runnable {
|
|||||||
short type = buffer.getShort();
|
short type = buffer.getShort();
|
||||||
short code = buffer.getShort();
|
short code = buffer.getShort();
|
||||||
int value = buffer.getInt();
|
int value = buffer.getInt();
|
||||||
|
boolean mapped = true;
|
||||||
|
|
||||||
if (type==EvdevConstants.EV_KEY) {
|
if (type==EvdevConstants.EV_KEY) {
|
||||||
if (code<EvdevConstants.KEY_CODES.length) {
|
if (code<EvdevConstants.KEY_CODES.length) {
|
||||||
@@ -90,6 +91,8 @@ public class EvdevHandler implements Runnable {
|
|||||||
conn.sendKeyboardInput(gfCode, KeyboardPacket.KEY_DOWN, (byte) 0);
|
conn.sendKeyboardInput(gfCode, KeyboardPacket.KEY_DOWN, (byte) 0);
|
||||||
else if (value==EvdevConstants.KEY_RELEASED)
|
else if (value==EvdevConstants.KEY_RELEASED)
|
||||||
conn.sendKeyboardInput(gfCode, KeyboardPacket.KEY_UP, (byte) 0);
|
conn.sendKeyboardInput(gfCode, KeyboardPacket.KEY_UP, (byte) 0);
|
||||||
|
|
||||||
|
mapped = false;
|
||||||
} else {
|
} else {
|
||||||
byte mouseButton = 0;
|
byte mouseButton = 0;
|
||||||
short gamepadButton = 0;
|
short gamepadButton = 0;
|
||||||
@@ -147,8 +150,8 @@ public class EvdevHandler implements Runnable {
|
|||||||
leftTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
|
leftTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
|
||||||
} else if (code==mapping.btn_tr2) {
|
} else if (code==mapping.btn_tr2) {
|
||||||
rightTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
|
rightTrigger = (byte) (value==EvdevConstants.KEY_PRESSED ? -1 : 0);
|
||||||
}
|
} else
|
||||||
conn.sendControllerInput(buttonFlags, leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY);
|
mapped = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type==EvdevConstants.EV_REL) {
|
} else if (type==EvdevConstants.EV_REL) {
|
||||||
@@ -156,6 +159,8 @@ public class EvdevHandler implements Runnable {
|
|||||||
conn.sendMouseMove((short) value, (short) 0);
|
conn.sendMouseMove((short) value, (short) 0);
|
||||||
else if (code==EvdevConstants.REL_Y)
|
else if (code==EvdevConstants.REL_Y)
|
||||||
conn.sendMouseMove((short) 0, (short) value);
|
conn.sendMouseMove((short) 0, (short) value);
|
||||||
|
|
||||||
|
mapped = false;
|
||||||
} else if (type==EvdevConstants.EV_ABS) {
|
} else if (type==EvdevConstants.EV_ABS) {
|
||||||
if (code==mapping.abs_x)
|
if (code==mapping.abs_x)
|
||||||
leftStickX = accountForDeadzone(absLX.getShort(value));
|
leftStickX = accountForDeadzone(absLX.getShort(value));
|
||||||
@@ -193,11 +198,14 @@ public class EvdevHandler implements Runnable {
|
|||||||
buttonFlags |= ControllerPacket.DOWN_FLAG;
|
buttonFlags |= ControllerPacket.DOWN_FLAG;
|
||||||
buttonFlags &= ~ControllerPacket.UP_FLAG;
|
buttonFlags &= ~ControllerPacket.UP_FLAG;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
mapped = false;
|
||||||
|
} else
|
||||||
|
mapped = false;
|
||||||
|
|
||||||
|
if (mapped)
|
||||||
conn.sendControllerInput(buttonFlags, leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY);
|
conn.sendControllerInput(buttonFlags, leftTrigger, rightTrigger, leftStickX, leftStickY, rightStickX, rightStickY);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private short accountForDeadzone(short value) {
|
private short accountForDeadzone(short value) {
|
||||||
if (Math.abs(value) > mapping.abs_deadzone) {
|
if (Math.abs(value) > mapping.abs_deadzone) {
|
||||||
|
|||||||
Reference in New Issue
Block a user