mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-03 14:36:09 +00:00
Suport for Dpads which use absolute values in evdev
This commit is contained in:
@@ -9,6 +9,8 @@ import java.nio.ByteOrder;
|
||||
*/
|
||||
public class EvdevAbsolute {
|
||||
|
||||
public final static int UP = 1, DOWN = -1, NONE = 0;
|
||||
|
||||
private final static int ABS_OFFSET = 0x40;
|
||||
private final static int READ_ONLY = 2;
|
||||
private final static char EVDEV_TYPE = 'E';
|
||||
@@ -52,4 +54,18 @@ public class EvdevAbsolute {
|
||||
return (byte) ((value-avg) * range / Byte.MAX_VALUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert input value to direction
|
||||
* @param value received input
|
||||
* @return input value as direction
|
||||
*/
|
||||
public byte getDirection(int value) {
|
||||
if (value>(avg+range/4))
|
||||
return UP;
|
||||
else if (value<(avg-range/4))
|
||||
return DOWN;
|
||||
else
|
||||
return NONE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user