mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-12-23 16:32:49 +00:00
allow emulation of modded controller
This commit is contained in:
parent
e0bd40fc03
commit
0a42f481ca
4 changed files with 52 additions and 1 deletions
|
|
@ -2147,6 +2147,25 @@ class Marble extends GameObject {
|
|||
move.d = new Vector();
|
||||
move.d.x = Gamepad.getAxis(Settings.gamepadSettings.moveYAxis);
|
||||
move.d.y = -Gamepad.getAxis(Settings.gamepadSettings.moveXAxis);
|
||||
|
||||
if (Settings.controlsSettings.moddedController) {
|
||||
// we need to scale the moves to square instead of circle
|
||||
var moveLen = Math.sqrt(move.d.x * move.d.x + move.d.y * move.d.y);
|
||||
if (moveLen > 0.00001) {
|
||||
// Normalize the vector
|
||||
var normalizedX = move.d.x / moveLen;
|
||||
var normalizedY = move.d.y / moveLen;
|
||||
|
||||
// Scale to square - this allows diagonal movements to reach the corners
|
||||
var scaleFactor = Math.max(Math.abs(normalizedX), Math.abs(normalizedY));
|
||||
if (scaleFactor > 0) {
|
||||
// Apply square mapping while preserving the original magnitude
|
||||
move.d.x = normalizedX / scaleFactor * moveLen;
|
||||
move.d.y = normalizedY / scaleFactor * moveLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (@:privateAccess !MarbleGame.instance.world.playGui.isChatFocused()) {
|
||||
if (Key.isDown(Settings.controlsSettings.forward)) {
|
||||
move.d.x -= 1;
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ typedef ControlsSettings = {
|
|||
var rewind:Int;
|
||||
var chat:Int;
|
||||
var oobRespawnKeyByPowerup:Bool;
|
||||
var moddedController:Bool;
|
||||
}
|
||||
|
||||
typedef TouchSettings = {
|
||||
|
|
@ -166,7 +167,8 @@ class Settings {
|
|||
blast: Key.MOUSE_RIGHT,
|
||||
rewind: Key.R,
|
||||
chat: Key.T,
|
||||
oobRespawnKeyByPowerup: false
|
||||
oobRespawnKeyByPowerup: false,
|
||||
moddedController: false
|
||||
};
|
||||
|
||||
public static var touchSettings:TouchSettings = {
|
||||
|
|
@ -473,6 +475,9 @@ class Settings {
|
|||
if (controlsSettings.oobRespawnKeyByPowerup == null) {
|
||||
controlsSettings.oobRespawnKeyByPowerup = false;
|
||||
}
|
||||
if (controlsSettings.moddedController == null) {
|
||||
controlsSettings.moddedController = false;
|
||||
}
|
||||
if (optionsSettings.rewindEnabled == null) {
|
||||
optionsSettings.rewindEnabled = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,6 +102,12 @@ class MiscOptionsGui extends GuiImage {
|
|||
}, 0.5, 118);
|
||||
oobResOpt.setCurrentOption(Settings.controlsSettings.oobRespawnKeyByPowerup ? 1 : 0);
|
||||
|
||||
var moddedOpt = optionCollection.addOption(1, "Emulate Modded Controller", ["No", "Yes"], (idx) -> {
|
||||
Settings.controlsSettings.moddedController = (idx == 1);
|
||||
return true;
|
||||
}, 0.5, 118);
|
||||
moddedOpt.setCurrentOption(Settings.controlsSettings.moddedController ? 1 : 0);
|
||||
|
||||
var bottomBar = new GuiControl();
|
||||
bottomBar.position = new Vector(0, 590);
|
||||
bottomBar.extent = new Vector(640, 200);
|
||||
|
|
|
|||
|
|
@ -76,6 +76,25 @@ class MoveManager {
|
|||
if (!MarbleGame.instance.paused) {
|
||||
move.d.x = Gamepad.getAxis(Settings.gamepadSettings.moveYAxis);
|
||||
move.d.y = -Gamepad.getAxis(Settings.gamepadSettings.moveXAxis);
|
||||
|
||||
if (Settings.controlsSettings.moddedController) {
|
||||
// we need to scale the moves to square instead of circle
|
||||
var moveLen = Math.sqrt(move.d.x * move.d.x + move.d.y * move.d.y);
|
||||
if (moveLen > 0.00001) {
|
||||
// Normalize the vector
|
||||
var normalizedX = move.d.x / moveLen;
|
||||
var normalizedY = move.d.y / moveLen;
|
||||
|
||||
// Scale to square - this allows diagonal movements to reach the corners
|
||||
var scaleFactor = Math.max(Math.abs(normalizedX), Math.abs(normalizedY));
|
||||
if (scaleFactor > 0) {
|
||||
// Apply square mapping while preserving the original magnitude
|
||||
move.d.x = normalizedX / scaleFactor * moveLen;
|
||||
move.d.y = normalizedY / scaleFactor * moveLen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (@:privateAccess !MarbleGame.instance.world.playGui.isChatFocused()) {
|
||||
if (Key.isDown(Settings.controlsSettings.forward)) {
|
||||
move.d.x -= 1;
|
||||
|
|
@ -89,6 +108,8 @@ class MoveManager {
|
|||
if (Key.isDown(Settings.controlsSettings.right)) {
|
||||
move.d.y -= 1;
|
||||
}
|
||||
move.d.x = Util.clamp(move.d.x, -1, 1);
|
||||
move.d.y = Util.clamp(move.d.y, -1, 1);
|
||||
if (Key.isDown(Settings.controlsSettings.jump)
|
||||
|| MarbleGame.instance.touchInput.jumpButton.pressed
|
||||
|| Gamepad.isDown(Settings.gamepadSettings.jump)) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue