Skip to content

Commit

Permalink
Merge pull request #40 from isitLoVe/patch-1
Browse files Browse the repository at this point in the history
Added support for Xbox Elite Wireless Controller Series 2
  • Loading branch information
jfernandez authored Apr 14, 2024
2 parents 526f8a4 + bc73fea commit a127ab9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
15 changes: 14 additions & 1 deletion backend/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ pub fn controllers() -> Result<Vec<Controller>> {
&& (device_info.product_id() == xbox::XBOX_ONE_S_CONTROLLER_BT_PRODUCT_ID
|| device_info.product_id() == xbox::XBOX_ONE_S_LATEST_FW_PRODUCT_ID
|| device_info.product_id() == xbox::XBOX_WIRELESS_CONTROLLER_USB_PRODUCT_ID
|| device_info.product_id() == xbox::XBOX_WIRELESS_CONTROLLER_BT_PRODUCT_ID)
|| device_info.product_id() == xbox::XBOX_WIRELESS_CONTROLLER_BT_PRODUCT_ID
|| device_info.product_id() == xbox::XBOX_WIRELESS_ELITE_CONTROLLER_USB_PRODUCT_ID
|| device_info.product_id() == xbox::XBOX_WIRELESS_ELITE_CONTROLLER_BT_PRODUCT_ID
|| device_info.product_id() == xbox::XBOX_WIRELESS_ELITE_CONTROLLER_BTLE_PRODUCT_ID)
})
.collect();
xbox_controllers.dedup_by(|a, b| a.serial_number() == b.serial_number());
Expand All @@ -96,6 +99,16 @@ pub fn controllers() -> Result<Vec<Controller>> {
let controller = xbox::parse_xbox_controller_data(device_info, &hidapi)?;
controllers.push(controller);
}
(xbox::MS_VENDOR_ID, xbox::XBOX_WIRELESS_ELITE_CONTROLLER_BT_PRODUCT_ID) => {
debug!("Found Xbox Elite 2 controller: {:?}", device_info);
let controller = xbox::parse_xbox_controller_data(device_info, &hidapi)?;
controllers.push(controller);
}
(xbox::MS_VENDOR_ID, xbox::XBOX_WIRELESS_ELITE_CONTROLLER_BTLE_PRODUCT_ID) => {
debug!("Found Xbox Elite 2 controller: {:?}", device_info);
let controller = xbox::parse_xbox_controller_data(device_info, &hidapi)?;
controllers.push(controller);
}
_ => {}
}
}
Expand Down
8 changes: 8 additions & 0 deletions backend/src/api/xbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ pub const XBOX_ONE_S_LATEST_FW_PRODUCT_ID: u16 = 0x0b20; // 2848
pub const XBOX_WIRELESS_CONTROLLER_USB_PRODUCT_ID: u16 = 0x0b12; // 2834
pub const XBOX_WIRELESS_CONTROLLER_BT_PRODUCT_ID: u16 = 0x0b13; // 2835

// Xbox Elite Wireless Controller Series 2
pub const XBOX_WIRELESS_ELITE_CONTROLLER_USB_PRODUCT_ID: u16 = 0x0b00;
pub const XBOX_WIRELESS_ELITE_CONTROLLER_BT_PRODUCT_ID: u16 = 0x0b05;
pub const XBOX_WIRELESS_ELITE_CONTROLLER_BTLE_PRODUCT_ID: u16 = 0x0b22;

// pub const XBOX_ONE_REPORT_BT_SIZE: usize = 64;

fn get_xbox_controller_name(product_id: u16) -> &'static str {
Expand All @@ -30,6 +35,9 @@ fn get_xbox_controller_name(product_id: u16) -> &'static str {
XBOX_ONE_S_LATEST_FW_PRODUCT_ID => "Xbox One S",
XBOX_WIRELESS_CONTROLLER_USB_PRODUCT_ID => "Xbox Series X/S",
XBOX_WIRELESS_CONTROLLER_BT_PRODUCT_ID => "Xbox Series X/S",
XBOX_WIRELESS_ELITE_CONTROLLER_USB_PRODUCT_ID => "Xbox Elite 2",
XBOX_WIRELESS_ELITE_CONTROLLER_BT_PRODUCT_ID => "Xbox Elite 2",
XBOX_WIRELESS_ELITE_CONTROLLER_BTLE_PRODUCT_ID => "Xbox Elite 2",
_ => "Xbox Unknown",
}
}
Expand Down

0 comments on commit a127ab9

Please sign in to comment.