Skip to content

Commit

Permalink
fix(LegionGo): Fix input when a single controller is detached.
Browse files Browse the repository at this point in the history
  • Loading branch information
pastaq committed Jun 15, 2024
1 parent 53eb7aa commit 9a2630b
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 97 deletions.
100 changes: 77 additions & 23 deletions rootfs/usr/share/inputplumber/devices/50-legion_go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,108 @@ matches:
# One or more source devices to combine into a single virtual device. The events
# from these devices will be watched and translated according to the key map.
source_devices:
- group: mouse # Touch Device
# Touchpad
- group: mouse # Gamepad Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6182
interface_num: 1
- group: gamepad
- group: mouse # DInput Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6182
interface_num: 2
- group: gamepad
product_id: 0x6184
interface_num: 1
- group: mouse # Gampead Mode
blocked: true
evdev:
vendor_id: "17ef"
product_id: "6182"
name: " Legion Controller for Windows Touchpad"
- group: mouse # DInput mode
blocked: true
evdev:
vendor_id: "17ef"
product_id: "6184"
name: "Legion-Controller 1-D6 Touchpad"

# Mouse
- group: mouse # DInput Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6185
interface_num: 2
- group: gamepad
interface_num: 1
- group: mouse # Gamepad Mode
blocked: true
evdev:
vendor_id: "17ef"
product_id: "6182"
name: "Generic X-Box pad"
- group: keyboard
name: " Legion Controller for Windows Mouse"
- group: mouse # FPS/Dinput Mode
blocked: true
unique: false
evdev:
vendor_id: "17ef"
product_id: "6182"
name: "*Legion Controller*"
- group: keyboard
blocked: false
product_id: "618[4-5]"
name: "Legion-Controller 1-D6 Mouse"
- group: mouse # FPS/Dinput Mode
blocked: true
unique: false
evdev:
vendor_id: "17ef"
product_id: "6185"
product_id: "618[4-5]"
name: "Legion-Controller 1-D6"
- group: keyboard

# Keyboard
- group: mouse # DInput Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6185
interface_num: 0
- group: keyboard # Gamepad Mode
blocked: true
unique: true
evdev:
vendor_id: "17ef"
product_id: "6185"
name: "Legion-Controller 1-D6 Keyboard"
- group: keyboard
product_id: "6182"
name: " Legion Controller for Windows Keyboard"
- group: keyboard # FPS/DInput Mode
blocked: true
unique: true
evdev:
vendor_id: "17ef"
product_id: "6185"
name: "Legion-Controller 1-D6 Mouse"
product_id: "618[4-5]"
name: "Legion-Controller 1-D6 Keyboard"

# Gamepad
- group: gamepad # Gamepad Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6182
interface_num: 2
- group: gamepad # Dinput Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6184
interface_num: 0
- group: gamepad # Dinput Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6184
interface_num: 2
- group: gamepad # FPS Mode
hidraw:
vendor_id: 0x17ef
product_id: 0x6185
interface_num: 2
- group: gamepad # Newer Kernels
evdev:
vendor_id: "17ef"
product_id: "6182"
name: "Lenovo Legion Controller for Windows"
- group: gamepad # Older Kernels
evdev:
vendor_id: "17ef"
product_id: "6182"
name: "Generic X-Box pad"

# IMU
- group: imu
iio:
name: accel_3d
Expand Down
5 changes: 4 additions & 1 deletion src/drivers/iio_imu/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ impl Driver {
pub fn calculate_sample_delay(&self) -> Result<Duration, Box<dyn Error>> {
let accel_rate = self.get_sample_rate("accel").unwrap_or(1.0);
let gyro_rate = self.get_sample_rate("gyro").unwrap_or(1.0);
let sample_delay = 1.0 / accel_rate.max(gyro_rate);
let mut sample_delay = 1.0 / accel_rate.max(gyro_rate);
if sample_delay <= 0.0 {
sample_delay = 0.0025;
}
log::debug!("Updated sample delay is: {sample_delay} seconds.");

Ok(Duration::from_secs_f64(sample_delay))
Expand Down
Loading

0 comments on commit 9a2630b

Please sign in to comment.