From 545c3397db4e5031e2a4aebc6f4bef4a3639a045 Mon Sep 17 00:00:00 2001 From: Iwan Timmer Date: Wed, 18 Feb 2015 17:07:34 +0100 Subject: [PATCH] Correct handling of triggers --- src/com/limelight/input/EvdevAbsolute.java | 26 ++++++++++++---------- src/com/limelight/input/EvdevHandler.java | 4 ++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/com/limelight/input/EvdevAbsolute.java b/src/com/limelight/input/EvdevAbsolute.java index b49c8f6..1801a39 100644 --- a/src/com/limelight/input/EvdevAbsolute.java +++ b/src/com/limelight/input/EvdevAbsolute.java @@ -13,8 +13,9 @@ public class EvdevAbsolute { private final static int ABS_OFFSET = 0x40; + private int min, max; private int avg; - private int range; + private int range, diff; private int flat; private boolean reverse; @@ -27,12 +28,13 @@ public class EvdevAbsolute { IO.ioctl(filename, data, request); buffer.getInt(); //Skip current value - int min = buffer.getInt(); - int max = buffer.getInt(); + min = buffer.getInt(); + max = buffer.getInt(); buffer.getInt(); //Skip fuzz flat = buffer.getInt(); avg = (min+max)/2; range = max-avg; + diff = max-min; this.reverse = reverse; } @@ -45,9 +47,9 @@ public class EvdevAbsolute { public short getShort(int value) { if (Math.abs(value-avg)avg+range) + else if (value>max) return reverse?Short.MIN_VALUE:Short.MAX_VALUE; - else if (valueavg+range) - return reverse?Byte.MIN_VALUE:Byte.MAX_VALUE; - else if (valuemax) + return reverse?0:(byte) 0xFF; + else if (value