Fixed regressions affecting default scroll wheel event and analog sticks rebinding

This commit is contained in:
cyber-sushi 2024-05-18 03:57:47 +02:00
parent 494e70267e
commit f35636fb42

View file

@ -185,44 +185,44 @@ impl EventReader {
else if axis_value > 0 { 1 } else if axis_value > 0 { 1 }
else { 0 }; else { 0 };
match AbsoluteAxisType(event.code()) { match AbsoluteAxisType(event.code()) {
AbsoluteAxisType::ABS_X => { AbsoluteAxisType::ABS_Y => {
match clamped_value { 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; 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; 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 { 0 => if lstick_values.1 != 0 {
match lstick_values.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_UP), 0).await,
1 => self.convert_event(event, Event::Axis(Axis::LSTICK_DOWN), 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 { 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; self.convert_event(event, Event::Axis(Axis::LSTICK_LEFT), 1).await;
lstick_values.0 = -1 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; self.convert_event(event, Event::Axis(Axis::LSTICK_RIGHT), 1).await;
lstick_values.0 = 1 lstick_values.0 = 1
}, },
0 => if lstick_values.1 != 0 { 0 => if lstick_values.0 != 0 {
match lstick_values.1 { 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_LEFT), 0).await,
1 => self.convert_event(event, Event::Axis(Axis::LSTICK_RIGHT), 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 if axis_value > 0 { 1 }
else { 0 }; else { 0 };
match AbsoluteAxisType(event.code()) { match AbsoluteAxisType(event.code()) {
AbsoluteAxisType::ABS_X => { AbsoluteAxisType::ABS_RY => {
match clamped_value { 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; 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; 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 { 0 => if rstick_values.1 != 0 {
match rstick_values.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_UP), 0).await,
1 => self.convert_event(event, Event::Axis(Axis::RSTICK_DOWN), 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 { 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; self.convert_event(event, Event::Axis(Axis::RSTICK_LEFT), 1).await;
rstick_values.0 = -1 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; self.convert_event(event, Event::Axis(Axis::RSTICK_RIGHT), 1).await;
rstick_values.0 = 1 rstick_values.0 = 1
}, },
0 => if rstick_values.1 != 0 { 0 => if rstick_values.0 != 0 {
match rstick_values.1 { 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_LEFT), 0).await,
1 => self.convert_event(event, Event::Axis(Axis::RSTICK_RIGHT), 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(); virt_dev.keys.emit(&[default_event]).unwrap();
}, },
EventType::RELATIVE => { EventType::RELATIVE => {
if value == 1 {
virt_dev.axis.emit(&[default_event]).unwrap(); virt_dev.axis.emit(&[default_event]).unwrap();
}
}, },
_ => {}, _ => {},
} }