Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completely rework the input subsystem #235

Merged
merged 10 commits into from
Jul 19, 2021
Merged

Completely rework the input subsystem #235

merged 10 commits into from
Jul 19, 2021

Conversation

Plombo
Copy link
Collaborator

@Plombo Plombo commented Jul 19, 2021

This is it: the big input rework. The platform-specific control code for SDL and Wii has been completely rewritten. Input devices are now assigned to individual players, controller hotplugging is handled gracefully, and it is easy to reassign which player uses which device. This should fix most of the control issues people have traditionally had with OpenBOR. The days of OpenBOR treating all input devices like pieces of a giant imaginary keyboard are over!

The new input subsystem works very well on Windows/Linux. I haven't been able to test controller support on Android, but these changes at least don't break the regular touch-based input system. The Wii implementation is in worse shape; it is still incomplete and buggy, and will need someone to improve it in the future.

Plombo added 10 commits July 19, 2021 13:39
This is a big one. Rework the input interface to have the concept of
separate input devices instead of treating all input devices like
extensions of a giant keyboard. A single input device is now assigned to
each player.

The rewrite of the SDL input code also adds support for the SDL game
controller (XInput) interface, so XInput-compatible controllers can have
sane default mappings.

There are some things incomplete (saving/loading control mappings,
reassigning devices to players) but games are playable.

This change will break consoles until their input code is rewritten. It
probably also breaks Android, but hopefully it will not be too hard to
fix since Android-specific code has been taken from the original
control.c.
Control mappings are now saved to a separate file from the main save
data.
When changing the input config for a button, it would pick up the newly
configured button as a "newly pressed button" on the next update, so it
would go right back into waiting for a button press again.
Now the only way to cancel out of input config when it's waiting for a
key/button press is for another player to press "cancel".
It compiles and runs now, but control config doesn't pick up on-screen
button presses yet.
This isn't super useful since on-screen buttons are actually mapped
directly to directions, Jump, Special, Attack 1, etc. But it's better
than having to cancel out of control config with the Esc button.
SDL uses the joystick interface to expose the functionality of the
accelerometer on Android devices. Since the accelerometer is not
actually a joystick/controller, blacklist it from being counted as an
input device.
The implementation is buggy and incomplete, but it at least compiles and
runs okay.
@Plombo Plombo requested a review from DCurrent as a code owner July 19, 2021 20:08
Copy link
Owner

@DCurrent DCurrent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thanks @Plombo!

@Plombo Plombo merged commit 3caaddd into master Jul 19, 2021
@Darknior
Copy link

Impressive update :)

For my part we are patching OB to make the INI readable by a human, to make it easier to integrate in a system, to use OB like any other emulator or game engine ...
It help us to script in python the controller support, to respect our mapping, our controller order etc ....

Do you think it can be possible to add it officially too ?
For sure having a readable ini file is better and will help other users ...
It is fine to encode the save files, for sure, but the ini file is not really fine i think.

@Darknior
Copy link

#236

@fgames9000
Copy link
Collaborator

I did a quick test, the automatic controller detection is fantastic. But it seems that some buttons are not working and others are inverted.
I will continue testing to send more exact feedback.

@DCurrent DCurrent deleted the input-rework-rebased branch August 24, 2021 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants