From f35636fb426f33de6ed160746f2fe0768a87f249 Mon Sep 17 00:00:00 2001 From: cyber-sushi Date: Sat, 18 May 2024 03:57:47 +0200 Subject: [PATCH] Fixed regressions affecting default scroll wheel event and analog sticks rebinding --- src/event_reader.rs | 60 +++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/src/event_reader.rs b/src/event_reader.rs index 5b84ce8..7b6015d 100644 --- a/src/event_reader.rs +++ b/src/event_reader.rs @@ -185,44 +185,44 @@ impl EventReader { else if axis_value > 0 { 1 } else { 0 }; match AbsoluteAxisType(event.code()) { - AbsoluteAxisType::ABS_X => { + AbsoluteAxisType::ABS_Y => { match clamped_value { - -1 if lstick_values.0 != -1 => { + -1 if lstick_values.1 != -1 => { self.convert_event(event, Event::Axis(Axis::LSTICK_UP), 1).await; - lstick_values.0 = -1 + lstick_values.1 = -1 }, - 1 if lstick_values.0 != 1 => { + 1 if lstick_values.1 != 1 => { self.convert_event(event, Event::Axis(Axis::LSTICK_DOWN), 1).await; - lstick_values.0 = 1 + lstick_values.1 = 1 }, - 0 => if lstick_values.0 != 0 { - match lstick_values.0 { + 0 => if lstick_values.1 != 0 { + match lstick_values.1 { -1 => self.convert_event(event, Event::Axis(Axis::LSTICK_UP), 0).await, 1 => self.convert_event(event, Event::Axis(Axis::LSTICK_DOWN), 0).await, _ => {}, } - lstick_values.0 = 0; + lstick_values.1 = 0; }, _ => {}, } }, - AbsoluteAxisType::ABS_Y => { + AbsoluteAxisType::ABS_X => { match clamped_value { - -1 if lstick_values.1 != -1 => { + -1 if lstick_values.0 != -1 => { self.convert_event(event, Event::Axis(Axis::LSTICK_LEFT), 1).await; lstick_values.0 = -1 }, - 1 => if lstick_values.1 != 1 { + 1 => if lstick_values.0 != 1 { self.convert_event(event, Event::Axis(Axis::LSTICK_RIGHT), 1).await; lstick_values.0 = 1 }, - 0 => if lstick_values.1 != 0 { - match lstick_values.1 { + 0 => if lstick_values.0 != 0 { + match lstick_values.0 { -1 => self.convert_event(event, Event::Axis(Axis::LSTICK_LEFT), 0).await, 1 => self.convert_event(event, Event::Axis(Axis::LSTICK_RIGHT), 0).await, _ => {}, } - lstick_values.1 = 0; + lstick_values.0 = 0; }, _ => {}, } @@ -246,44 +246,44 @@ impl EventReader { else if axis_value > 0 { 1 } else { 0 }; match AbsoluteAxisType(event.code()) { - AbsoluteAxisType::ABS_X => { + AbsoluteAxisType::ABS_RY => { match clamped_value { - -1 => if rstick_values.0 != -1 { + -1 => if rstick_values.1 != -1 { self.convert_event(event, Event::Axis(Axis::RSTICK_UP), 1).await; - rstick_values.0 = -1 + rstick_values.1 = -1 }, - 1 => if rstick_values.0 != 1 { + 1 => if rstick_values.1 != 1 { self.convert_event(event, Event::Axis(Axis::RSTICK_DOWN), 1).await; - rstick_values.0 = 1 + rstick_values.1 = 1 }, - 0 => if rstick_values.0 != 0 { - match rstick_values.0 { + 0 => if rstick_values.1 != 0 { + match rstick_values.1 { -1 => self.convert_event(event, Event::Axis(Axis::RSTICK_UP), 0).await, 1 => self.convert_event(event, Event::Axis(Axis::RSTICK_DOWN), 0).await, _ => {}, } - rstick_values.0 = 0; + rstick_values.1 = 0; }, _ => {}, } }, - AbsoluteAxisType::ABS_Y => { + AbsoluteAxisType::ABS_RX => { match clamped_value { - -1 if rstick_values.1 != -1 => { + -1 if rstick_values.0 != -1 => { self.convert_event(event, Event::Axis(Axis::RSTICK_LEFT), 1).await; rstick_values.0 = -1 }, - 1 => if rstick_values.1 != 1 { + 1 => if rstick_values.0 != 1 { self.convert_event(event, Event::Axis(Axis::RSTICK_RIGHT), 1).await; rstick_values.0 = 1 }, - 0 => if rstick_values.1 != 0 { - match rstick_values.1 { + 0 => if rstick_values.0 != 0 { + match rstick_values.0 { -1 => self.convert_event(event, Event::Axis(Axis::RSTICK_LEFT), 0).await, 1 => self.convert_event(event, Event::Axis(Axis::RSTICK_RIGHT), 0).await, _ => {}, } - rstick_values.1 = 0; + rstick_values.0 = 0; }, _ => {}, } @@ -415,7 +415,9 @@ impl EventReader { virt_dev.keys.emit(&[default_event]).unwrap(); }, EventType::RELATIVE => { - virt_dev.axis.emit(&[default_event]).unwrap(); + if value == 1 { + virt_dev.axis.emit(&[default_event]).unwrap(); + } }, _ => {}, }