SOLVED GamePad laggy input Help

Adro

Member
Hey there fellow game makers,

I'm new to using GamePads and I'm having some problems. I'm using really simple code to get my gamepad input, but it won't animate cleanly like the keyboard controls--in fact adding the GamePad input causes both inputs to lag.

My system and animation worked fine with just keyboard input, and will animated correctly if I negate the gamepad_set_axis_deadzone function, but then the obviously this creates a different type of broken.

Any suggestions would be much appreciated. I might need to overhaul whole my input system, but thought I'd check with others more experienced first.

Much thanks.

GML:
// CREATE EVENT
}
    // set up gamepad deadzone
    gamepad_set_axis_deadzone(0, 0.5);
    
}

// STEP EVENT
 if (state == states.idle)
 {
 
        player_speed = 0;
        image_speed = 0;
 
        // change states if direction is given
        if (keyboard_check(vk_left) == true) or (gamepad_axis_value(0, gp_axislh) > 0) state = states.moving;
        if (keyboard_check(vk_right) == true) or (gamepad_axis_value(0, gp_axislh) < 0) state = states.moving;
        if (keyboard_check(vk_up) == true) or (gamepad_axis_value(0, gp_axislv) < 0) state = states.moving;
        if (keyboard_check(vk_down) == true) or (gamepad_axis_value(0, gp_axislv) > 0) state = states.moving;
    }
    
    ...
    
    else if (state == states.moving)
    {
        
        // movement commands
        if (keyboard_check(vk_left) == true) or (gamepad_axis_value(0, gp_axislh) < 0)
        {
                // set player speed and animation speed
                player_speed = player_speed_normal;
                image_speed = 1;

                // check for collision
                if (place_meeting(x-2, y, objSolid) == false)
                {
                    direction = 180;
                    if (!strafing)    sprite_index = LEFT_SPRITE;
                    image_speed = 1;
                }
        }
    
    ...

        // change state back to idle
        if keyboard_check_released(vk_left)    or (gamepad_axis_value(0, gp_axislh) == 0)    state = states.idle;   
        if keyboard_check_released(vk_right) or (gamepad_axis_value(0, gp_axislh) == 0)    state = states.idle;   
        if keyboard_check_released(vk_up)     or (gamepad_axis_value(0, gp_axislv) == 0)    state = states.idle;   
        if keyboard_check_released(vk_down)  or (gamepad_axis_value(0, gp_axislv) == 0)    state = states.idle;   
    }
}
Obviously this isn't all of the exact code, this is just the left movement as an example of the system. Let me know if you need more code for better clarification.

Adro
 

kburkhart84

Firehammer Games
I'd suggest either having a much smaller dead zone(maybe like 0.1). Or simply not having a dead zone and check axis values above that same value. My input system doesn't use the system's dead zones, rather you have a value that constitutes the axis being "down" or not.

You also need to check your code logic. I think your problem(which could be fixed by stopping the deadzone and using a small value directly instead) is that you wait until either the keyboard key is released or until the axis of the gamepad is EXACTLY 0. The same thing that makes you think you need a dead zone is the same thing that is going to cause you issues in this manner. It isn't exactly easy to make a gamepad axis be exactly 0.
 

Adro

Member
Solved.

You're recommendations helped a lot kburkhart84. My poorly designed or band-aid designed input system need improvement also. The two combined helped a lot. Basically I was getting input multiple times in the one step which was causing the problem. I get input once at the start of the step event only which fixed the problem immediately, combined with manual deadzones.

Cheers!
 
Top