Gamepad binds showed in Freeplay's hint
_lastDeviceUsed -> lastDeviceUsed
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package funkin.input;
|
||||
|
||||
import funkin.util.InputUtil;
|
||||
import flixel.input.gamepad.FlxGamepad;
|
||||
import flixel.util.FlxDirectionFlags;
|
||||
import flixel.input.FlxInput.FlxInputState;
|
||||
@@ -381,22 +382,22 @@ class Controls extends FlxActionSet
|
||||
public function getDialogueName(action:FlxActionDigital, ?ignoreSurrounding:Bool = false):String
|
||||
{
|
||||
if (action.inputs.length == 0) return 'N/A';
|
||||
var input = action.inputs[0];
|
||||
var input = FunkinAction.lastDeviceUsed == KEYBOARD ? action.inputs[0] : action.inputs[1];
|
||||
if (ignoreSurrounding == false)
|
||||
{
|
||||
return switch (input.device)
|
||||
return switch (FunkinAction.lastDeviceUsed)
|
||||
{
|
||||
case KEYBOARD: return '[${(input.inputID : FlxKey)}]';
|
||||
case GAMEPAD: return '(${(input.inputID : FlxGamepadInputID)})';
|
||||
case KEYBOARD: return '[${InputUtil.format(input.inputID, Keys).toUpperCase()}]';
|
||||
case GAMEPAD: return '(${InputUtil.format(input.inputID, Gamepad(input.deviceID)).toUpperCase()})';
|
||||
case device: throw 'unhandled device: $device';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return switch (input.device)
|
||||
return switch (FunkinAction.lastDeviceUsed)
|
||||
{
|
||||
case KEYBOARD: return '${(input.inputID : FlxKey)}';
|
||||
case GAMEPAD: return '${(input.inputID : FlxGamepadInputID)}';
|
||||
case KEYBOARD: return InputUtil.format(input.inputID, Keys).toUpperCase();
|
||||
case GAMEPAD: return InputUtil.format(input.inputID, Gamepad(input.deviceID)).toUpperCase();
|
||||
case device: throw 'unhandled device: $device';
|
||||
}
|
||||
}
|
||||
@@ -1203,6 +1204,7 @@ class FunkinAction extends FlxActionDigital
|
||||
*/
|
||||
public function checkPressed():Bool
|
||||
{
|
||||
if (checkFiltered(PRESSED)) updateLastDeviceUsed();
|
||||
return checkFiltered(PRESSED);
|
||||
}
|
||||
|
||||
@@ -1211,6 +1213,7 @@ class FunkinAction extends FlxActionDigital
|
||||
*/
|
||||
public function checkJustPressed():Bool
|
||||
{
|
||||
if (checkFiltered(JUST_PRESSED)) updateLastDeviceUsed();
|
||||
return checkFiltered(JUST_PRESSED);
|
||||
}
|
||||
|
||||
@@ -1227,6 +1230,7 @@ class FunkinAction extends FlxActionDigital
|
||||
*/
|
||||
public function checkJustReleased():Bool
|
||||
{
|
||||
if (checkFiltered(JUST_RELEASED)) updateLastDeviceUsed();
|
||||
return checkFiltered(JUST_RELEASED);
|
||||
}
|
||||
|
||||
@@ -1353,6 +1357,29 @@ class FunkinAction extends FlxActionDigital
|
||||
|
||||
return triggered;
|
||||
}
|
||||
|
||||
public static var lastDeviceUsed:FlxInputDevice;
|
||||
|
||||
/**
|
||||
* Checks which is the last device you have used and stores the value in `lastDeviceUsed`.
|
||||
*/
|
||||
public function updateLastDeviceUsed()
|
||||
{
|
||||
if (FlxG.keys.pressed.ANY)
|
||||
{
|
||||
lastDeviceUsed = FlxInputDevice.KEYBOARD;
|
||||
return;
|
||||
}
|
||||
|
||||
if (FlxG.gamepads.lastActive != null)
|
||||
{
|
||||
lastDeviceUsed = FlxInputDevice.GAMEPAD;
|
||||
return;
|
||||
}
|
||||
|
||||
// Default value (just in case everything's null somehow)
|
||||
lastDeviceUsed = FlxInputDevice.KEYBOARD;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1758,6 +1758,15 @@ class FreeplayState extends MusicBeatSubState
|
||||
handleTouchSelectionScroll(elapsed);
|
||||
#end
|
||||
|
||||
#if FEATURE_TOUCH_CONTROLS
|
||||
if (ControlsHandler.usingExternalInputDevice)
|
||||
charSelectHint.text = 'Press [ ${controls.getDialogueNameFromControl(FREEPLAY_CHAR_SELECT, true)} ] to change characters';
|
||||
else
|
||||
charSelectHint.text = 'Tap the DJ to change characters';
|
||||
#else
|
||||
charSelectHint.text = 'Press [ ${controls.getDialogueNameFromControl(FREEPLAY_CHAR_SELECT, true)} ] to change characters';
|
||||
#end
|
||||
|
||||
handleDirectionalInput(elapsed);
|
||||
|
||||
final wheelAmount:Int = Std.int(FlxMath.bound(FlxG.mouse.wheel, -1, 1));
|
||||
|
||||
@@ -18,7 +18,7 @@ class InputUtil
|
||||
return switch (device)
|
||||
{
|
||||
case Keys: getKeyName(id);
|
||||
case Gamepad(gamepadID): getButtonName(id, FlxG.gamepads.getByID(gamepadID));
|
||||
case Gamepad(gamepadID): FlxG.gamepads.getByID(gamepadID) != null ? getButtonName(id, FlxG.gamepads.getByID(gamepadID)) : 'N/A';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user