improve support for gamepads - #7655
Conversation
|
Setting as draft for further testing and due to it conflicting with other pending PRs because of added XSTRs. It might be necessary to split the gamepad navigation support into a separate PR for further refinement and testing if feedback warrants it. |
|
Gamepad navigation is enabled by default but can be disabled with settings (in-game or ini). As the Freespace UI system doesn't lend itself all that well for more up-to-date gamepad support the inputs instead mimic mouse and keyboard inputs. Mouse is controlled by the Left Stick. The Action button (A/Cross) simulates left mouse button, and the X/Square button simulates the right mouse button. Keyboard inputs mimicked are: Escape (Cancel - B/Circle), Up/down/left/right arrows keys (D-Pad), Shift-TAB (L1), TAB (L2), PageDown (LT), PageUp (RT). Presumably mods using SCPUI could use that info to create easy to navigate menus using those keyboard controls, therefore making them gamepad friendly as well. Gamepad navigation for in-game settings and the Lab are default for imgui (above mappings are ignored in that case). Imgui mappings can be found here. The exception is the Lab, where the Right Stick, LT, and RT can be used to manipulate the object/camera. Exact controls are in the appropriate help window in the Lab. |
d779a2f to
6a0d178
Compare
Use the SDL gamepad API to add full gamepad support. Adds rumble for supported gamepads and changes the FF in-game options to take immediate effect instead of requiring a restart. Additionally this makes changes to allow gamepad triggers to be used as both an axis and a button. This support is specific to gamepads since we can explicitly identify the trigger with the API and act on it accordingly. FSO control config doesn't currently support such an action directly however so we have to hack it in just a bit. Due to this the control binding will show the trigger axis name bound to a button control only while a gamepad is connected, otherwise it shows a button name associated with the trigger.
Gamepad navigation is enabled by default but can be disabled with settings. As the retail FreeSpace UI system doesn't lend itself all that well to proper gamepad mechanics, the gamepad inputs instead mimic a mouse and keyboard. Gamepad navigation is only active when at least one gamepad is connected and the mouse cursor is set to visible in the game. One exception is gamepad camera controls, where no cursor check is performed. A gamepad does NOT need to be set as a current joystick in order to work for navigation. When gamepad navigation is initialized it also enables Dear ImGui gamepad navigation. While in the Lab or In-game Settings the ImGui gamepad navigation layout will be used instead of the normal FreeSpace-style navigation layout. FreeSpace gamepad navigation layout: Mouse -------- The cursor is controlled via the Left Stick. Left click is simulated via the Action button (A / Cross, by default) Right click is simulated via the X / Square button Keyboard --------- Although they are used inconsistently, with usage and purpose occasionally varying between different menus, the retail UI code generally uses the following keyboard keys for navigation: The ESC key is simulated via the Cancel button (B / Circle, by default) The Arrow keys are simulated via D-Pad The TAB key is simulated via the Right Shoulder button The Shift-TAB combo is simulated via the Left Shoulder button The Page Down key is simulated via the Left Trigger The Page Up key is simulated via the Right Trigger Dear ImGui gamepad navigation: The gamepad is supported directly without simulating Mouse/Keyboard inputs. ImGui control layout infographics are available at: https://www.dearimgui.com/controls_sheets/ Camera controls (used in the Lab & chosen to not conflict with ImGui): Right Stick: Orient the displayed object Right Stick + Left Trigger: Rotate the camera Right Stick + Right Trigger: Zoom the camera in or out Right Stick + Both Triggers: Pan the camera on the X/Y plane
6a0d178 to
21d9757
Compare
Make use of the SDL gamepad API to improve support for gamepads. Also adds support for rumble, triggers as buttons, and ui navigation (leanback).
NOTE: This is a semi-breaking change as control bindings for gamepads can change compared to older builds.