• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GML Gamepad inputs without Analog Stick

T

Tofu Heavy Industries

Guest
I can't get my game to recognize any directional input from a controller without analog sticks. Such as a 8bitdo nes/snes usb controller. If I plug in a XInput controller (such as a PS2 w/ usb converter), I can use either the analog sticks or the dpad, but if the controller doesn't have analog sticks, it won't take any directions at all.

Heres the setup for the controller
Code:
global.playcontrol_one = 255;

switch(async_load[? "event_type"])             // Parse the async_load map to see which event has been triggered
{
    case "gamepad discovered":  

        if (global.playcontrol_one == 255) {global.playcontrol_one = async_load[? "pad_index"];
            gamepad_set_axis_deadzone(global.playcontrol_one, 0.5);       // Set the "deadzone" for the axis
            gamepad_set_button_threshold(global.playcontrol_one, 0.1);    // Set the "threshold" for the triggers
    
        } else { global.playcontrol_two = async_load[? "pad_index"];
            gamepad_set_axis_deadzone(global.playcontrol_two, 0.5);       // Set the "deadzone" for the axis
            gamepad_set_button_threshold(global.playcontrol_two, 0.1);    // Set the "threshold" for the triggers 
        }
        break;

    case "gamepad lost": {
        //Do nothing
        }
        break;
}

And heres some usage code in a step event:

Code:
var RIGHT = gamepad_button_check(global.playcontrol_one, gp_padr) || (gamepad_axis_value(global.playcontrol_one, gp_axislh) > 0)
var LEFT = (gamepad_button_check(global.playcontrol_one, gp_padl)) || (gamepad_axis_value(global.playcontrol_one, gp_axislh) < 0);
What can I do to satisfy both usage of an analog stick and a controller with only a dpad?
 

kburkhart84

Firehammer Games
On some gamepads(there is no standard full on standard if you aren't using XInput devices), I've seen the directional buttons actually register as buttons instead of axes. Are you literally checking all of the buttons? Have you opened up the gamepad in the Windows control panel to see if everything is registering there?
 
T

Tofu Heavy Industries

Guest
Using Windows 7, if the controller(s) are plugged in, and I go to Devices/Printers> game Controller > Properties ; Moving the d-pad moves the "Point of view hat" arrow cursor.

In the FCEU emulator, going to controller config, pressing up = "hat 0:0", down = "hat 0:2", right = " hat 0:1", left = "hat 0:3" .

I have not tried (in a long time) mapping the directions to gp_pad, but it is a SNES USB controller, so the four "gp_face" buttons are already spoken for. Even if it were a NES USB, that would only leave 2 face buttons for the four directions.
 

kburkhart84

Firehammer Games
You are going to have to use the Point of View Hat instead of the axes when trying to access those in GMS then. It will be gamepads 4 - 11, as 0 - 3 are XInput devices. There is a different function for that, called gamepad_hat_value().
 
Top