HaxeFlixel / HaxeFlixel/flixel

GamePad input not reset when entering substate

Open
#2,271 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Haxe
Stars
2.2k
Forks
522
Avg merge
34m
Merged PRs (30d)
1

Description

  • Haxe version: 4.0.5
  • Flixel version: latest
  • OpenFL version: latest
  • Lime version: latest
  • Affected targets: Neko, Windows, HTML5...

Code snippet reproducing the issue:
PlayState.hx


import flixel.FlxSubState;
import flixel.FlxG;
import flixel.FlxState;

class PlayState extends FlxState
{
	override public function create():Void
	{
		super.create();
	}

	override public function update(elapsed:Float):Void
	{
		super.update(elapsed);
		if (FlxG.keys.anyJustPressed([ENTER]) || (FlxG.gamepads.lastActive != null && FlxG.gamepads.lastActive.justPressed.START)) {
			openSubState(new PauseSubState());
		}
	}
}

class PauseSubState extends FlxSubState
{

	override public function create():Void
	{
		super.create();
		openCallback = () -> trace("ENTERING PAUSE STATE");
		closeCallback = () -> trace("EXITING PAUSE STATE");
	}

	override public function update(elapsed:Float) {
		super.update(elapsed);
		if (FlxG.gamepads.lastActive.anyJustPressed([START])) trace("START BUTTON IS STILL PRESSED");
		if (FlxG.keys.anyJustPressed([ENTER]) || (FlxG.gamepads.lastActive != null && FlxG.gamepads.lastActive.justPressed.START)) {
			close();
		}
	}
}

Observed behavior:
GamePads input is not reset when entering substate

Expected behavior:
GamePad input should be reset, so it would not trigger substate close.
Keyboard works as expected.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PlayState.hx reproduction and trace gamepad input handling when FlxState opens PauseSubState. Run the example on an affected target and compare the transition with keyboard input. Done means pressing START to enter the pause substate does not immediately trigger its close condition, while keyboard behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.