Skip to content

feat: add mouse wheel support#514

Open
pastaq wants to merge 2 commits intomainfrom
pastaq/lego_scroll
Open

feat: add mouse wheel support#514
pastaq wants to merge 2 commits intomainfrom
pastaq/lego_scroll

Conversation

@pastaq
Copy link
Contributor

@pastaq pastaq commented Feb 3, 2026

replaces #445

I pulled in @LukeShortCloud commit and made some changes. He had already made the InputValue a vec2 so there was nothing to be done there. I added the InputValue -> REL_WHEEL and REL_HWHEEL to evdev.rs and moved all capability -> string into the standard location, and added the new mouse wheel to the string list.

Here is a full diff of the changes from Luke's patch to my version.

< From b03631e9312fe1f602768ef80414cbeee805b949 Mon Sep 17 00:00:00 2001
---
> From 3abbad3eede76e2fa2dfd6e8ba5a1e5a373b3af9 Mon Sep 17 00:00:00 2001
4c4
< Subject: [PATCH] feat: add mouse wheel support
---
> Subject: [PATCH 1/2] feat: add mouse wheel support
6a7,9
>
> (cherry picked from commit b03631e9312fe1f602768ef80414cbeee805b949)
> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
10,11c13,14
<  src/dbus/interface/composite_device.rs        |  2 +
<  src/input/capability.rs                       | 41 +++++++++++++++++
---
>  src/dbus/interface/composite_device.rs        | 20 +--------
>  src/input/capability.rs                       | 42 ++++++++++++++++++
13c16
<  src/input/event/evdev.rs                      | 14 +++++-
---
>  src/input/event/evdev.rs                      | 16 ++++++-
16c19
<  8 files changed, 124 insertions(+), 6 deletions(-)
---
>  8 files changed, 127 insertions(+), 24 deletions(-)
50c53
< index be15acd..d0ac977 100644
---
> index e4d0435..057dc33 100644
53,54c56
< @@ -236,6 +236,7 @@ pub struct DialCapability {
<  pub struct MouseCapability {
---
> @@ -275,6 +275,7 @@ pub struct MouseCapability {
55a58
>      #[serde(skip_serializing_if = "Option::is_none")]
61c64
< @@ -245,6 +246,13 @@ pub struct MouseMotionCapability {
---
> @@ -286,6 +287,13 @@ pub struct MouseMotionCapability {
76c79
< index e9995e3..c79accd 100644
---
> index 55730bd..e3db7ac 100644
79,94c82,115
< @@ -352,6 +352,7 @@ impl CompositeDeviceInterface {
<                  Capability::Mouse(mouse) => match mouse {
<                      Mouse::Motion => "Mouse:Motion".to_string(),
<                      Mouse::Button(button) => format!("Mouse:Button:{}", button),
< +                    Mouse::Wheel(wheel) => format!("Mouse:Wheel:{}", wheel),
<                  },
<                  Capability::Keyboard(key) => format!("Keyboard:{}", key),
<                  _ => cap.to_string(),
< @@ -416,6 +417,7 @@ impl CompositeDeviceInterface {
<                  Capability::Mouse(mouse) => match mouse {
<                      Mouse::Motion => "Mouse:Motion".to_string(),
<                      Mouse::Button(button) => format!("Mouse:Button:{}", button),
< +                    Mouse::Wheel(wheel) => format!("Mouse:Wheel:{}", wheel),
<                  },
<                  Capability::Keyboard(key) => format!("Keyboard:{}", key),
<                  _ => cap.to_string(),
---
> @@ -13,7 +13,7 @@ use crate::{
>      config::DeviceProfile,
>      dbus::polkit::check_polkit,
>      input::{
> -        capability::{Capability, Gamepad, Mouse},
> +        capability::Capability,
>          composite_device::{client::CompositeDeviceClient, InterceptMode},
>          event::{native::NativeEvent, value::InputValue},
>      },
> @@ -465,23 +465,7 @@ impl CompositeDeviceInterface {
>
>          let mut capability_strings = HashSet::new();
>          for cap in capabilities {
> -            let str = match cap {
> -                Capability::Gamepad(gamepad) => match gamepad {
> -                    Gamepad::Button(button) => format!("Gamepad:Button:{}", button),
> -                    Gamepad::Axis(axis) => format!("Gamepad:Axis:{}", axis),
> -                    Gamepad::Trigger(trigger) => format!("Gamepad:Trigger:{}", trigger),
> -                    Gamepad::Accelerometer => "Gamepad:Accelerometer".to_string(),
> -                    Gamepad::Gyro => "Gamepad:Gyro".to_string(),
> -                    Gamepad::Dial(dial) => format!("Gamepad:Dial:{dial}"),
> -                },
> -                Capability::Mouse(mouse) => match mouse {
> -                    Mouse::Motion => "Mouse:Motion".to_string(),
> -                    Mouse::Button(button) => format!("Mouse:Button:{}", button),
> -                },
> -                Capability::Keyboard(key) => format!("Keyboard:{}", key),
> -                Capability::DBus(action) => format!("DBus:{}", action.as_str()),
> -                _ => cap.to_string(),
> -            };
> +            let str = cap.to_capability_string();
>              capability_strings.insert(str);
>          }
>
96c117
< index 74a536e..d440cfe 100644
---
> index 5206b40..fb72245 100644
99c120,128
< @@ -199,6 +199,15 @@ impl From<CapabilityConfig> for Capability {
---
> @@ -56,6 +56,7 @@ impl Capability {
>              Capability::Mouse(mouse) => match mouse {
>                  Mouse::Motion => "Mouse:Motion".to_string(),
>                  Mouse::Button(button) => format!("Mouse:Button:{button}"),
> +                Mouse::Wheel(wheel) => format!("Mouse:Wheel:{wheel}"),
>              },
>              Capability::Keyboard(key) => format!("Keyboard:{key}"),
>              Capability::None => "None".to_string(),
> @@ -267,6 +268,15 @@ impl From<CapabilityConfig> for Capability {
115c144
< @@ -331,6 +340,8 @@ pub enum Mouse {
---
> @@ -437,6 +447,8 @@ pub enum Mouse {
124c153
< @@ -338,6 +349,7 @@ impl fmt::Display for Mouse {
---
> @@ -444,6 +456,7 @@ impl fmt::Display for Mouse {
132c161
< @@ -417,6 +429,35 @@ impl FromStr for MouseButton {
---
> @@ -523,6 +536,35 @@ impl FromStr for MouseButton {
169c198
< index f4cdbd3..644c310 100644
---
> index df06bec..d5402d9 100644
172c201
< @@ -919,6 +919,7 @@ impl CompositeDevice {
---
> @@ -988,6 +988,7 @@ impl CompositeDevice {
179c208
<              }
---
>                  Capability::Gyroscope(_) => (),
181c210
< index 574a7e6..d0bdeb1 100644
---
> index 7c11b68..7b374a4 100644
225a255,263
> @@ -975,6 +987,8 @@ fn input_event_from_value(
>                      EventType::RELATIVE => match RelativeAxisCode(code) {
>                          RelativeAxisCode::REL_X => x.map(|v| v as i32),
>                          RelativeAxisCode::REL_Y => y.map(|v| v as i32),
> +                        RelativeAxisCode::REL_HWHEEL => x.map(|v| v as i32),
> +                        RelativeAxisCode::REL_WHEEL => y.map(|v| v as i32),
>                          _ => None,
>                      },
>                      _ => None,
227c265
< index 9640890..a548822 100644
---
> index 7aa98a5..a784274 100644
238c276
< @@ -138,6 +139,8 @@ impl InputValue {
---
> @@ -205,6 +206,8 @@ impl InputValue {
247c285
< @@ -183,11 +186,10 @@ impl InputValue {
---
> @@ -254,11 +257,10 @@ impl InputValue {
260c298
< @@ -233,6 +235,7 @@ impl InputValue {
---
> @@ -308,6 +310,7 @@ impl InputValue {
268c306
< @@ -266,6 +269,7 @@ impl InputValue {
---
> @@ -345,6 +348,7 @@ impl InputValue {
276c314
< @@ -307,6 +311,7 @@ impl InputValue {
---
> @@ -388,6 +392,7 @@ impl InputValue {
284c322
< @@ -340,6 +345,7 @@ impl InputValue {
---
> @@ -425,6 +430,7 @@ impl InputValue {
292c330
< @@ -395,6 +401,7 @@ impl InputValue {
---
> @@ -484,6 +490,7 @@ impl InputValue {
300c338
< @@ -450,6 +457,7 @@ impl InputValue {
---
> @@ -543,6 +550,7 @@ impl InputValue {
308c346
< @@ -509,6 +517,7 @@ impl InputValue {
---
> @@ -606,6 +614,7 @@ impl InputValue {
316c354
< @@ -678,6 +687,37 @@ impl InputValue {
---
> @@ -781,6 +790,37 @@ impl InputValue {

LukeShortCloud and others added 2 commits February 2, 2026 19:54
for both horizontal and vertical movement.

(cherry picked from commit b03631e)
Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
Adds scroll wheel functionality to Legion Go and Legion Go 2.

While at it, clean up excess debug statements -> trace in composite
device.

Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants