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

Fix firstPressed functions in FlxGamepad #2728

Merged
merged 1 commit into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions flixel/input/gamepad/FlxGamepad.hx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,11 @@ class FlxGamepad implements IFlxDestroyable
*/
public inline function firstPressedID():FlxGamepadInputID
{
return mapping.getID(firstPressedRawID());
var id = firstPressedRawID();
if (id < 0)
return id;

return mapping.getID(id);
}

/**
Expand All @@ -460,7 +464,7 @@ class FlxGamepad implements IFlxDestroyable
{
for (button in buttons)
{
if (button != null && button.released)
if (button != null && button.pressed)
{
return button.ID;
}
Expand All @@ -474,7 +478,11 @@ class FlxGamepad implements IFlxDestroyable
*/
public inline function firstJustPressedID():FlxGamepadInputID
{
return mapping.getID(firstJustPressedRawID());
var id = firstJustPressedRawID();
if (id < 0)
return id;

return mapping.getID(id);
}

/**
Expand All @@ -499,7 +507,11 @@ class FlxGamepad implements IFlxDestroyable
*/
public inline function firstJustReleasedID():FlxGamepadInputID
{
return mapping.getID(firstJustReleasedRawID());
var id = firstJustReleasedRawID();
if (id < 0)
return id;

return mapping.getID(id);
}

/**
Expand Down