Suport for Dpads which use absolute values in evdev

This commit is contained in:
Iwan Timmer
2014-01-28 14:42:13 +01:00
parent dc97bc9cf0
commit 07c6c55577
4 changed files with 53 additions and 3 deletions

View File

@@ -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;
}
}