mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-12-10 05:59:15 +00:00
fix char select inputs for keyb and controllers
This commit is contained in:
parent
71bc847698
commit
a12950d5a7
|
|
@ -1267,6 +1267,8 @@ class FunkinAction extends FlxActionDigital
|
|||
public var namePressed(default, null):Null<String>;
|
||||
public var nameReleased(default, null):Null<String>;
|
||||
|
||||
var cache:Map<String, {timestamp:Int, value:Bool}> = [];
|
||||
|
||||
public function new(?name:String = "", ?namePressed:String, ?nameReleased:String)
|
||||
{
|
||||
super(name);
|
||||
|
|
@ -1386,7 +1388,13 @@ class FunkinAction extends FlxActionDigital
|
|||
public function checkFiltered(?filterTrigger:FlxInputState, ?filterDevice:FlxInputDevice):Bool
|
||||
{
|
||||
// Make sure we only update the inputs once per frame.
|
||||
if (_timestamp == FlxG.game.ticks) return triggered; // run no more than once per frame
|
||||
var key = '${filterTrigger}:${filterDevice}';
|
||||
var cacheEntry = cache.get(key);
|
||||
|
||||
if (cacheEntry != null && cacheEntry.timestamp == FlxG.game.ticks)
|
||||
{
|
||||
return cacheEntry.value;
|
||||
}
|
||||
|
||||
_x = null;
|
||||
_y = null;
|
||||
|
|
@ -1428,6 +1436,8 @@ class FunkinAction extends FlxActionDigital
|
|||
}
|
||||
}
|
||||
|
||||
cache.set(key, {timestamp: FlxG.game.ticks, value: triggered});
|
||||
|
||||
return triggered;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -730,6 +730,7 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
var holdTmrLeft:Float = 0;
|
||||
var holdTmrRight:Float = 0;
|
||||
var spamDirections:FlxDirectionFlags = NONE;
|
||||
var initSpam = 0.5;
|
||||
|
||||
var mobileDeny:Bool = false;
|
||||
var mobileAccept:Bool = false;
|
||||
|
|
@ -782,41 +783,6 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
}
|
||||
#end
|
||||
|
||||
if (controls.UI_UP) holdTmrUp += elapsed;
|
||||
if (controls.UI_UP_R)
|
||||
{
|
||||
holdTmrUp = 0;
|
||||
spamDirections = spamDirections.without(UP);
|
||||
}
|
||||
|
||||
if (controls.UI_DOWN) holdTmrDown += elapsed;
|
||||
if (controls.UI_DOWN_R)
|
||||
{
|
||||
holdTmrDown = 0;
|
||||
spamDirections = spamDirections.without(DOWN);
|
||||
}
|
||||
|
||||
if (controls.UI_LEFT) holdTmrLeft += elapsed;
|
||||
if (controls.UI_LEFT_R)
|
||||
{
|
||||
holdTmrLeft = 0;
|
||||
spamDirections = spamDirections.without(LEFT);
|
||||
}
|
||||
|
||||
if (controls.UI_RIGHT) holdTmrRight += elapsed;
|
||||
if (controls.UI_RIGHT_R)
|
||||
{
|
||||
holdTmrRight = 0;
|
||||
spamDirections = spamDirections.without(RIGHT);
|
||||
}
|
||||
|
||||
var initSpam = 0.5;
|
||||
|
||||
if (holdTmrUp >= initSpam) spamDirections = spamDirections.with(UP);
|
||||
if (holdTmrDown >= initSpam) spamDirections = spamDirections.with(DOWN);
|
||||
if (holdTmrLeft >= initSpam) spamDirections = spamDirections.with(LEFT);
|
||||
if (holdTmrRight >= initSpam) spamDirections = spamDirections.with(RIGHT);
|
||||
|
||||
if (controls.UI_UP_P)
|
||||
{
|
||||
cursorY -= 1;
|
||||
|
|
@ -849,6 +815,39 @@ class CharSelectSubState extends MusicBeatSubState
|
|||
selectSound.play(true);
|
||||
}
|
||||
|
||||
if (controls.UI_UP) holdTmrUp += elapsed;
|
||||
if (controls.UI_UP_R || !controls.UI_UP)
|
||||
{
|
||||
holdTmrUp = 0;
|
||||
spamDirections = spamDirections.without(UP);
|
||||
}
|
||||
|
||||
if (controls.UI_DOWN) holdTmrDown += elapsed;
|
||||
if (controls.UI_DOWN_R || !controls.UI_DOWN)
|
||||
{
|
||||
holdTmrDown = 0;
|
||||
spamDirections = spamDirections.without(DOWN);
|
||||
}
|
||||
|
||||
if (controls.UI_LEFT) holdTmrLeft += elapsed;
|
||||
if (controls.UI_LEFT_R || !controls.UI_LEFT)
|
||||
{
|
||||
holdTmrLeft = 0;
|
||||
spamDirections = spamDirections.without(LEFT);
|
||||
}
|
||||
|
||||
if (controls.UI_RIGHT) holdTmrRight += elapsed;
|
||||
if (controls.UI_RIGHT_R || !controls.UI_RIGHT)
|
||||
{
|
||||
holdTmrRight = 0;
|
||||
spamDirections = spamDirections.without(RIGHT);
|
||||
}
|
||||
|
||||
if (holdTmrUp >= initSpam) spamDirections = spamDirections.with(UP);
|
||||
if (holdTmrDown >= initSpam) spamDirections = spamDirections.with(DOWN);
|
||||
if (holdTmrLeft >= initSpam) spamDirections = spamDirections.with(LEFT);
|
||||
if (holdTmrRight >= initSpam) spamDirections = spamDirections.with(RIGHT);
|
||||
|
||||
if (controls.BACK_P) goBack();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue