mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2026-04-26 12:41:40 +00:00
allow emulation of modded controller
This commit is contained in:
parent
efdb666b68
commit
7f1b39609f
4 changed files with 52 additions and 1 deletions
|
|
@ -2147,6 +2147,25 @@ class Marble extends GameObject {
|
||||||
move.d = new Vector();
|
move.d = new Vector();
|
||||||
move.d.x = Gamepad.getAxis(Settings.gamepadSettings.moveYAxis);
|
move.d.x = Gamepad.getAxis(Settings.gamepadSettings.moveYAxis);
|
||||||
move.d.y = -Gamepad.getAxis(Settings.gamepadSettings.moveXAxis);
|
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 (@:privateAccess !MarbleGame.instance.world.playGui.isChatFocused()) {
|
||||||
if (Key.isDown(Settings.controlsSettings.forward)) {
|
if (Key.isDown(Settings.controlsSettings.forward)) {
|
||||||
move.d.x -= 1;
|
move.d.x -= 1;
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ typedef ControlsSettings = {
|
||||||
var blast:Int;
|
var blast:Int;
|
||||||
var rewind:Int;
|
var rewind:Int;
|
||||||
var chat:Int;
|
var chat:Int;
|
||||||
|
var moddedController:Bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef TouchSettings = {
|
typedef TouchSettings = {
|
||||||
|
|
@ -164,7 +165,8 @@ class Settings {
|
||||||
respawn: Key.BACKSPACE,
|
respawn: Key.BACKSPACE,
|
||||||
blast: Key.MOUSE_RIGHT,
|
blast: Key.MOUSE_RIGHT,
|
||||||
rewind: Key.R,
|
rewind: Key.R,
|
||||||
chat: Key.T
|
chat: Key.T,
|
||||||
|
moddedController: false
|
||||||
};
|
};
|
||||||
|
|
||||||
public static var touchSettings:TouchSettings = {
|
public static var touchSettings:TouchSettings = {
|
||||||
|
|
@ -500,6 +502,9 @@ class Settings {
|
||||||
if (controlsSettings.chat == null) {
|
if (controlsSettings.chat == null) {
|
||||||
controlsSettings.chat = Key.T;
|
controlsSettings.chat = Key.T;
|
||||||
}
|
}
|
||||||
|
if (controlsSettings.moddedController == null) {
|
||||||
|
controlsSettings.moddedController = false;
|
||||||
|
}
|
||||||
if (optionsSettings.rewindEnabled == null) {
|
if (optionsSettings.rewindEnabled == null) {
|
||||||
optionsSettings.rewindEnabled = false;
|
optionsSettings.rewindEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,12 @@ class MiscOptionsGui extends GuiImage {
|
||||||
flOpt.setCurrentOption(Settings.optionsSettings.fastLoad ? 1 : 0);
|
flOpt.setCurrentOption(Settings.optionsSettings.fastLoad ? 1 : 0);
|
||||||
// #end
|
// #end
|
||||||
|
|
||||||
|
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();
|
var bottomBar = new GuiControl();
|
||||||
bottomBar.position = new Vector(0, 590);
|
bottomBar.position = new Vector(0, 590);
|
||||||
bottomBar.extent = new Vector(640, 200);
|
bottomBar.extent = new Vector(640, 200);
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,25 @@ class MoveManager {
|
||||||
if (!MarbleGame.instance.paused) {
|
if (!MarbleGame.instance.paused) {
|
||||||
move.d.x = Gamepad.getAxis(Settings.gamepadSettings.moveYAxis);
|
move.d.x = Gamepad.getAxis(Settings.gamepadSettings.moveYAxis);
|
||||||
move.d.y = -Gamepad.getAxis(Settings.gamepadSettings.moveXAxis);
|
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 (@:privateAccess !MarbleGame.instance.world.playGui.isChatFocused()) {
|
||||||
if (Key.isDown(Settings.controlsSettings.forward)) {
|
if (Key.isDown(Settings.controlsSettings.forward)) {
|
||||||
move.d.x -= 1;
|
move.d.x -= 1;
|
||||||
|
|
@ -89,6 +108,8 @@ class MoveManager {
|
||||||
if (Key.isDown(Settings.controlsSettings.right)) {
|
if (Key.isDown(Settings.controlsSettings.right)) {
|
||||||
move.d.y -= 1;
|
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)
|
if (Key.isDown(Settings.controlsSettings.jump)
|
||||||
|| MarbleGame.instance.touchInput.jumpButton.pressed
|
|| MarbleGame.instance.touchInput.jumpButton.pressed
|
||||||
|| Gamepad.isDown(Settings.gamepadSettings.jump)) {
|
|| Gamepad.isDown(Settings.gamepadSettings.jump)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue