Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/drivers/horipad_steam/hid_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ pub struct PackedInputDataReport {

// bytes 12-17 // Gyro
#[packed_field(bytes = "12..=13", endian = "lsb")]
pub roll: Integer<i16, packed_bits::Bits<16>>,
#[packed_field(bytes = "14..=15", endian = "lsb")]
pub yaw: Integer<i16, packed_bits::Bits<16>>,
#[packed_field(bytes = "14..=15", endian = "lsb")]
pub roll: Integer<i16, packed_bits::Bits<16>>,
#[packed_field(bytes = "16..=17", endian = "lsb")]
pub pitch: Integer<i16, packed_bits::Bits<16>>,
// bytes 18-23 // Accelerometer
Expand Down Expand Up @@ -187,8 +187,8 @@ impl Default for PackedInputDataReport {
rt_analog: 0,
lt_analog: 0,
tick: Integer::from_primitive(0),
roll: Integer::from_primitive(0),
yaw: Integer::from_primitive(0),
roll: Integer::from_primitive(0),
pitch: Integer::from_primitive(0),
accel_z: Integer::from_primitive(0),
accel_y: Integer::from_primitive(0),
Expand Down
23 changes: 17 additions & 6 deletions src/input/target/horipad_steam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,22 @@ impl HoripadSteamDevice {
Ok(vec![])
}

/// Handle [OutputEvent::GetReport] events from the HIDRAW device
/// Handle [OutputEvent::GetReport] events from the HIDRAW device.
/// Reply immediately to prevent UHID GET_REPORT timeout (~5s per request)
/// which would cause long delays when consumers like Steam probe the device.
fn handle_get_report(
&mut self,
_id: u32,
_report_number: u8,
id: u32,
report_number: u8,
_report_type: uhid_virt::ReportType,
) -> Result<(), Box<dyn Error>> {
log::debug!(
"Received GetReport request: id: {id}, report_number: {report_number}"
);
if let Err(e) = self.device.write_get_report_reply(id, 1, vec![]) {
log::warn!("Failed to write get report reply: {:?}", e);
return Err(e.to_string().into());
}
Ok(())
}
}
Expand Down Expand Up @@ -522,9 +531,11 @@ fn denormalize_accel_value(value_meters_sec: f64) -> i16 {
value as i16
}

/// Horipad gyro values are measured in units of degrees per second.
/// InputPlumber gyro values are also measured in degrees per second.
/// SDL negates all gyro axes when reading from this device (SDL_hidapi_steam_hori.c L329-331):
/// imu_data[N] = -1.0f * LOAD16(data[...])
/// We invert here so that SDL produces the correct sign after its negation.
/// https://github.com/libsdl-org/SDL/blob/main/src/joystick/hidapi/SDL_hidapi_steam_hori.c#L329-L331
fn denormalize_gyro_value(value_degrees_sec: f64) -> i16 {
let value = value_degrees_sec;
let value = -value_degrees_sec;
value as i16
}