mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-17 14:22:00 +00:00
Little cleanup EvdevHandler code
This commit is contained in:
@@ -23,7 +23,7 @@ public class EvdevHandler extends EvdevReader {
|
|||||||
private short buttonFlags;
|
private short buttonFlags;
|
||||||
private byte leftTrigger, rightTrigger;
|
private byte leftTrigger, rightTrigger;
|
||||||
private short leftStickX, leftStickY, rightStickX, rightStickY;
|
private short leftStickX, leftStickY, rightStickX, rightStickY;
|
||||||
private boolean gamepadModified = false;
|
private boolean gamepadModified;
|
||||||
|
|
||||||
private short mouseDeltaX, mouseDeltaY;
|
private short mouseDeltaX, mouseDeltaY;
|
||||||
private byte mouseScroll;
|
private byte mouseScroll;
|
||||||
@@ -76,8 +76,7 @@ public class EvdevHandler extends EvdevReader {
|
|||||||
conn.sendMouseScroll(mouseScroll);
|
conn.sendMouseScroll(mouseScroll);
|
||||||
mouseScroll = 0;
|
mouseScroll = 0;
|
||||||
}
|
}
|
||||||
}
|
} else if (type==EvdevConstants.EV_KEY) {
|
||||||
else if (type==EvdevConstants.EV_KEY) {
|
|
||||||
if (code<EvdevConstants.KEY_CODES.length) {
|
if (code<EvdevConstants.KEY_CODES.length) {
|
||||||
short gfCode = translator.translate(EvdevConstants.KEY_CODES[code]);
|
short gfCode = translator.translate(EvdevConstants.KEY_CODES[code]);
|
||||||
|
|
||||||
@@ -135,16 +134,15 @@ public class EvdevHandler extends EvdevReader {
|
|||||||
gamepadModified = true;
|
gamepadModified = true;
|
||||||
|
|
||||||
if (gamepadButton != 0) {
|
if (gamepadButton != 0) {
|
||||||
if (value==EvdevConstants.KEY_PRESSED) {
|
if (value==EvdevConstants.KEY_PRESSED)
|
||||||
buttonFlags |= gamepadButton;
|
buttonFlags |= gamepadButton;
|
||||||
} else if (value==EvdevConstants.KEY_RELEASED){
|
else if (value==EvdevConstants.KEY_RELEASED)
|
||||||
buttonFlags &= ~gamepadButton;
|
buttonFlags &= ~gamepadButton;
|
||||||
}
|
} else if (code==mapping.btn_tl2)
|
||||||
} else if (code==mapping.btn_tl2) {
|
|
||||||
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
|
else
|
||||||
gamepadModified = false;
|
gamepadModified = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -153,9 +151,8 @@ public class EvdevHandler extends EvdevReader {
|
|||||||
mouseDeltaX = (short) value;
|
mouseDeltaX = (short) value;
|
||||||
else if (code==EvdevConstants.REL_Y)
|
else if (code==EvdevConstants.REL_Y)
|
||||||
mouseDeltaY = (short) value;
|
mouseDeltaY = (short) value;
|
||||||
else if (code==EvdevConstants.REL_WHEEL) {
|
else if (code==EvdevConstants.REL_WHEEL)
|
||||||
mouseScroll = (byte) value;
|
mouseScroll = (byte) value;
|
||||||
}
|
|
||||||
} else if (type==EvdevConstants.EV_ABS) {
|
} else if (type==EvdevConstants.EV_ABS) {
|
||||||
gamepadModified = true;
|
gamepadModified = true;
|
||||||
|
|
||||||
@@ -201,11 +198,7 @@ public class EvdevHandler extends EvdevReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private short accountForDeadzone(short value) {
|
private short accountForDeadzone(short value) {
|
||||||
if (Math.abs(value) > mapping.abs_deadzone) {
|
return Math.abs(value) > mapping.abs_deadzone?value:0;
|
||||||
return value;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user