The problem with what
@SangHendrix suggests is that's going to be true if any controllers
are plugged in.
Many gamers will have controllers plugged into their PC all the time, but not necessarily want to use them for a given game.
If you've played any professional games that support multiple inputs, the standard procedure is to show the icons for whatever the player has actually pressed a button on.
So if I click or press Enter on the main title, it shows me keyboard buttons. If I pressed A on my Xbox controller, it shows the icons for those buttons.
I haven't done anything with gamepads, so someone else might have a better answer; but, taking a quick look, I'd try adding a check to the middle of _updateGamepadState().
Code:
Input._updateGamepadState = function(gamepad) {
var lastState = this._gamepadStates[gamepad.index] || [];
var newState = [];
var buttons = gamepad.buttons;
var axes = gamepad.axes;
var threshold = 0.5;
newState[12] = false;
newState[13] = false;
newState[14] = false;
newState[15] = false;
for (var i = 0; i < buttons.length; i++) {
newState[i] = buttons[i].pressed;
}
if (axes[1] < -threshold) {
newState[12] = true; // up
} else if (axes[1] > threshold) {
newState[13] = true; // down
}
if (axes[0] < -threshold) {
newState[14] = true; // left
} else if (axes[0] > threshold) {
newState[15] = true; // right
}
for (var j = 0; j < newState.length; j++) {
if (newState[j] !== lastState[j]) {
var buttonName = this.gamepadMapper[j];
if (buttonName) {
// A valid gamepad button was pressed, turn on a switch
$gameSwitches.setValue(X, true);
this._currentState[buttonName] = newState[j];
}
}
}
this._gamepadStates[gamepad.index] = newState;
};
In the $gameSwitches line, you'd replace X with the value of the switch to turn on.
By default, that will go into the game save so it's true for the rest of that player's game; if you wanted it to reset every time the game is started, you'd need an additional plugin to reset the switch on game load.
What software are you using? I copied the MV function because that's what you have in your profile, but I just noticed you posted this in MZ support.