Skip to content

Commit

Permalink
remove checks for haxe 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion authored and charlesisfeline committed Jul 31, 2024
1 parent 5414425 commit b594a96
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 58 deletions.
51 changes: 2 additions & 49 deletions source/funkin/backend/system/Controls.hx
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ class Controls extends FlxActionSet
var _cheat = new FlxActionDigital(Action.CHEAT);
var _switchMod = new FlxActionDigital(Action.SWITCHMOD);

#if (haxe >= "4.0.0")
var byName:Map<String, FlxActionDigital> = [];
#else
var byName:Map<String, FlxActionDigital> = new Map<String, FlxActionDigital>();
#end

public var gamepadsAdded:Array<Int> = [];
public var keyboardScheme = KeyboardScheme.None;
Expand Down Expand Up @@ -554,7 +550,6 @@ class Controls extends FlxActionSet

public function copyFrom(controls:Controls, ?device:Device)
{
#if (haxe >= "4.0.0")
for (name => action in controls.byName)
{
for (input in action.inputs)
Expand All @@ -563,31 +558,14 @@ class Controls extends FlxActionSet
byName[name].add(cast input);
}
}
#else
for (name in controls.byName.keys())
{
var action = controls.byName[name];
for (input in action.inputs)
{
if (device == null || isDevice(input, device))
byName[name].add(cast input);
}
}
#end


switch (device)
{
case null:
// add all
#if (haxe >= "4.0.0")
for (gamepad in controls.gamepadsAdded)
if (!gamepadsAdded.contains(gamepad))
gamepadsAdded.push(gamepad);
#else
for (gamepad in controls.gamepadsAdded)
if (gamepadsAdded.indexOf(gamepad) == -1)
gamepadsAdded.push(gamepad);
#end

mergeKeyboardScheme(controls.keyboardScheme);

Expand Down Expand Up @@ -623,11 +601,7 @@ class Controls extends FlxActionSet
*/
public function bindKeys(control:Control, keys:Array<FlxKey>)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, state) -> addKeys(action, keys, state));
#else
forEachBound(control, function(action, state) addKeys(action, keys, state));
#end
}

/**
Expand All @@ -636,11 +610,7 @@ class Controls extends FlxActionSet
*/
public function unbindKeys(control:Control, keys:Array<FlxKey>)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, _) -> removeKeys(action, keys));
#else
forEachBound(control, function(action, _) removeKeys(action, keys));
#end
}

inline static function addKeys(action:FlxActionDigital, keys:Array<FlxKey>, state:FlxInputState)
Expand Down Expand Up @@ -734,26 +704,17 @@ class Controls extends FlxActionSet
{
gamepadsAdded.push(id);

#if (haxe >= "4.0.0")
for (control => buttons in buttonMap)
inline bindButtons(control, id, buttons);
#else
for (control in buttonMap.keys())
bindButtons(control, id, buttonMap[control]);
#end

}

inline function addGamepadLiteral(id:Int, ?buttonMap:Map<Control, Array<FlxGamepadInputID>>):Void
{
gamepadsAdded.push(id);

#if (haxe >= "4.0.0")
for (control => buttons in buttonMap)
inline bindButtons(control, id, buttons);
#else
for (control in buttonMap.keys())
bindButtons(control, id, buttonMap[control]);
#end
}

public function removeGamepad(deviceID:Int = FlxInputDeviceID.ALL):Void
Expand Down Expand Up @@ -808,11 +769,7 @@ class Controls extends FlxActionSet
*/
public function bindButtons(control:Control, id, buttons)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, state) -> addButtons(action, buttons, state, id));
#else
forEachBound(control, function(action, state) addButtons(action, buttons, state, id));
#end
}

/**
Expand All @@ -821,11 +778,7 @@ class Controls extends FlxActionSet
*/
public function unbindButtons(control:Control, gamepadID:Int, buttons)
{
#if (haxe >= "4.0.0")
inline forEachBound(control, (action, _) -> removeButtons(action, gamepadID, buttons));
#else
forEachBound(control, function(action, _) removeButtons(action, gamepadID, buttons));
#end
}

inline static function addButtons(action:FlxActionDigital, buttons:Array<FlxGamepadInputID>, state, id)
Expand Down
9 changes: 0 additions & 9 deletions source/funkin/options/PlayerSettings.hx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,12 @@ class PlayerSettings
static public var player1(default, null):PlayerSettings;
static public var player2(default, null):PlayerSettings;

#if (haxe >= "4.0.0")
static public final onAvatarAdd = new FlxTypedSignal<PlayerSettings->Void>();
static public final onAvatarRemove = new FlxTypedSignal<PlayerSettings->Void>();
#else
static public var onAvatarAdd = new FlxTypedSignal<PlayerSettings->Void>();
static public var onAvatarRemove = new FlxTypedSignal<PlayerSettings->Void>();
#end

public var id(default, null):Int;

#if (haxe >= "4.0.0")
public final controls:Controls;
#else
public var controls:Controls;
#end

function new(id, scheme)
{
Expand Down

0 comments on commit b594a96

Please sign in to comment.