bevy_fps_controller
                                
                                
                                
                                    bevy_fps_controller copied to clipboard
                            
                            
                            
                        Add gamepad support
The controller doesn't currently support gamepads. This PR aims to change that!
Currently, keyboard input is broken as the gamepad is overriding the values in FpsControllerInput.
There are two ways of solving this:
- Both input methods need to reach consensus. For example, pressing W on your keyboard and moving the left stick to the left will cause the player to move forward and left.
 - The game should automatically switch between the two input methods (depending on which one received the most recent input)
 
I'm not sure which solution is best, so any input is welcome! (pun not intended)
A quick and dirty change to add input consesus is here:
- input.movement = Vec3::new(move_vec.x, vertical_axis, move_vec.y);
+ input.movement += Vec3::new(move_vec.x, vertical_axis, move_vec.y);
                 ^
- input.sprint = button_input.pressed(button(controller.pad_sprint));
+ input.sprint = input.sprint || button_input.pressed(button(controller.pad_sprint));
                 ^-------------^
- input.jump = button_input.pressed(button(controller.pad_jump));
+ input.jump = input.jump || button_input.pressed(button(controller.pad_jump));
               ^-----------^
- input.fly = button_input.just_pressed(button(controller.pad_fly));
+ input.fly = input.fly || button_input.just_pressed(button(controller.pad_fly));
              ^----------^
- input.crouch = button_input.pressed(button(controller.pad_crouch));
+ input.crouch = input.crouch || button_input.pressed(button(controller.pad_crouch));
                 ^-------------^
This naive implementation is kinda brittle as relies on the gamepad input running after the keyboard input, but it does work.
After asking around online, someone brought up a good point in favour of the input consensus solution.
The Steam Deck and Steam Controller’s touchpads can result in both mouse and joystick input being used simultaneously. Locking down which input is used prevents this from working as intended.
As such, I think the consensus solution would be the way to go.