gamepad support and keybind cleaning up

This commit is contained in:
Kade M 2021-06-24 19:54:11 -07:00
parent 5432d66601
commit 06ca64b5d8
13 changed files with 424 additions and 150 deletions

View File

@ -1,5 +1,6 @@
package; package;
import flixel.input.gamepad.FlxGamepad;
import flixel.FlxG; import flixel.FlxG;
import flixel.input.FlxInput; import flixel.input.FlxInput;
import flixel.input.actions.FlxAction; import flixel.input.actions.FlxAction;
@ -571,8 +572,22 @@ class Controls extends FlxActionSet
//trace(FlxKey.fromString(FlxG.save.data.upBind)); //trace(FlxKey.fromString(FlxG.save.data.upBind));
removeKeyboard(); removeKeyboard();
if (gamepadsAdded.length != 0)
removeGamepad();
KeyBinds.keyCheck(); KeyBinds.keyCheck();
var buttons = new Map<Control,Array<FlxGamepadInputID>>();
buttons.set(Control.UP,[FlxGamepadInputID.fromString(FlxG.save.data.gpupBind)]);
buttons.set(Control.LEFT,[FlxGamepadInputID.fromString(FlxG.save.data.gpleftBind)]);
buttons.set(Control.DOWN,[FlxGamepadInputID.fromString(FlxG.save.data.gpdownBind)]);
buttons.set(Control.RIGHT,[FlxGamepadInputID.fromString(FlxG.save.data.gprightBind)]);
buttons.set(Control.ACCEPT,[FlxGamepadInputID.A]);
buttons.set(Control.BACK,[FlxGamepadInputID.B]);
buttons.set(Control.PAUSE,[FlxGamepadInputID.START]);
addGamepad(0,buttons);
inline bindKeys(Control.UP, [FlxKey.fromString(FlxG.save.data.upBind), FlxKey.UP]); inline bindKeys(Control.UP, [FlxKey.fromString(FlxG.save.data.upBind), FlxKey.UP]);
inline bindKeys(Control.DOWN, [FlxKey.fromString(FlxG.save.data.downBind), FlxKey.DOWN]); inline bindKeys(Control.DOWN, [FlxKey.fromString(FlxG.save.data.downBind), FlxKey.DOWN]);
inline bindKeys(Control.LEFT, [FlxKey.fromString(FlxG.save.data.leftBind), FlxKey.LEFT]); inline bindKeys(Control.LEFT, [FlxKey.fromString(FlxG.save.data.leftBind), FlxKey.LEFT]);
@ -599,6 +614,9 @@ class Controls extends FlxActionSet
public function addGamepad(id:Int, ?buttonMap:Map<Control, Array<FlxGamepadInputID>>):Void public function addGamepad(id:Int, ?buttonMap:Map<Control, Array<FlxGamepadInputID>>):Void
{ {
if (gamepadsAdded.contains(id))
gamepadsAdded.remove(id);
gamepadsAdded.push(id); gamepadsAdded.push(id);
#if (haxe >= "4.0.0") #if (haxe >= "4.0.0")

View File

@ -177,7 +177,7 @@ class DialogueBox extends FlxSpriteGroup
dialogueStarted = true; dialogueStarted = true;
} }
if (FlxG.keys.justPressed.ANY && dialogueStarted == true) if (PlayerSettings.player1.controls.ACCEPT && dialogueStarted == true)
{ {
remove(dialogue); remove(dialogue);

View File

@ -1,5 +1,6 @@
package; package;
import flixel.input.gamepad.FlxGamepad;
import flash.text.TextField; import flash.text.TextField;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxSprite; import flixel.FlxSprite;
@ -184,10 +185,32 @@ class FreeplayState extends MusicBeatState
scoreText.text = "PERSONAL BEST:" + lerpScore; scoreText.text = "PERSONAL BEST:" + lerpScore;
comboText.text = combo + '\n'; comboText.text = combo + '\n';
var upP = controls.UP_P; var upP = FlxG.keys.justPressed.UP;
var downP = controls.DOWN_P; var downP = FlxG.keys.justPressed.DOWN;
var accepted = controls.ACCEPT; var accepted = controls.ACCEPT;
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.DPAD_UP)
{
changeSelection(-1);
}
if (gamepad.justPressed.DPAD_DOWN)
{
changeSelection(1);
}
if (gamepad.justPressed.DPAD_LEFT)
{
changeDiff(-1);
}
if (gamepad.justPressed.DPAD_RIGHT)
{
changeDiff(1);
}
}
if (upP) if (upP)
{ {
changeSelection(-1); changeSelection(-1);
@ -197,9 +220,9 @@ class FreeplayState extends MusicBeatState
changeSelection(1); changeSelection(1);
} }
if (controls.LEFT_P) if (FlxG.keys.justPressed.LEFT)
changeDiff(-1); changeDiff(-1);
if (controls.RIGHT_P) if (FlxG.keys.justPressed.RIGHT)
changeDiff(1); changeDiff(1);
if (controls.BACK) if (controls.BACK)

View File

@ -1,3 +1,4 @@
import flixel.input.gamepad.FlxGamepad;
import openfl.Lib; import openfl.Lib;
import flixel.FlxG; import flixel.FlxG;
@ -92,6 +93,10 @@ class KadeEngineData
if (FlxG.save.data.optimize == null) if (FlxG.save.data.optimize == null)
FlxG.save.data.optimize = false; FlxG.save.data.optimize = false;
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
KeyBinds.gamepad = gamepad != null;
Conductor.recalculateTimings(); Conductor.recalculateTimings();
PlayerSettings.player1.controls.loadKeyBinds(); PlayerSettings.player1.controls.loadKeyBinds();

View File

@ -3,6 +3,7 @@ package;
/// Code created by Rozebud for FPS Plus (thanks rozebud) /// Code created by Rozebud for FPS Plus (thanks rozebud)
// modified by KadeDev for use in Kade Engine/Tricky // modified by KadeDev for use in Kade Engine/Tricky
import flixel.input.gamepad.FlxGamepad;
import flixel.util.FlxAxes; import flixel.util.FlxAxes;
import flixel.FlxSubState; import flixel.FlxSubState;
import Options.Option; import Options.Option;
@ -36,15 +37,19 @@ class KeyBindMenu extends FlxSubState
var warningTween:FlxTween; var warningTween:FlxTween;
var keyText:Array<String> = ["LEFT", "DOWN", "UP", "RIGHT"]; var keyText:Array<String> = ["LEFT", "DOWN", "UP", "RIGHT"];
var defaultKeys:Array<String> = ["A", "S", "W", "D", "R"]; var defaultKeys:Array<String> = ["A", "S", "W", "D", "R"];
var defaultGpKeys:Array<String> = ["DPAD_LEFT", "DPAD_DOWN", "DPAD_UP", "DPAD_RIGHT"];
var curSelected:Int = 0; var curSelected:Int = 0;
var keys:Array<String> = [FlxG.save.data.leftBind, var keys:Array<String> = [FlxG.save.data.leftBind,
FlxG.save.data.downBind, FlxG.save.data.downBind,
FlxG.save.data.upBind, FlxG.save.data.upBind,
FlxG.save.data.rightBind]; FlxG.save.data.rightBind];
var gpKeys:Array<String> = [FlxG.save.data.gpleftBind,
FlxG.save.data.gpdownBind,
FlxG.save.data.gpupBind,
FlxG.save.data.gprightBind];
var tempKey:String = ""; var tempKey:String = "";
var blacklist:Array<String> = ["ESCAPE", "ENTER", "BACKSPACE", "SPACE"]; var blacklist:Array<String> = ["ESCAPE", "ENTER", "BACKSPACE", "SPACE", "TAB"];
var blackBox:FlxSprite; var blackBox:FlxSprite;
var infoText:FlxText; var infoText:FlxText;
@ -60,10 +65,17 @@ class KeyBindMenu extends FlxSubState
if (k == null) if (k == null)
keys[i] = defaultKeys[i]; keys[i] = defaultKeys[i];
} }
for (i in 0...gpKeys.length)
{
var k = gpKeys[i];
if (k == null)
gpKeys[i] = defaultGpKeys[i];
}
//FlxG.sound.playMusic('assets/music/configurator' + TitleState.soundExt); //FlxG.sound.playMusic('assets/music/configurator' + TitleState.soundExt);
persistentUpdate = persistentDraw = true; persistentUpdate = true;
keyTextDisplay = new FlxText(-10, 0, 1280, "", 72); keyTextDisplay = new FlxText(-10, 0, 1280, "", 72);
keyTextDisplay.scrollFactor.set(0, 0); keyTextDisplay.scrollFactor.set(0, 0);
@ -74,7 +86,7 @@ class KeyBindMenu extends FlxSubState
blackBox = new FlxSprite(0,0).makeGraphic(FlxG.width,FlxG.height,FlxColor.BLACK); blackBox = new FlxSprite(0,0).makeGraphic(FlxG.width,FlxG.height,FlxColor.BLACK);
add(blackBox); add(blackBox);
infoText = new FlxText(-10, 580, 1280, "(Escape to save, backspace to leave without saving)", 72); infoText = new FlxText(-10, 580, 1280, 'Current Mode: ${KeyBinds.gamepad ? 'GAMEPAD' : 'KEYBOARD'}. Press TAB to switch\n(${KeyBinds.gamepad ? 'RIGHT Trigger' : 'Escape'} to save, ${KeyBinds.gamepad ? 'LEFT Trigger' : 'Backspace'} to leave without saving. ${KeyBinds.gamepad ? 'START To change a keybind' : ''})', 72);
infoText.scrollFactor.set(0, 0); infoText.scrollFactor.set(0, 0);
infoText.setFormat("VCR OSD Mono", 24, FlxColor.WHITE, FlxTextAlign.CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK); infoText.setFormat("VCR OSD Mono", 24, FlxColor.WHITE, FlxTextAlign.CENTER, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
infoText.borderSize = 2; infoText.borderSize = 2;
@ -98,23 +110,36 @@ class KeyBindMenu extends FlxSubState
super.create(); super.create();
} }
var frames = 0;
override function update(elapsed:Float) override function update(elapsed:Float)
{ {
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (frames <= 10)
frames++;
switch(state){ switch(state){
case "select": case "select":
if (FlxG.keys.justPressed.UP) if (FlxG.keys.justPressed.UP)
{ {
FlxG.sound.play(Paths.sound('scrollMenu')); FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(-1); changeItem(-1);
} }
if (FlxG.keys.justPressed.DOWN) if (FlxG.keys.justPressed.DOWN)
{ {
FlxG.sound.play(Paths.sound('scrollMenu')); FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(1); changeItem(1);
} }
if (FlxG.keys.justPressed.TAB)
{
KeyBinds.gamepad = !KeyBinds.gamepad;
infoText.text = 'Current Mode: ${KeyBinds.gamepad ? 'GAMEPAD' : 'KEYBOARD'}. Press TAB to switch\n(${KeyBinds.gamepad ? 'RIGHT Trigger' : 'Escape'} to save, ${KeyBinds.gamepad ? 'LEFT Trigger' : 'Backspace'} to leave without saving. ${KeyBinds.gamepad ? 'START To change a keybind' : ''})';
textUpdate();
}
if (FlxG.keys.justPressed.ENTER){ if (FlxG.keys.justPressed.ENTER){
FlxG.sound.play(Paths.sound('scrollMenu')); FlxG.sound.play(Paths.sound('scrollMenu'));
@ -123,31 +148,87 @@ class KeyBindMenu extends FlxSubState
else if(FlxG.keys.justPressed.ESCAPE){ else if(FlxG.keys.justPressed.ESCAPE){
quit(); quit();
} }
else if (FlxG.keys.justPressed.BACKSPACE){ else if (FlxG.keys.justPressed.BACKSPACE){
reset(); reset();
} }
if (gamepad != null) // GP Logic
{
if (gamepad.justPressed.DPAD_UP)
{
FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(-1);
textUpdate();
}
if (gamepad.justPressed.DPAD_DOWN)
{
FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(1);
textUpdate();
}
if (gamepad.justPressed.START && frames > 10){
FlxG.sound.play(Paths.sound('scrollMenu'));
state = "input";
}
else if(gamepad.justPressed.LEFT_TRIGGER){
quit();
}
else if (gamepad.justPressed.RIGHT_TRIGGER){
reset();
}
}
case "input": case "input":
tempKey = keys[curSelected]; tempKey = keys[curSelected];
keys[curSelected] = "?"; keys[curSelected] = "?";
if (KeyBinds.gamepad)
gpKeys[curSelected] = "?";
textUpdate(); textUpdate();
state = "waiting"; state = "waiting";
case "waiting": case "waiting":
if(FlxG.keys.justPressed.ESCAPE){ if (gamepad != null && KeyBinds.gamepad) // GP Logic
keys[curSelected] = tempKey; {
state = "select"; if(FlxG.keys.justPressed.ESCAPE){ // just in case you get stuck
FlxG.sound.play(Paths.sound('confirmMenu')); gpKeys[curSelected] = tempKey;
state = "select";
FlxG.sound.play(Paths.sound('confirmMenu'));
}
if (gamepad.justPressed.START)
{
addKeyGamepad(defaultKeys[curSelected]);
save();
state = "select";
}
if (gamepad.justPressed.ANY)
{
trace(gamepad.firstJustPressedID());
addKeyGamepad(gamepad.firstJustPressedID());
save();
state = "select";
textUpdate();
}
} }
else if(FlxG.keys.justPressed.ENTER){ else
addKey(defaultKeys[curSelected]); {
save(); if(FlxG.keys.justPressed.ESCAPE){
state = "select"; keys[curSelected] = tempKey;
} state = "select";
else if(FlxG.keys.justPressed.ANY){ FlxG.sound.play(Paths.sound('confirmMenu'));
addKey(FlxG.keys.getIsDown()[0].ID.toString()); }
save(); else if(FlxG.keys.justPressed.ENTER){
state = "select"; addKey(defaultKeys[curSelected]);
save();
state = "select";
}
else if(FlxG.keys.justPressed.ANY){
addKey(FlxG.keys.getIsDown()[0].ID.toString());
save();
state = "select";
}
} }
@ -170,11 +251,24 @@ class KeyBindMenu extends FlxSubState
keyTextDisplay.text = "\n\n"; keyTextDisplay.text = "\n\n";
for(i in 0...4){ if (KeyBinds.gamepad)
{
for(i in 0...4){
var textStart = (i == curSelected) ? "> " : " "; var textStart = (i == curSelected) ? "> " : " ";
keyTextDisplay.text += textStart + keyText[i] + ": " + ((keys[i] != keyText[i]) ? (keys[i] + " / ") : "" ) + keyText[i] + " ARROW\n"; trace(gpKeys[i]);
keyTextDisplay.text += textStart + keyText[i] + ": " + gpKeys[i] + "\n";
}
}
else
{
for(i in 0...4){
var textStart = (i == curSelected) ? "> " : " ";
keyTextDisplay.text += textStart + keyText[i] + ": " + ((keys[i] != keyText[i]) ? (keys[i] + " / ") : "" ) + keyText[i] + " ARROW\n";
}
} }
keyTextDisplay.screenCenter(); keyTextDisplay.screenCenter();
@ -187,6 +281,11 @@ class KeyBindMenu extends FlxSubState
FlxG.save.data.downBind = keys[1]; FlxG.save.data.downBind = keys[1];
FlxG.save.data.leftBind = keys[0]; FlxG.save.data.leftBind = keys[0];
FlxG.save.data.rightBind = keys[3]; FlxG.save.data.rightBind = keys[3];
FlxG.save.data.gpupBind = gpKeys[2];
FlxG.save.data.gpdownBind = gpKeys[1];
FlxG.save.data.gpleftBind = gpKeys[0];
FlxG.save.data.gprightBind = gpKeys[3];
FlxG.save.flush(); FlxG.save.flush();
@ -217,6 +316,38 @@ class KeyBindMenu extends FlxSubState
} }
function addKeyGamepad(r:String){
var shouldReturn:Bool = true;
var notAllowed:Array<String> = ["START", "RIGHT_TRIGGER", "LEFT_TRIGGER"];
for(x in 0...gpKeys.length)
{
var oK = gpKeys[x];
if(oK == r)
gpKeys[x] = null;
if (notAllowed.contains(oK))
{
gpKeys[x] = null;
return;
}
}
if(shouldReturn){
gpKeys[curSelected] = r;
FlxG.sound.play(Paths.sound('scrollMenu'));
}
else{
gpKeys[curSelected] = tempKey;
FlxG.sound.play(Paths.sound('scrollMenu'));
keyWarning.alpha = 1;
warningTween.cancel();
warningTween = FlxTween.tween(keyWarning, {alpha: 0}, 0.5, {ease: FlxEase.circOut, startDelay: 2});
}
}
function addKey(r:String){ function addKey(r:String){
var shouldReturn:Bool = true; var shouldReturn:Bool = true;
@ -233,7 +364,10 @@ class KeyBindMenu extends FlxSubState
if(oK == r) if(oK == r)
keys[x] = null; keys[x] = null;
if (notAllowed.contains(oK)) if (notAllowed.contains(oK))
{
keys[x] = null;
return; return;
}
} }
if (r.contains("NUMPAD")) if (r.contains("NUMPAD"))

View File

@ -12,6 +12,8 @@ import flixel.input.keyboard.FlxKey;
class KeyBinds class KeyBinds
{ {
public static var gamepad:Bool = false;
public static function resetBinds():Void{ public static function resetBinds():Void{
FlxG.save.data.upBind = "W"; FlxG.save.data.upBind = "W";
@ -19,6 +21,10 @@ class KeyBinds
FlxG.save.data.leftBind = "A"; FlxG.save.data.leftBind = "A";
FlxG.save.data.rightBind = "D"; FlxG.save.data.rightBind = "D";
FlxG.save.data.killBind = "R"; FlxG.save.data.killBind = "R";
FlxG.save.data.gpupBind = "DPAD_UP";
FlxG.save.data.gpdownBind = "DPAD_DOWN";
FlxG.save.data.gpleftBind = "DPAD_LEFT";
FlxG.save.data.gprightBind = "DPAD_RIGHT";
PlayerSettings.player1.controls.loadKeyBinds(); PlayerSettings.player1.controls.loadKeyBinds();
} }
@ -49,9 +55,22 @@ class KeyBinds
} }
if (StringTools.contains(FlxG.save.data.rightBind,"NUMPAD")) if (StringTools.contains(FlxG.save.data.rightBind,"NUMPAD"))
FlxG.save.data.rightBind = "D"; FlxG.save.data.rightBind = "D";
if(FlxG.save.data.killBind == null){
FlxG.save.data.killBind = "R"; if(FlxG.save.data.gpupBind == null){
trace("No KILL"); FlxG.save.data.gpupBind = "DPAD_UP";
trace("No GUP");
}
if(FlxG.save.data.gpdownBind == null){
FlxG.save.data.gpdownBind = "DPAD_DOWN";
trace("No GDOWN");
}
if(FlxG.save.data.gpleftBind == null){
FlxG.save.data.gpleftBind = "DPAD_LEFT";
trace("No GLEFT");
}
if(FlxG.save.data.gprightBind == null){
FlxG.save.data.gprightBind = "DPAD_RIGHT";
trace("No GRIGHT");
} }
trace('${FlxG.save.data.leftBind}-${FlxG.save.data.downBind}-${FlxG.save.data.upBind}-${FlxG.save.data.rightBind}'); trace('${FlxG.save.data.leftBind}-${FlxG.save.data.downBind}-${FlxG.save.data.upBind}-${FlxG.save.data.rightBind}');

View File

@ -1,5 +1,6 @@
package; package;
import flixel.input.gamepad.FlxGamepad;
import Controls.KeyboardScheme; import Controls.KeyboardScheme;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxObject; import flixel.FlxObject;
@ -144,13 +145,29 @@ class MainMenuState extends MusicBeatState
if (!selectedSomethin) if (!selectedSomethin)
{ {
if (controls.UP_P) var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.DPAD_UP)
{
FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(-1);
}
if (gamepad.justPressed.DPAD_DOWN)
{
FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(1);
}
}
if (FlxG.keys.justPressed.UP)
{ {
FlxG.sound.play(Paths.sound('scrollMenu')); FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(-1); changeItem(-1);
} }
if (controls.DOWN_P) if (FlxG.keys.justPressed.DOWN)
{ {
FlxG.sound.play(Paths.sound('scrollMenu')); FlxG.sound.play(Paths.sound('scrollMenu'));
changeItem(1); changeItem(1);

View File

@ -317,10 +317,10 @@ class Judgement extends Option
override function getValue():String { override function getValue():String {
return "Safe Frames: " + Conductor.safeFrames + return "Safe Frames: " + Conductor.safeFrames +
" - SIK: " + HelperFunctions.truncateFloat(22 * Conductor.timeScale, 0) + " - SIK: " + HelperFunctions.truncateFloat(45 * Conductor.timeScale, 0) +
"ms GD: " + HelperFunctions.truncateFloat(45 * Conductor.timeScale, 0) + "ms GD: " + HelperFunctions.truncateFloat(90 * Conductor.timeScale, 0) +
"ms BD: " + HelperFunctions.truncateFloat(135 * Conductor.timeScale, 0) + "ms BD: " + HelperFunctions.truncateFloat(135 * Conductor.timeScale, 0) +
"ms SHT: " + HelperFunctions.truncateFloat(155 * Conductor.timeScale, 0) + "ms SHT: " + HelperFunctions.truncateFloat(166 * Conductor.timeScale, 0) +
"ms TOTAL: " + HelperFunctions.truncateFloat(Conductor.safeZoneOffset,0) + "ms"; "ms TOTAL: " + HelperFunctions.truncateFloat(Conductor.safeZoneOffset,0) + "ms";
} }

View File

@ -1,5 +1,6 @@
package; package;
import flixel.input.gamepad.FlxGamepad;
import flixel.tweens.FlxEase; import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import openfl.Lib; import openfl.Lib;
@ -144,9 +145,26 @@ class OptionsMenu extends MusicBeatState
changeSelection(curSelected); changeSelection(curSelected);
} }
if (controls.UP_P)
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.DPAD_UP)
{
FlxG.sound.play(Paths.sound('scrollMenu'));
changeSelection(-1);
}
if (gamepad.justPressed.DPAD_DOWN)
{
FlxG.sound.play(Paths.sound('scrollMenu'));
changeSelection(1);
}
}
if (FlxG.keys.justPressed.UP)
changeSelection(-1); changeSelection(-1);
if (controls.DOWN_P) if (FlxG.keys.justPressed.DOWN)
changeSelection(1); changeSelection(1);
if (isCat) if (isCat)

View File

@ -1,5 +1,6 @@
package; package;
import flixel.input.gamepad.FlxGamepad;
import openfl.Lib; import openfl.Lib;
#if windows #if windows
import llua.Lua; import llua.Lua;
@ -108,6 +109,8 @@ class PauseSubState extends MusicBeatSubstate
if (PlayState.instance.useVideo) if (PlayState.instance.useVideo)
menuItems.remove('Resume'); menuItems.remove('Resume');
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
var upP = controls.UP_P; var upP = controls.UP_P;
var downP = controls.DOWN_P; var downP = controls.DOWN_P;
var leftP = controls.LEFT_P; var leftP = controls.LEFT_P;
@ -115,6 +118,14 @@ class PauseSubState extends MusicBeatSubstate
var accepted = controls.ACCEPT; var accepted = controls.ACCEPT;
var oldOffset:Float = 0; var oldOffset:Float = 0;
if (gamepad != null && KeyBinds.gamepad)
{
upP = gamepad.justPressed.DPAD_UP;
downP = gamepad.justPressed.DPAD_DOWN;
leftP = gamepad.justPressed.DPAD_LEFT;
rightP = gamepad.justPressed.DPAD_RIGHT;
}
// pre lowercasing the song name (update) // pre lowercasing the song name (update)
var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase(); var songLowercase = StringTools.replace(PlayState.SONG.song, " ", "-").toLowerCase();
switch (songLowercase) { switch (songLowercase) {

View File

@ -1,5 +1,6 @@
package; package;
import openfl.ui.KeyLocation;
import openfl.events.Event; import openfl.events.Event;
import haxe.EnumTools; import haxe.EnumTools;
import openfl.ui.Keyboard; import openfl.ui.Keyboard;
@ -1399,6 +1400,10 @@ class PlayState extends MusicBeatState
data = i; data = i;
} }
if (evt.keyLocation == KeyLocation.NUM_PAD)
{
trace(String.fromCharCode(evt.charCode) + " " + key);
}
if (data == -1) if (data == -1)
return; return;
@ -3114,7 +3119,7 @@ class PlayState extends MusicBeatState
var rightHold:Bool = false; var rightHold:Bool = false;
var leftHold:Bool = false; var leftHold:Bool = false;
// THIS FUNCTION JUST FUCKS WIT HELD NOTES AND BOTPLAY/REPLAY // THIS FUNCTION JUST FUCKS WIT HELD NOTES AND BOTPLAY/REPLAY (also gamepad shit)
private function keyShit():Void // I've invested in emma stocks private function keyShit():Void // I've invested in emma stocks
{ {
@ -3149,11 +3154,6 @@ class PlayState extends MusicBeatState
releaseArray = [false, false, false, false]; releaseArray = [false, false, false, false];
} }
var anas:Array<Ana> = [null,null,null,null];
/*for (i in 0...pressArray.length)
if (pressArray[i])
anas[i] = new Ana(Conductor.songPosition, null, false, "miss", i);*/
// HOLDS, check for sustain notes // HOLDS, check for sustain notes
if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic) if (holdArray.contains(true) && /*!boyfriend.stunned && */ generatedMusic)
@ -3165,103 +3165,110 @@ class PlayState extends MusicBeatState
}); });
} }
// PRESSES, check for note hits if (KeyBinds.gamepad && !FlxG.keys.pressed.ANY)
/*if (pressArray.contains(true) && generatedMusic)
{ {
boyfriend.holdTimer = 0; var anas:Array<Ana> = [null,null,null,null];
var possibleNotes:Array<Note> = []; // notes that can be hit for (i in 0...pressArray.length)
var directionList:Array<Int> = []; // directions that can be hit if (pressArray[i])
var dumbNotes:Array<Note> = []; // notes to kill later anas[i] = new Ana(Conductor.songPosition, null, false, "miss", i);
var directionsAccounted:Array<Bool> = [false,false,false,false]; // we don't want to do judgments for more than one presses
// PRESSES, check for note hits
notes.forEachAlive(function(daNote:Note) if (pressArray.contains(true) && generatedMusic)
{ {
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit) boyfriend.holdTimer = 0;
var possibleNotes:Array<Note> = []; // notes that can be hit
var directionList:Array<Int> = []; // directions that can be hit
var dumbNotes:Array<Note> = []; // notes to kill later
var directionsAccounted:Array<Bool> = [false,false,false,false]; // we don't want to do judgments for more than one presses
notes.forEachAlive(function(daNote:Note)
{ {
if (!directionsAccounted[daNote.noteData]) if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit)
{ {
if (directionList.contains(daNote.noteData)) if (!directionsAccounted[daNote.noteData])
{ {
directionsAccounted[daNote.noteData] = true; if (directionList.contains(daNote.noteData))
for (coolNote in possibleNotes)
{ {
if (coolNote.noteData == daNote.noteData && Math.abs(daNote.strumTime - coolNote.strumTime) < 10) directionsAccounted[daNote.noteData] = true;
{ // if it's the same note twice at < 10ms distance, just delete it for (coolNote in possibleNotes)
// EXCEPT u cant delete it in this loop cuz it fucks with the collection lol {
dumbNotes.push(daNote); if (coolNote.noteData == daNote.noteData && Math.abs(daNote.strumTime - coolNote.strumTime) < 10)
break; { // if it's the same note twice at < 10ms distance, just delete it
} // EXCEPT u cant delete it in this loop cuz it fucks with the collection lol
else if (coolNote.noteData == daNote.noteData && daNote.strumTime < coolNote.strumTime) dumbNotes.push(daNote);
{ // if daNote is earlier than existing note (coolNote), replace break;
possibleNotes.remove(coolNote); }
possibleNotes.push(daNote); else if (coolNote.noteData == daNote.noteData && daNote.strumTime < coolNote.strumTime)
break; { // if daNote is earlier than existing note (coolNote), replace
possibleNotes.remove(coolNote);
possibleNotes.push(daNote);
break;
}
} }
} }
} else
else {
{ possibleNotes.push(daNote);
possibleNotes.push(daNote); directionList.push(daNote.noteData);
directionList.push(daNote.noteData); }
}
}
}
});
trace('notes that can be hit: ' + possibleNotes.length);
for (note in dumbNotes)
{
FlxG.log.add("killing dumb ass note at " + note.strumTime);
note.kill();
notes.remove(note, true);
note.destroy();
}
possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
if (perfectMode)
goodNoteHit(possibleNotes[0]);
else if (possibleNotes.length > 0)
{
if (!FlxG.save.data.ghost)
{
for (shit in 0...pressArray.length)
{ // if a direction is hit that shouldn't be
if (pressArray[shit] && !directionList.contains(shit))
noteMiss(shit, null);
} }
} }
for (coolNote in possibleNotes) });
for (note in dumbNotes)
{ {
if (pressArray[coolNote.noteData]) FlxG.log.add("killing dumb ass note at " + note.strumTime);
note.kill();
notes.remove(note, true);
note.destroy();
}
possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
if (perfectMode)
goodNoteHit(possibleNotes[0]);
else if (possibleNotes.length > 0)
{
if (!FlxG.save.data.ghost)
{ {
if (mashViolations != 0) for (shit in 0...pressArray.length)
mashViolations--; { // if a direction is hit that shouldn't be
scoreTxt.color = FlxColor.WHITE; if (pressArray[shit] && !directionList.contains(shit))
var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition); noteMiss(shit, null);
anas[coolNote.noteData].hit = true; }
anas[coolNote.noteData].hitJudge = Ratings.CalculateRating(noteDiff, Math.floor((PlayStateChangeables.safeFrames / 60) * 1000)); }
anas[coolNote.noteData].nearestNote = [coolNote.strumTime,coolNote.noteData,coolNote.sustainLength]; for (coolNote in possibleNotes)
goodNoteHit(coolNote); {
if (pressArray[coolNote.noteData])
{
if (mashViolations != 0)
mashViolations--;
scoreTxt.color = FlxColor.WHITE;
var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition);
anas[coolNote.noteData].hit = true;
anas[coolNote.noteData].hitJudge = Ratings.CalculateRating(noteDiff, Math.floor((PlayStateChangeables.safeFrames / 60) * 1000));
anas[coolNote.noteData].nearestNote = [coolNote.strumTime,coolNote.noteData,coolNote.sustainLength];
goodNoteHit(coolNote);
}
} }
} }
else if (!FlxG.save.data.ghost)
{
for (shit in 0...pressArray.length)
if (pressArray[shit])
noteMiss(shit, null);
}
} }
else if (!FlxG.save.data.ghost)
{
for (shit in 0...pressArray.length)
if (pressArray[shit])
noteMiss(shit, null);
}
}*/ if (!loadRep)
for (i in anas)
if (i != null)
replayAna.anaArray.push(i); // put em all there*/
}
/*if (!loadRep)
for (i in anas)
if (i != null)
replayAna.anaArray.push(i); // put em all there*/
notes.forEachAlive(function(daNote:Note) notes.forEachAlive(function(daNote:Note)
{ {
if(PlayStateChangeables.useDownscroll && daNote.y > strumLine.y || if(PlayStateChangeables.useDownscroll && daNote.y > strumLine.y ||

View File

@ -1,5 +1,6 @@
package; package;
import flixel.input.gamepad.FlxGamepad;
import flixel.FlxG; import flixel.FlxG;
import flixel.FlxSprite; import flixel.FlxSprite;
import flixel.addons.transition.FlxTransitionableState; import flixel.addons.transition.FlxTransitionableState;
@ -222,12 +223,44 @@ class StoryMenuState extends MusicBeatState
{ {
if (!selectedWeek) if (!selectedWeek)
{ {
if (controls.UP_P) var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.DPAD_UP)
{
changeWeek(-1);
}
if (gamepad.justPressed.DPAD_DOWN)
{
changeWeek(1);
}
if (gamepad.pressed.DPAD_RIGHT)
rightArrow.animation.play('press')
else
rightArrow.animation.play('idle');
if (gamepad.pressed.DPAD_LEFT)
leftArrow.animation.play('press');
else
leftArrow.animation.play('idle');
if (gamepad.justPressed.DPAD_RIGHT)
{
changeDifficulty(1);
}
if (gamepad.justPressed.DPAD_LEFT)
{
changeDifficulty(-1);
}
}
if (FlxG.keys.justPressed.UP)
{ {
changeWeek(-1); changeWeek(-1);
} }
if (controls.DOWN_P) if (FlxG.keys.justPressed.DOWN)
{ {
changeWeek(1); changeWeek(1);
} }

View File

@ -80,6 +80,8 @@ class TitleState extends MusicBeatState
curWacky = FlxG.random.getObject(getIntroTextShit()); curWacky = FlxG.random.getObject(getIntroTextShit());
trace('hello');
// DEBUG BULLSHIT // DEBUG BULLSHIT
super.create(); super.create();
@ -277,7 +279,7 @@ class TitleState extends MusicBeatState
FlxG.fullscreen = !FlxG.fullscreen; FlxG.fullscreen = !FlxG.fullscreen;
} }
var pressedEnter:Bool = FlxG.keys.justPressed.ENTER; var pressedEnter:Bool = controls.ACCEPT;
#if mobile #if mobile
for (touch in FlxG.touches.list) for (touch in FlxG.touches.list)
@ -289,19 +291,6 @@ class TitleState extends MusicBeatState
} }
#end #end
var gamepad:FlxGamepad = FlxG.gamepads.lastActive;
if (gamepad != null)
{
if (gamepad.justPressed.START)
pressedEnter = true;
#if switch
if (gamepad.justPressed.B)
pressedEnter = true;
#end
}
if (pressedEnter && !transitioning && skippedIntro) if (pressedEnter && !transitioning && skippedIntro)
{ {
#if !switch #if !switch