mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-17 06:11:36 +00:00
Revert "Adjusted short and byte scaling and reversal in EvdevAbsolute and accounting for signed and unsigned input"
Patch don't take minimum values into account
This reverts commit 12efe3b5a3.
This commit is contained in:
@@ -11,18 +11,14 @@ public class EvdevAbsolute {
|
|||||||
|
|
||||||
public final static int UP = 1, DOWN = -1, NONE = 0;
|
public final static int UP = 1, DOWN = -1, NONE = 0;
|
||||||
|
|
||||||
private static final int SHORT_MAX_UNSIGNED = 0xFFFF;
|
|
||||||
private static final int BYTE_MAX_UNSIGNED = 0xFF;
|
|
||||||
private final static int ABS_OFFSET = 0x40;
|
private final static int ABS_OFFSET = 0x40;
|
||||||
private final static int READ_ONLY = 2;
|
private final static int READ_ONLY = 2;
|
||||||
private final static char EVDEV_TYPE = 'E';
|
private final static char EVDEV_TYPE = 'E';
|
||||||
|
|
||||||
private int max;
|
|
||||||
private int avg;
|
private int avg;
|
||||||
private int range;
|
private int range;
|
||||||
|
|
||||||
private boolean reverse;
|
private boolean reverse;
|
||||||
private boolean signed;
|
|
||||||
|
|
||||||
public EvdevAbsolute(String filename, int axis, boolean reverse) {
|
public EvdevAbsolute(String filename, int axis, boolean reverse) {
|
||||||
ByteBuffer buffer = ByteBuffer.allocate(6*4);
|
ByteBuffer buffer = ByteBuffer.allocate(6*4);
|
||||||
@@ -33,10 +29,10 @@ public class EvdevAbsolute {
|
|||||||
|
|
||||||
buffer.getInt(); //Skip current value
|
buffer.getInt(); //Skip current value
|
||||||
int min = buffer.getInt();
|
int min = buffer.getInt();
|
||||||
max = buffer.getInt();
|
int max = buffer.getInt();
|
||||||
avg = (min+max)/2;
|
avg = (min+max)/2;
|
||||||
range = max-avg;
|
range = max-avg;
|
||||||
signed = min < 0;
|
|
||||||
this.reverse = reverse;
|
this.reverse = reverse;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,10 +46,7 @@ public class EvdevAbsolute {
|
|||||||
* @return input value as short
|
* @return input value as short
|
||||||
*/
|
*/
|
||||||
public short getShort(int value) {
|
public short getShort(int value) {
|
||||||
if (signed)
|
return (short) ((value-avg) * (reverse?-range:range) / Short.MAX_VALUE);
|
||||||
return (short) ((reverse ? -1 - value : value) * (Short.MAX_VALUE + 1) / (max + 1));
|
|
||||||
else
|
|
||||||
return (short) ((reverse ? max - value : value) * SHORT_MAX_UNSIGNED / max);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,11 +55,7 @@ public class EvdevAbsolute {
|
|||||||
* @return input value as byte
|
* @return input value as byte
|
||||||
*/
|
*/
|
||||||
public byte getByte(int value) {
|
public byte getByte(int value) {
|
||||||
if (signed) {
|
return (byte) ((value-avg) * (reverse?-range:range) / Byte.MAX_VALUE);
|
||||||
return (byte) ((reverse ? -1 - value : value) * (Byte.MAX_VALUE + 1) / (max + 1));
|
|
||||||
} else {
|
|
||||||
return (byte) ((reverse ? max - value : value) * BYTE_MAX_UNSIGNED / max);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user