Official continuation of Destination Sol, the great fun little arcade space shooter from http://sourceforge.net/projects/destinationsol/ Modules live at https://github.com/DestinationSol/
Apache License 2.0
326
stars
123
forks
source link
feat(input): remove fixed keyboard controls from GameOptions #655
This pull request moves the input control constants from GameOptions into a separate DefaultOptions enum. GameOptions has been changed to instead use a dynamic map of controls to their triggering inputs. This should allow for greater extensibility in the future, since modules can now define input controls. There is no way at present to persist the runtime-added controls yet.
An input control consists of an action that can be triggered by any number of input keys. The control itself contains the constant data describing what the control is and how it can be used. Controls are now associated with input types, which can be any of KEYBOARD, MIXED, MOUSE and CONTROLLER. Controls can be associated with multiple input types.
A control can now support an arbitrary number of keys as triggering inputs. This is implemented internally within GameOptions but currently nothing in the game supports it. Changing the input bindings from the main menu will replace all existing bindings for that control with the single binding chosen currently.
Testing
Play the game and make sure that all inputs work as before.
For each input type, try changing the input bindings from the main menu. Ensure that the following operations work as before:
Display input binding
Change input binding
Save input bindings
Reset input bindings to defaults
Restart the game after changing the input bindings and test again. Ensure that the changed inputs have persisted across saves.
Future Improvements
These changes are not happening in this pull request but would be ideal as follow-ups.
Support actually using multiple input bindings within the game e.g. all specified bindings should trigger a button, not just the first one.
Populate the main menu inputs screen dynamically based on the input types specified by the controls.
Allow the user to select both a primary button and a secondary button for each control from the main menu inputs screen.
Notes
This pull request moves all the keyboard input bindings which where previously stored in a series of constant variables. Because of this, reviewers should be aware that copy-paste errors are highly likely.
It might be possible to port Terasology's input system to Destination Sol but that would require a considerably larger effort (and more ECS). This pull request attempts to adapt the existing code to be more future-proof instead.
Description
This pull request moves the input control constants from
GameOptions
into a separateDefaultOptions
enum.GameOptions
has been changed to instead use a dynamic map of controls to their triggering inputs. This should allow for greater extensibility in the future, since modules can now define input controls. There is no way at present to persist the runtime-added controls yet.An input control consists of an action that can be triggered by any number of input keys. The control itself contains the constant data describing what the control is and how it can be used. Controls are now associated with input types, which can be any of
KEYBOARD
,MIXED
,MOUSE
andCONTROLLER
. Controls can be associated with multiple input types.A control can now support an arbitrary number of keys as triggering inputs. This is implemented internally within
GameOptions
but currently nothing in the game supports it. Changing the input bindings from the main menu will replace all existing bindings for that control with the single binding chosen currently.Testing
Future Improvements
These changes are not happening in this pull request but would be ideal as follow-ups.
Notes