libultraship icon indicating copy to clipboard operation
libultraship copied to clipboard

[WIP] Expansion of button controls for intent-based control modifications

Open cclark25 opened this issue 8 months ago • 4 comments

This PR contains code I have written for a controls mod for the 2ship2harkinian application, and I wanted to share it here in case it is useful to anyone else. Currently it is branched off of the commit used by 2ship. This corresponding branch of 2ship uses these changes: https://github.com/cclark25/2ship2harkinian/tree/IntentControls

The primary goal of this branch is to allow the addition of an arbitrary number of button controls, for the sake of defining controls based on their intended usage rather than a set of limited global buttons. For example, instead of a game using the A button for jump, roll, and talk, this will instead allow each of those controls to be optionally defined separately for more granular control mapping. This is currently very difficult in the libultraship library because all buttons are defined as a 16bit bitmask, only allowing 16 unique buttons. This PR addresses that by adding on special button mapping functionality, which utilizes a separate 16bit button ID value and 8bit "pressed" state to track whether a button is pressed or not. This effectively allows up to 2^16 - 1 (0 is reserved) additional buttons.

In addition, these control checks will be managed by a collection of function pointers, allowing the special control logic to be customized and swapped in/out per controller.

These code changes are currently functional.

cclark25 avatar Jun 18 '24 00:06 cclark25