thombruce / verse

🚀 A universe in progress
Other
8 stars 0 forks source link

Gamepad Support #16

Closed thombruce closed 1 year ago

thombruce commented 1 year ago

I've just added control mapping using the leafwing-input-manager crate here: 363cf31beb37601d5f463aa6e64123b7a6ede46a

The input manager also supports mapping actions to gamepad controls.

I'd like to do two things here:

  1. Map gamepad buttons to the following:
    • Left stick left: Rotate Left
    • Left stick right: Rotate Right
    • Right trigger: Forward
  2. Allow axis to control the intensity of the forward acceleration

For axis inputs, see the example here: https://github.com/Leafwing-Studios/leafwing-input-manager/blob/main/examples/axis_inputs.rs

    if action_state.pressed(Action::Rudder) {
        let value = action_state.clamped_value(Action::Rudder);
        println!("Rudder: {value}");
    }

_Note that left stick is also an axis control. An "axispair" in the example linked above:

    if action_state.pressed(Action::Move) {
        // We're working with gamepads, so we want to defensively ensure that we're using the clamped values
        let axis_pair = action_state.clamped_axis_pair(Action::Move).unwrap();
        println!("Move:");
        println!("   distance: {}", axis_pair.length());
        println!("          x: {}", axis_pair.x());
        println!("          y: {}", axis_pair.y());
    }

If desirable, we could similarly control the rotation intensity using an implementation like that above.

thombruce commented 1 year ago

I'm also thinking about being able to adjust the camera scale using the mouse wheel. What would be a good controller binding for this?

D-pad up and down maybe.

Or zoom levels that are switched between using left bumper.

Those both seem like ergonomic options to me, though I suspect D-pad will be reclaimed for other purposes in a future update.