1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

PS4 controller struggles

Discussion in 'Programming' started by TearyLilium, Nov 8, 2019 at 6:25 PM.

  1. TearyLilium

    TearyLilium Member

    Joined:
    Friday
    Posts:
    5
    I'm trying to figure out how to use a PS4 controller for my game. There is an extremely weird thing going on... So if I check for gamepad_is_connected(i) stuff it does recognize that my controller is connected and in the slot 0. If I look into the list of connected controllers, it does say that it is connected and the slot is occupied... But then if I try to have any input it doesn't seem to work?
    if (gamepad_button_check(0, gp_face1))
    show_message("something");

    But.... apparently if I start compiling the game and I hold that gp_face1 button before it finished compiling, it will work at the very first second as the game starts and it keeps triggering it all the time afterwards even if I'm not holding the button anymore. That's why i'm very confused because clearly the controller can be read by gms2 and it recognizes it and the inputs... but it doesn't work like it should work?

    also if I create an async system event and put this code in there
    var type = async_load[? "event_type"];
    var index = async_load[? "pad_index"];
    if (type == "gamepad discovered")
    { show_message("Controller connected: " + string(index));
    } else
    {
    show_message("Controller disconnected: " + string(index));
    }

    at the beginning of the game it says "Controller connected: 0" and then immediately "Controller disconnected: undefined" after that...
    So it feels like the controller works the very first moment when the game starts and then it immediately disconnects?
     
  2. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    56
    You are not checking for "gamepad lost" .. so any other event that is not "gamepad discovered" would trigger the disconnect message .. the fact that "pad_index" is undefined makes it clear that it wasn't even a pad event
     
  3. TearyLilium

    TearyLilium Member

    Joined:
    Friday
    Posts:
    5
    Well that point still remains... It does register the input the moment the game starts and then immediately stops doing anything which is so confusing to me
     
  4. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    56
    Code:
    var type = async_load[? "event_type"];
    switch(type){
        case "gamepad discovered":
        case "gamepad lost"
            var index = async_load[? "pad_index"];
            show_debug_message(type + string( index ));
        break;
    }

    Your code:
    Code:
    if (gamepad_button_check(0, gp_face1))
    show_message("something");

    ..looks just fine .. so I'm really not sure what the problem could be .. I guess it is in a step event?
     
  5. TearyLilium

    TearyLilium Member

    Joined:
    Friday
    Posts:
    5
    Yeah looks just fine to me too, I actually did try the gamepad lost thing too and yeah the controller doesn't disconnect unless I unplug it from the pc
    And yeah it is in a step event, I have no idea what the problem might be
     
  6. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    56
    Try this in the draw event:
    Code:
    draw_text(x,y,string(gamepad_button_value(0,gp_face1)) + " force of " + string( gamepad_get_button_threshold(0) ) + " needed" )
    This is a button pressure test for gp_face1 and it displayes the needed threshold for it to be a press (which should be 0.5 by default)
     
  7. TearyLilium

    TearyLilium Member

    Joined:
    Friday
    Posts:
    5
    Yep it does say "0 force of 0.50 needed" but if I press the button, nothing happens at all... no signs of the button being pressed at all sadly
     
  8. TailBit

    TailBit Member

    Joined:
    Oct 16, 2019
    Posts:
    56
    Do you maybe have a program active in the background that turns gampad button presses into keyboard presses? .. I'm really running out of ideas here.
     
  9. TearyLilium

    TearyLilium Member

    Joined:
    Friday
    Posts:
    5
    Not at all..
    it feels like it must be a bug with gamemaker studio or something? becuase that's definitely not something that should usually happen...
    and so I actually just tried a DS4Windows program so that my windows interprets my PS4 controller as an Xbox one and things started working then!
    So it's definitely some weird bug that gms doesn't like PS4 controllers or something, it looks..
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice