allegroflare / allegro_flare

Application toolkit for Allegro 5
https://clubcatt.com/allegroflare
MIT License
36 stars 6 forks source link

Refactor Internal Configurability of Input Devices #254

Closed MarkOates closed 1 year ago

MarkOates commented 1 year ago

Problem

Currently, input configuration is unfinished. This includes joystick support, keyboard remapping, etc. While there are classes that represent basic concepts, the design has not solidified for real-world use. If a player wanted to customize the buttons on their controls, seamlessly use a joystick, or, if the developer wanted to support different controller types, those options are not yet available.

More info available on the Project Doc.

Solution

This PR adds new essential classes. Also included are some modifications/refactors to integrate these new classes.

Key elements are:

Mapping

Also introduced is an explicit mapping class PhysicalInputDeviceToVirtualControllerMapping. This is an association class that contains pointers to player, a physical input device, the virtual input device, and then contains a mapping between the two devices.

When initializing VirtualControlProcessor, a "reasonable" mapping is automatically created. For now, this will preserve the previous routing and controller mapping behaviour that is currently present in the system, so nothing should break. (Note the signature of the virtual control functions will change, see blow). In the future, the mapping may need to be created explicitly rather than implicitly during initialize(). If that's the case then helper functions will be made available.

Deprecated Features, Required Upgrades

⚠️ This change will likely break build on some projects. Please update signatures for the following functions:

MarkOates commented 1 year ago

Going to merge this quickly to formalize the classes.