//Locate this function. BattleManager.lmbsUpdateCommand
/*
These are the gamepad keys that MV has available.
So, we're going to add the missing keys.
Input.gamepadMapper = {
0: 'ok', // A
1: 'cancel', // B
2: 'shift', // X
3: 'menu', // Y
4: 'pageup', // LB
5: 'pagedown', // RB
12: 'up', // D-pad up
13: 'down', // D-pad down
14: 'left', // D-pad left
15: 'right', // D-pad right
};
To use them, simply determine how you want the button to be pressed.
Input.isTriggered('key') means the action will be done upon the button press.
Input.isPressed('key') means the action will be done until the botton is released.
Btw, I'm also putting here a small function to detect if a gamepad is connected and split the inputs :)
*/
Input.gamepadMapper = {
//Gamepad 1
0: 'ok', // A
1: 'cancel', // B
2: 'shift', // X
3: 'menu', // Y
4: 'LB', // LB
5: 'RB', // RB
6: 'LT', // LT
7: 'RT', // RT
8: 'select', //Select (Generic)
9: 'start', //Select (Generic)
10: 'L3', //Left Stick Press
11: 'R3', //Right Stick Press
12: 'up', // D-pad up
13: 'down', // D-pad down
14: 'left', // D-pad left
15: 'right', // D-pad right
};
BattleManager.lmbsUpdateCommand = function() {
var inputMethod = "keyboard";
if(isGamepadConnected(0)){
inputMethod = "gamepad";
}else{
inputMethod = "keyboard";
}
//If anyone checks the code this might sound redundant but I don't want errors :3
if(inputMethod === "keyboard"){
if ((Input.isTriggered(Moghunter.lmbsKeyMenu) && this.lmbsCanCallMenu()) {
$gameTemp._lmbsSelectPhase[0] = true;
$gameTemp._lmbsMenuPhase[0] = true;
SoundManager.playCursor();
return
};
if (Input.isPressed(Moghunter.lmbsKeyGuard) {this._lmbsActor.lmbsGuard()};
if (Input.isTriggered(Moghunter.lmbsKeyAttack)) {this._lmbsActor.lmbsAttackAction()};
if (Input.isTriggered(Moghunter.lmbsKeySkill)) {this._lmbsActor.lmbsSkillActionActor()};
if (Input.isTriggered('up')) {
this._lmbsActor.lmbsJump();
} else if (Input.isPressed('down')) {
};
if (Input.isPressed('left')) {
this._lmbsActor.lmbsMove(2);
} else if (Input.isPressed('right')) {
this._lmbsActor.lmbsMove(3);
};
if (Input.isPressed(Moghunter.lmbsKeyDash)) {this._lmbsActor.lmbsUpdateDash()
} else {this._lmbsActor._lmbs_Dash[1] = false};
if (Input.isTriggered(Moghunter.lmbsKeyDash)) {this._lmbsActor.lmbsAirDash()};
if (Input.isTriggered(Moghunter.lmbsKeyPrev) && this.lmbsCanCallMenu()) {
var act = BattleManager._lmbsActor
BattleManager._lmbsActor = BattleManager.lmbsPrevTarget(-1,0,true);
$gameTemp._lmbsPlayerCursor[0] = $gameTemp._lmbsPlayerCursor[1];
SoundManager.playCursor();
if (act != BattleManager._lmbsActor) {this.lmbsPlayTurnVoice()};
} else if (Input.isTriggered(Moghunter.lmbsKeyNext) && this.lmbsCanCallMenu()) {
var act = BattleManager._lmbsActor
BattleManager._lmbsActor = BattleManager.lmbsNextTarget(1,0,true);
$gameTemp._lmbsPlayerCursor[0] = $gameTemp._lmbsPlayerCursor[1];
SoundManager.playCursor();
if (act != BattleManager._lmbsActor) {this.lmbsPlayTurnVoice()};
};
}else{
//Gamepad Inputs Start here. Just replace what's between the ''
if ((Input.isTriggered('start') && this.lmbsCanCallMenu()) {
$gameTemp._lmbsSelectPhase[0] = true;
$gameTemp._lmbsMenuPhase[0] = true;
SoundManager.playCursor();
return
};
//Guard
if (Input.isPressed('cancel') {this._lmbsActor.lmbsGuard()};
//Normal Attack
if (Input.isTriggered('ok')) {this._lmbsActor.lmbsAttackAction()};
//Skills
if (Input.isTriggered('RT')) {this._lmbsActor.lmbsSkillActionActor()};
//Movement
if (Input.isTriggered('up')) {
this._lmbsActor.lmbsJump();
} else if (Input.isPressed('down')) {
};
if (Input.isPressed('left')) {
this._lmbsActor.lmbsMove(2);
} else if (Input.isPressed('right')) {
this._lmbsActor.lmbsMove(3);
};
//Dash
if (Input.isPressed('shift') {this._lmbsActor.lmbsUpdateDash()
} else {this._lmbsActor._lmbs_Dash[1] = false};
//AirDash
if (Input.isTriggered('shift') {this._lmbsActor.lmbsAirDash()};
//Change Playable Character (Left)
if (Input.isTriggered('LB') && this.lmbsCanCallMenu()) {
var act = BattleManager._lmbsActor
BattleManager._lmbsActor = BattleManager.lmbsPrevTarget(-1,0,true);
$gameTemp._lmbsPlayerCursor[0] = $gameTemp._lmbsPlayerCursor[1];
SoundManager.playCursor();
if (act != BattleManager._lmbsActor) {this.lmbsPlayTurnVoice()};
//Change Playable Character (Right)
} else if (Input.isTriggered('RB') && this.lmbsCanCallMenu()) {
var act = BattleManager._lmbsActor
BattleManager._lmbsActor = BattleManager.lmbsNextTarget(1,0,true);
$gameTemp._lmbsPlayerCursor[0] = $gameTemp._lmbsPlayerCursor[1];
SoundManager.playCursor();
if (act != BattleManager._lmbsActor) {this.lmbsPlayTurnVoice()};
};
}
if (BattleManager._lmbsActor.lmbsIsEscaping()) {BattleManager._lmbsActor.lmbsUpdateEscape()};
};
function isGamepadConnected(index) {
if (navigator.getGamepads) {
var gamepads = navigator.getGamepads();
if (gamepads && gamepads[index]) {
var gamepad = gamepads[index];
return gamepad.connected;
}
}
return false;
}