summaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-uclogic-core.c
diff options
context:
space:
mode:
authorNikolai Kondrashov <spbnick@gmail.com>2022-05-08 18:01:43 +0200
committerJiri Kosina <jkosina@suse.cz>2022-05-11 14:19:27 +0200
commitfbc08b4e8ea5582029dc3c05c954d4d157e4d3f8 (patch)
tree249de3edbf8355f0b35db22bc408787d0ec7f9e5 /drivers/hid/hid-uclogic-core.c
parentcaf7e93479c73374a9fcad29f90477280444584e (diff)
downloadlinux-fbc08b4e8ea5582029dc3c05c954d4d157e4d3f8.tar.bz2
HID: uclogic: Always shift touch reports to zero
Always decrement touch report values to have the range start with zero, regardless if flipped or not. This fixes the future non-flipped touch strip reports. Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-uclogic-core.c')
-rw-r--r--drivers/hid/hid-uclogic-core.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/hid/hid-uclogic-core.c b/drivers/hid/hid-uclogic-core.c
index cc53625ed1f7..c4ab94d58a0f 100644
--- a/drivers/hid/hid-uclogic-core.c
+++ b/drivers/hid/hid-uclogic-core.c
@@ -386,15 +386,16 @@ static int uclogic_raw_event_frame(
}
/* If need to, and can, transform the touch ring reports */
- if (frame->touch_byte > 0 && frame->touch_byte < size &&
- frame->touch_flip_at != 0) {
+ if (frame->touch_byte > 0 && frame->touch_byte < size) {
__s8 value = data[frame->touch_byte];
- if (value != 0) {
- value = frame->touch_flip_at - value;
- if (value < 0)
- value = frame->touch_max + value;
- data[frame->touch_byte] = value;
+ if (value != 0) {
+ if (frame->touch_flip_at != 0) {
+ value = frame->touch_flip_at - value;
+ if (value <= 0)
+ value = frame->touch_max + value;
+ }
+ data[frame->touch_byte] = value - 1;
}
}