mirror of
https://github.com/JanNeuendorf/SVC16.git
synced 2025-07-19 00:20:08 +00:00
Mapped the left stick of a gamepad to be used as a DPad
This commit is contained in:
parent
f5ea5b88fe
commit
cea522cee3
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -1813,7 +1813,7 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "svc16"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "svc16"
|
||||
version = "0.7.0"
|
||||
version = "0.7.1"
|
||||
edition = "2021"
|
||||
authors = ["Jan Neuendorf"]
|
||||
description = "An emulator for a simple virtual computer"
|
||||
@ -18,4 +18,5 @@ winit-input-map = {version="0.4.1",optional=true}
|
||||
winit_input_helper = "0.16.0"
|
||||
|
||||
[features]
|
||||
default=[]
|
||||
gamepad = ["gilrs","winit-input-map"]
|
||||
|
26
src/utils.rs
26
src/utils.rs
@ -8,7 +8,7 @@ use winit::{
|
||||
};
|
||||
use winit_input_helper::WinitInputHelper;
|
||||
#[cfg(feature = "gamepad")]
|
||||
use winit_input_map::{input_map, GamepadButton, InputMap};
|
||||
use winit_input_map::{input_map, GamepadAxis, GamepadButton, InputCode, InputMap};
|
||||
|
||||
#[cfg(feature = "gamepad")]
|
||||
#[derive(Debug, std::hash::Hash, PartialEq, Eq, Clone, Copy)]
|
||||
@ -30,10 +30,26 @@ pub fn build_gamepad_map() -> InputMap<NesInput> {
|
||||
(NesInput::B, GamepadButton::South),
|
||||
(NesInput::Select, GamepadButton::Select),
|
||||
(NesInput::Start, GamepadButton::Start),
|
||||
(NesInput::Up, GamepadButton::DPadUp),
|
||||
(NesInput::Down, GamepadButton::DPadDown),
|
||||
(NesInput::Left, GamepadButton::DPadLeft),
|
||||
(NesInput::Right, GamepadButton::DPadRight)
|
||||
(
|
||||
NesInput::Up,
|
||||
GamepadButton::DPadUp,
|
||||
InputCode::gamepad_axis_pos(GamepadAxis::LeftStickY)
|
||||
),
|
||||
(
|
||||
NesInput::Down,
|
||||
GamepadButton::DPadDown,
|
||||
InputCode::gamepad_axis_neg(GamepadAxis::LeftStickY)
|
||||
),
|
||||
(
|
||||
NesInput::Left,
|
||||
GamepadButton::DPadLeft,
|
||||
InputCode::gamepad_axis_neg(GamepadAxis::LeftStickX)
|
||||
),
|
||||
(
|
||||
NesInput::Right,
|
||||
GamepadButton::DPadRight,
|
||||
InputCode::gamepad_axis_pos(GamepadAxis::LeftStickX)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user