Skip to content

Commit

Permalink
add horizontal_dpad and vertical_dpad to VirtualAxis (Leafwing-Studio…
Browse files Browse the repository at this point in the history
  • Loading branch information
adtennant authored May 8, 2023
1 parent 8144259 commit e91f875
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release Notes

## Unreleased

### Usability

- Added `VirtualAxis::horizontal_dpad()` and `VirtualAxis::vertical_dpad()`.

## Version 0.9.2

### Bugs
Expand Down
18 changes: 18 additions & 0 deletions src/axislike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,24 @@ impl VirtualAxis {
positive: InputKind::Keyboard(KeyCode::W),
}
}

#[allow(clippy::doc_markdown)]
/// Generates a [`VirtualAxis`] corresponding to the horizontal DPad buttons on a gamepad.
pub fn horizontal_dpad() -> VirtualAxis {
VirtualAxis {
negative: InputKind::GamepadButton(GamepadButtonType::DPadLeft),
positive: InputKind::GamepadButton(GamepadButtonType::DPadRight),
}
}

#[allow(clippy::doc_markdown)]
/// Generates a [`VirtualAxis`] corresponding to the vertical DPad buttons on a gamepad.
pub fn vertical_dpad() -> VirtualAxis {
VirtualAxis {
negative: InputKind::GamepadButton(GamepadButtonType::DPadDown),
positive: InputKind::GamepadButton(GamepadButtonType::DPadUp),
}
}
}

/// The type of axis used by a [`UserInput`](crate::user_input::UserInput).
Expand Down

0 comments on commit e91f875

Please sign in to comment.