-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,393 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/composite_device_v1.json | ||
# Schema version number | ||
version: 1 | ||
|
||
# The type of configuration schema | ||
kind: CompositeDevice | ||
|
||
# Name of the composite device mapping | ||
name: ASUS ROG Ally X | ||
|
||
# Only allow a single source device per composite device of this type. | ||
single_source: false | ||
|
||
# Only use this profile if *any* of the given matches matches. If this list is | ||
# empty, then the source devices will *always* be checked. | ||
# /sys/class/dmi/id/product_name | ||
matches: | ||
- dmi_data: | ||
board_name: RC72LA | ||
sys_vendor: ASUSTeK COMPUTER INC. | ||
|
||
# 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: gamepad # Used for setting attributes on load | ||
hidraw: | ||
vendor_id: 0x0b05 | ||
product_id: 0x1b4c | ||
interface_num: 2 | ||
- group: gamepad | ||
evdev: | ||
name: "ASUS ROG Ally X Gamepad" | ||
vendor_id: "0b05" | ||
product_id: "1b4c" | ||
handler: event* | ||
- group: keyboard | ||
unique: false | ||
evdev: | ||
name: "Asus Keyboard" | ||
phys_path: usb-0000:64:00.3-2/input[2-3] | ||
handler: event* | ||
- group: imu | ||
iio: | ||
name: bmi323-imu | ||
mount_matrix: | ||
x: [-1, 0, 0] | ||
y: [0, 0, -1] | ||
z: [0, 1, 0] | ||
|
||
# The target input device(s) that the virtual device profile can use | ||
target_devices: | ||
- xbox-elite | ||
- mouse | ||
- keyboard | ||
|
||
# The ID of a device event mapping in the 'event_maps' folder | ||
capability_map_id: aly1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use std::{error::Error, ffi::OsStr}; | ||
|
||
use udev::Device; | ||
|
||
use crate::udev::device::{AttributeSetter, UdevDevice}; | ||
|
||
// Hardware ID's | ||
const ALLY_PID: u16 = 0x1abe; | ||
const ALLYX_PID: u16 = 0x1b4c; | ||
pub const PIDS: [u16; 2] = [ALLY_PID, ALLYX_PID]; | ||
pub const VID: u16 = 0x0b05; | ||
|
||
pub struct Driver { | ||
_device: UdevDevice, | ||
} | ||
|
||
impl Driver { | ||
pub fn new(udevice: UdevDevice) -> Result<Self, Box<dyn Error + Send + Sync>> { | ||
let vid = udevice.id_vendor(); | ||
let pid = udevice.id_product(); | ||
if VID != vid || !PIDS.contains(&pid) { | ||
return Err(format!("'{}' is not an ROG Ally controller", udevice.devnode()).into()); | ||
} | ||
|
||
// Set the controller buttons to the correct values at startup | ||
let device = udevice.get_device()?; | ||
let Some(mut parent) = device.parent() else { | ||
return Err("Failed to get device parent".into()); | ||
}; | ||
let Some(driver) = parent.driver() else { | ||
return Err("Failed to identify device driver".into()); | ||
}; | ||
if driver.to_str().unwrap() == "asus" { | ||
set_attribute(device.clone(), "btn_m1/remap", "kb_f15")?; | ||
set_attribute(device.clone(), "btn_m2/remap", "kb_f14")?; | ||
set_attribute(device, "gamepad_mode", "1")?; | ||
//TODO: Figure out why this fails and manually running the same thing | ||
//doesn't. | ||
//set_attribute(device, "apply", "1")?; | ||
let result = parent.set_attribute_value(OsStr::new("apply"), OsStr::new("1")); | ||
match result { | ||
Ok(_) => log::debug!("set apply to 1"), | ||
Err(e) => return Err(format!("Could set apply to 1: {e:?}").into()), | ||
}; | ||
} else { | ||
return Err("Device is not an asus device.".into()); | ||
} | ||
|
||
Ok(Self { _device: udevice }) | ||
} | ||
} | ||
|
||
pub fn set_attribute( | ||
mut device: Device, | ||
attribute: &str, | ||
value: &str, | ||
) -> Result<(), Box<dyn Error + Send + Sync>> { | ||
let result = device.set_attribute_on_tree(attribute, value); | ||
match result { | ||
Ok(r) => { | ||
log::debug!("set {attribute} to {value}"); | ||
Ok(r) | ||
} | ||
Err(e) => Err(format!("Could not set {attribute} to {value}: {e:?}").into()), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod driver; |
Oops, something went wrong.