How to... make "Input.isPressed" use "_gamepadsStates[n]"?

FoxySeta

Cleric, script kiddie and fudanshi
Veteran
Joined
May 6, 2017
Messages
270
Reaction score
110
First Language
Italian
Primarily Uses
RMMV
Ok so this thread is partially related to this one (about the use of multiple gamepads): simply put, I'm trying to solve it myself editing "Input.isPressed".
Here's the original code:
Code:
/**
 * Checks whether a key is currently pressed down.
 *
 * @static
 * @method isPressed
 * @param {String} keyName The mapped name of the key
 * @return {Boolean} True if the key is pressed
 */
Input.isPressed = function(keyName) {
    if (this._isEscapeCompatible(keyName) && this.isPressed('escape')) {
        return true;
    } else {
        return this._currentState[keyName];
    }
};
Here's mine:
Code:
Input.isPressed = function(keyName, gamepadNumber) {
    if (this._isEscapeCompatible(keyName) && this.isPressed('escape')) {
        return true;
    } else if (gamepadNumber == undefined) {
        return this._currentState[keyName];
    } else {
        return this._gamepadStates[gamepadNumber][keyName];
    }
};
When I test my project, it doesn't crash, but it works only when the "else if" condition is true; when the condition is false, it doesn't crash, it simply always returns false (since I'm using 4 gamepads, "gamepadNumber" is always between 0 and 3).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c

Forum statistics

Threads
105,857
Messages
1,017,015
Members
137,563
Latest member
MinyakaAeon
Top