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

Rudimentary Gamepad Recording and Loading Support for FlxReplay #3330

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

agmass
Copy link

@agmass agmass commented Jan 5, 2025

Adds support for recording and loading gamepad inputs inside FlxReplay-s, so far only support button and analog inputs.
Analog Inputs are always recorded even when 0 which may cause a small jump in replay file size when having multiple gamepad inputs connected. There are a few areas where I touch FlxGamepad and FlxGamepadManager that could seem a bit sketchy, but i'm not aware of any other ways to get this to work. Tested on CPP and HTML5

@Geokureli
Copy link
Member

Geokureli commented Jan 5, 2025

Could you share a little test state that would allow me to verify its accuracy? Perhaps we can add Gampad controls to the Replay demo?

Analog Inputs are always recorded even when 0 which may cause a small jump in replay file size when having multiple gamepad inputs connected.

Could we get this to behave like keyboard? where zero values are ignored?

@agmass
Copy link
Author

agmass commented Jan 5, 2025

Could you share a little test state that would allow me to verify its accuracy? Perhaps we can add Gampad controls to the Replay demo?

I've been testing this on my own game with a bit more bloat, but here's a small video showing the system (the player marked in red is using a gamepad):

2025-01-05.19-54-42.mp4

The debug text on the right has a "Input" section showing the exact input from the gamepad/demo, as some are ignored

Could we get this to behave like keyboard? where zero values are ignored?

I realize I can just clear the axis array ever frame and leave out zero-d inputs from being saved, I'll try to make something now to get this working

Comment on lines +713 to +721
if (recording)
{
if (AxisID < 0 || AxisID >= axis.length)
{
return 0;
}
return axis[AxisID];
}

Copy link
Member

Choose a reason for hiding this comment

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

Can you talk about why this is needed?

Copy link
Author

@agmass agmass Jan 5, 2025

Choose a reason for hiding this comment

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

I'm editing the axis list upon playback (i'm not entirely sure if there's a better way to edit the axises of a gamepad, that's just what i was able to find) but if i don't specify the gamepad has to find it's axis from there, the gamepad will pull it directly from the input device. Along with this, the recording could double-up the axis flip as getAxisValue() flips it once during playback and could flip it again if called raw when recording. I wasn't sure if making a new variable inside FlxGamepad or making a new class overriding this was the better choice

@Geokureli
Copy link
Member

Also can you post an example of the string data?

@agmass
Copy link
Author

agmass commented Jan 5, 2025

Also can you post an example of the string data?

image
after the commit trimming down the size by not including all axis, even when disabled

everything past "/" is axis output, everything before is button output. the key with no value at the start of the list is the gamepad's id

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.

2 participants