Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ACTION=="add|change|bind", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e31[01]",
ACTION=="add|change|bind", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e31[01]", SUBSYSTEM=="hid", DRIVER=="hid-lenovo-go-s", ATTR{gamepad/auto_sleep_time}="0", ATTR{gamepad/dpad_mode}="8-way", ATTR{gamepad/poll_rate}="250", ATTR{os_mode}="linux", ATTR{touchpad/linux_mode}="absolute", GOTO="inputplumber_setup_end"

# Legion Go/Go2 Controller Settings
ACTION=="add|change|bind", ATTRS{idVendor}=="17ef", ATTRS{idProduct}=="61e[bcde]", SUBSYSTEM=="hid", DRIVER=="hid-lenovo-go", ATTR{os_mode}="linux", ATTR{left_handle/imu_bypass_enable}="true", ATTR{right_handle/imu_bypass_enable}="true", ATTR{touchpad/vibration_enable}="false", GOTO="inputplumber_setup_end"
ACTION=="add|change|bind", ATTRS{idVendor}=="17ef", ATTRS{idProduct}=="61e[bcde]", SUBSYSTEM=="hid", DRIVER=="hid-lenovo-go", ATTR{os_mode}="linux", ATTR{left_handle/imu_bypass_enabled}="true", ATTR{right_handle/imu_bypass_enabled}="true", ATTR{touchpad/vibration_enabled}="false", GOTO="inputplumber_setup_end"

# ASUS
# ROG Ally Controller Settings
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

#RGB
- group: led
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_2021.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

# Optional configuration for the composite device
options:
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_2s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

#RGB
- group: led
Expand Down
6 changes: 3 additions & 3 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_air.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ source_devices:
name: "{i2c-BMI0160:00,bmi260}"
config:
imu:
mount_matrix: # TODO: Verify on actual hardware
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

#RGB
- group: led
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_air_plus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, -1]
z: [1, 0, 0]
y: [1, 0, 0]
z: [0, 0, 1]

#RGB
- group: led
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ source_devices:
mount_matrix:
# TODO: Verify on actual hardware
x: [0, -1, 0]
y: [0, 0, -1]
z: [-1, 0, 0]
y: [1, 0, 0]
z: [0, 0, 1]

#RGB
- group: led
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_flip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [0, 0, -1]
z: [1, 0, 0]
- group: touchscreen
udev:
properties:
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayaneo_next.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

# Optional configuration for the composite device
options:
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayn_loki_max.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ source_devices:
imu:
mount_matrix:
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, -1, 0]
y: [0, -1, 0]
z: [0, 0, -1]

#RGB
- group: led
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ source_devices:
mount_matrix:
# TODO: Verify on actual hardware
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, 1, 0]
y: [0, -1, 0]
z: [0, 0, -1]

#RGB
- group: led
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-ayn_loki_zero.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ source_devices:
imu:
mount_matrix: # TODO: Verify on actual hardware
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, 1, 0]
y: [0, -1, 0]
z: [0, 0, -1]

#RGB
- group: led
Expand Down
10 changes: 5 additions & 5 deletions rootfs/usr/share/inputplumber/devices/50-legion_go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ source_devices:
imu:
mount_matrix:
x: [0, 1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, 1]
accel_correction: 10.0 # adm_sfh rdesktop scale compensation
gyro_correction: 100.0
- group: imu
Expand All @@ -233,9 +233,9 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [1, 0, 0]
accel_correction: 10.0 # adm_sfh rdesktop scale compensation
y: [1, 0, 0]
z: [0, 0, -1]
accel_correction: 10.5 # adm_sfh rdesktop scale compensation
gyro_correction: 100.0

# Optional configuration for the composite device
Expand Down
10 changes: 3 additions & 7 deletions rootfs/usr/share/inputplumber/devices/50-msi_claw_a8_bz2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,6 @@ source_devices:
name: gyro_3d
config:
imu:
mount_matrix:
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, 1, 0]
accel_correction: 10.0 # adm_sfh rdesktop scale compensation
gyro_correction: 100.0
- group: imu
Expand All @@ -155,9 +151,9 @@ source_devices:
imu:
mount_matrix:
x: [-1, 0, 0]
y: [0, 0, 1]
z: [0, -1, 0]
accel_correction: 10.0 # adm_sfh rdesktop scale compensation
y: [0, -1, 0]
z: [0, 0, -1]
accel_correction: 10.5 # adm_sfh rdesktop scale compensation
gyro_correction: 100.0

# Optional configuration for the composite device
Expand Down
6 changes: 3 additions & 3 deletions rootfs/usr/share/inputplumber/devices/50-onexplayer_3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ source_devices:
iio:
name: bmi260
mount_matrix:
x: [0, 1, 0]
y: [1, 0, 0]
z: [0, 0, 1]
x: [0, -1, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

# Optional configuration for the composite device
options:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

# Optional configuration for the composite device
options:
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-onexplayer_x1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ source_devices:
mount_matrix:
# TODO: Verify on actual hardware
x: [0, 1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [1, 0, 0]
z: [0, 0, -1]

# External / docked controllers: joined dock supplies power and 2.4 GHz to the
# handheld. The gamepad entry is the receiver's XInput-style device; the fe02
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-orangepi_neo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ source_devices:
imu:
mount_matrix:
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, -1, 0]
y: [0, -1, 0]
z: [0, 0, -1]

# Optional configuration for the composite device
options:
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-rog_ally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ source_devices:
imu:
mount_matrix:
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, -1, 0]
y: [0, -1, 0]
z: [0, 0, -1]
- group: led
udev:
sys_name: ally:rgb:joystick_rings
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-rog_ally_x.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ source_devices:
imu:
mount_matrix:
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, -1, 0]
y: [0, -1, 0]
z: [0, 0, -1]
- group: led
udev:
sys_name: ally:rgb:joystick_rings
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-rog_xbox_ally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ source_devices:
mount_matrix:
# TODO: Verify on actual hardware
x: [1, 0, 0]
y: [0, 0, 1]
z: [0, 1, 0]
y: [0, -1, 0]
z: [0, 0, -1]
- group: led
udev:
sys_name: ally:rgb:joystick_rings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ source_devices:
imu:
mount_matrix:
x: [-1, 0, 0]
y: [0, 0, 1]
z: [0, -1, 0]
y: [0, -1, 0]
z: [0, 0, 1]
- group: led
udev:
sys_name: ally:rgb:joystick_rings
Expand Down
4 changes: 2 additions & 2 deletions rootfs/usr/share/inputplumber/devices/50-zotac-zone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ source_devices:
imu:
mount_matrix:
x: [0, -1, 0]
y: [0, 0, 1]
z: [-1, 0, 0]
y: [-1, 0, 0]
z: [0, 0, -1]

#RGB
- group: led
Expand Down
12 changes: 12 additions & 0 deletions src/drivers/iio_imu/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ impl Driver {
})
}

/// The event kinds the device's discovered channel groups can produce.
pub fn supported_events(&self) -> Vec<Event> {
let mut events = Vec::new();
if !self.layout.accel.is_empty() {
events.push(Event::Accelerometer(AxisData::default()));
}
if !self.layout.gyro.is_empty() {
events.push(Event::Gyroscope(AxisData::default()));
}
events
}

pub fn update_filtered_events(&mut self, events: Vec<Event>) {
self.filtered_events = events;
}
Expand Down
39 changes: 15 additions & 24 deletions src/drivers/iio_imu/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,33 +29,24 @@ pub struct MountMatrix {

impl MountMatrix {
/// Create a new [MountMatrix] from the given mount matrix string
/// Example:
/// "1, 0, 0; 0, 1, 0; 0, 0, 1"
/// Examples:
/// "1, 0, 0; 0, 1, 0; 0, 0, 1", "1 0 0 0 1 0 0 0 1"
pub fn new(matrix_str: String) -> Result<Self, Box<dyn Error + Send + Sync>> {
let parts: Vec<&str> = matrix_str.split(';').map(|part| part.trim()).collect();
if parts.len() != 3 {
return Err("Not enough parts found in the matrix".into());
let values: Result<Vec<f64>, _> = matrix_str
.split(|c: char| c == ',' || c == ';' || c.is_whitespace())
.filter(|part| !part.is_empty())
.map(|part| part.parse::<f64>())
.collect();
let values = values?;
if values.len() != 9 {
return Err("Expected nine numbers in the matrix".into());
}

let mut matrix = MountMatrix::default();
for (i, part) in parts.into_iter().enumerate() {
let sub_parts: Vec<&str> = part.split(',').map(|part| part.trim()).collect();
if sub_parts.len() != 3 {
return Err("Not enough subparts".into());
}
let x = sub_parts.first().unwrap().parse::<f64>()?;
let y = sub_parts.get(1).unwrap().parse::<f64>()?;
let z = sub_parts.get(2).unwrap().parse::<f64>()?;

match i {
0 => matrix.x = (x, y, z),
1 => matrix.y = (x, y, z),
2 => matrix.z = (x, y, z),
_ => (),
}
}

Ok(matrix)
Ok(MountMatrix {
x: (values[0], values[1], values[2]),
y: (values[3], values[4], values[5]),
z: (values[6], values[7], values[8]),
})
}
}

Expand Down
Loading
Loading