Skip to content

Commit

Permalink
fix(Capability): Ensure HAT0-HAT3 are avaialable.
Browse files Browse the repository at this point in the history
  • Loading branch information
pastaq committed Jul 16, 2024
1 parent 6726b7f commit 4de18fe
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 6 deletions.
26 changes: 26 additions & 0 deletions rootfs/usr/share/inputplumber/profiles/mouse_keyboard_wasd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,32 @@ mapping:
target_events:
- dbus: ui_quick

# Dpad
- name: D-Up
source_event:
gamepad:
button: DPadUp
target_events:
- keyboard: KeyUp
- name: D-Down
source_event:
gamepad:
button: DPadDown
target_events:
- keyboard: KeyDown
- name: D-Left
source_event:
gamepad:
button: DPadLeft
target_events:
- keyboard: KeyLeft
- name: D-Right
source_event:
gamepad:
button: DPadRight
target_events:
- keyboard: KeyRight

# Left Stick
- name: Left
source_event:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
"enum": [
"LeftStick",
"RightStick",
"Hat0",
"Hat1",
"Hat2",
"Hat3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@
"enum": [
"LeftStick",
"RightStick",
"Hat0",
"Hat1",
"Hat2",
"Hat3"
Expand Down
3 changes: 3 additions & 0 deletions src/input/capability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ impl FromStr for GamepadButton {
pub enum GamepadAxis {
LeftStick,
RightStick,
Hat0,
Hat1,
Hat2,
Hat3,
Expand All @@ -525,6 +526,7 @@ impl fmt::Display for GamepadAxis {
match self {
GamepadAxis::LeftStick => write!(f, "LeftStick"),
GamepadAxis::RightStick => write!(f, "RightStick"),
GamepadAxis::Hat0 => write!(f, "Hat0"),
GamepadAxis::Hat1 => write!(f, "Hat1"),
GamepadAxis::Hat2 => write!(f, "Hat2"),
GamepadAxis::Hat3 => write!(f, "Hat3"),
Expand All @@ -540,6 +542,7 @@ impl FromStr for GamepadAxis {
match s {
"LeftStick" => Ok(GamepadAxis::LeftStick),
"RightStick" => Ok(GamepadAxis::RightStick),
"Hat0" => Ok(GamepadAxis::Hat0),
"Hat1" => Ok(GamepadAxis::Hat1),
"Hat2" => Ok(GamepadAxis::Hat2),
"Hat3" => Ok(GamepadAxis::Hat3),
Expand Down
2 changes: 1 addition & 1 deletion src/input/event/dbus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ fn actions_from_capability(capability: Capability) -> Vec<Action> {
GamepadAxis::LeftStick => {
vec![Action::Left, Action::Right, Action::Up, Action::Down]
}
GamepadAxis::Hat1 => {
GamepadAxis::Hat0 => {
vec![Action::Left, Action::Right, Action::Up, Action::Down]
}
GamepadAxis::Buttons(negative, positive) => {
Expand Down
9 changes: 6 additions & 3 deletions src/input/event/evdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -623,15 +623,18 @@ fn event_codes_from_capability(capability: Capability) -> Vec<u16> {
GamepadAxis::RightStick => {
vec![AbsoluteAxisCode::ABS_RX.0, AbsoluteAxisCode::ABS_RY.0]
}
GamepadAxis::Hat1 => {
GamepadAxis::Hat0 => {
vec![AbsoluteAxisCode::ABS_HAT0X.0, AbsoluteAxisCode::ABS_HAT0Y.0]
}
GamepadAxis::Hat2 => {
GamepadAxis::Hat1 => {
vec![AbsoluteAxisCode::ABS_HAT1X.0, AbsoluteAxisCode::ABS_HAT1Y.0]
}
GamepadAxis::Hat3 => {
GamepadAxis::Hat2 => {
vec![AbsoluteAxisCode::ABS_HAT2X.0, AbsoluteAxisCode::ABS_HAT2Y.0]
}
GamepadAxis::Hat3 => {
vec![AbsoluteAxisCode::ABS_HAT3X.0, AbsoluteAxisCode::ABS_HAT3Y.0]
}
GamepadAxis::Buttons(_, _) => {
vec![AbsoluteAxisCode::ABS_HAT0X.0, AbsoluteAxisCode::ABS_HAT0Y.0]
}
Expand Down
3 changes: 2 additions & 1 deletion src/input/target/dualsense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ impl DualSenseDevice {
}
}
}
GamepadAxis::Hat1 => {
GamepadAxis::Hat0 => {
if let InputValue::Vector2 { x, y } = value {
if let Some(x) = x {
let value = denormalize_signed_value(x, -1.0, 1.0);
Expand Down Expand Up @@ -1480,6 +1480,7 @@ impl DualSenseDevice {
}
}
}
GamepadAxis::Hat1 => (),
GamepadAxis::Hat2 => (),
GamepadAxis::Hat3 => (),
// TODO: Remove GamepadAxis::Buttons
Expand Down
3 changes: 2 additions & 1 deletion src/input/target/steam_deck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ impl SteamDeckDevice {
y,
} => (),
},
GamepadAxis::Hat1 => match value {
GamepadAxis::Hat0 => match value {
InputValue::None => (),
InputValue::Bool(_) => (),
InputValue::Float(_) => (),
Expand Down Expand Up @@ -405,6 +405,7 @@ impl SteamDeckDevice {
y: _,
} => (),
},
GamepadAxis::Hat1 => (),
GamepadAxis::Hat2 => (),
GamepadAxis::Hat3 => (),
GamepadAxis::Buttons(_, _) => (),
Expand Down

0 comments on commit 4de18fe

Please sign in to comment.