Windows Issues when connecting and then disconnecting a PS4 controller

A

Angel González

Guest
Hey guys, good day!

Hope you could help me with this little issue I'm having.

Currently I'm working on the feature of allowing players to use a PS4 controlller, but when I connect and then disconnect a PS4 controller, the game stops working.

I thought it was something with my project so I created a new one with just one empty room and no objects, and then did the same action (connect and disconnect the controller) and the issue persisted on this new fresh project.

Is there a way to prevent the game stop working after connect and disconnect the controller or is this an expected behavior related to Windows 10?

FYI I haven't tried with a X360-ONE controller as I currently don't have one.

Thanks in advance for the help!
 
N

nicktheslayer95

Guest
I have this issue too, I suspect it may be related to how the program I use to make the PS4 controller compatible interacts with Windows, and subsequently, Game Maker. I assume you're using DS4Windows by Jays2Kings, right?
 
T

trentallain

Guest
I have this issue too, I suspect it may be related to how the program I use to make the PS4 controller compatible interacts with Windows, and subsequently, Game Maker. I assume you're using DS4Windows by Jays2Kings, right?
You can use a PS4 controller with GameMaker without software if you check it in slots 4 and above.
 
A

Angel González

Guest
@nicktheslayer95 and @trentallain thanks for the reply!

Actually, I'm not using any kind of program to use the PS4 Controller on Win 10. Just like @trentallain says, I only check in slots 4 and above :)

Just as an FYI, Windows 10 recognize the controller as a Wireless Controller, hope this info could help.
 
Last edited by a moderator:
N

nicktheslayer95

Guest
Well, I'm glad I dropped in then, I'll have to find out how to check for this myself. Is there any known way to discern the difference between an XBOX or PS4 controller in Game Maker? I'd really love to change the button icons in my game accordingly.
 

NightFrost

Member
Well, I'm glad I dropped in then, I'll have to find out how to check for this myself. Is there any known way to discern the difference between an XBOX or PS4 controller in Game Maker? I'd really love to change the button icons in my game accordingly.
Use gamepad_get_description. But your code needs to make a snap judgment about what icons to display when controller not on your list. Pseudocode
Code:
if(type == xbox){
   // Use xbox icons
} else if(type == ps4){
  // Use ps icons
} else {
  // Use xbox icons
}
 

Yal

🐧 *penguin noises*
GMC Elder
I've heard that the functions to get the controller's name can be used for this, PS4 controllers has a name along the lines of "DUALSHOCK4" and XBOX controllers then has... something else. I'm just assuming people use XBOX controllers since they're the de facto standard. PS controllers has some additional caveats because the button layout is different in different regions because cultural meanings of Os and Xs...
 
A

Angel González

Guest
Hey guys, reporting again!

After updating to the latest version of GM2 (2.0.7.171) the issue is still happening :(

So I tested on GM 1.4.1763 and here the game is still running if I connect and then disconnect the PS4 controller. So I believe this issue is only happening on GM2 for some reason.

By the way, I haven't tested with a XBOX controller, don't have one at the moment, so need to get one.

I really hope this issue gets fixed in a future because it's quite a blocking for some users who only have PS4 controllers (just like me), in the mean time, I'll work on polishing the gameplay/scripts of my game ;)

FYI, Hyper Light Drifter allows to connect and disconnect a PS4 controller without breaking the game, but I believe the game is made on GM 1.4.x
 

obscene

Member
Most likely your controller is being detected at both 0 and 4 at the same time.

This is my code currently and it seems to work most of the time...

Code:
/// Detect Controller

show_debug_message("Event = " + async_load[? "event_type"]);        // Debug cocde so you can see which event has been
show_debug_message("Pad = " + string(async_load[? "pad_index"]));   // triggered and the pad associated with it.

switch(async_load[? "event_type"])             // Parse the async_load map to see which event has been triggered
    {
    case "gamepad discovered":                     // A game pad has been discovered
        var pad = async_load[? "pad_index"];       // Get the pad index value from the async_load map
        gamepad_set_axis_deadzone(pad, .05+obj_controller_system.deadzone*.2);       // Set the "deadzone" for the axis
        gamepad_set_button_threshold(pad, 0.1);    // Set the "threshold" for the triggers
        gamepad = pad;
        break;
       
    case "gamepad lost":                           // Gamepad has been removed or otherwise disabled
        var pad = async_load[? "pad_index"];       // Get the pad index
        gamepad = noone;                   // Set the controller array to "noone" so it detects a new pad being connected
        break;
    }
   
// Select Xinput for double-detected devices
if gamepad_get_device_count() > 1
    {
    gamepad=0;
    while !gamepad_is_connected(gamepad)
        {
        if gamepad>7 //
            {
            gamepad=-4
            break;
            }
        gamepad+=1;
        }
    gamepad_set_axis_deadzone(gamepad, .05+obj_controller_system.deadzone*.2);
    gamepad_set_button_threshold(gamepad, 0.1);              
    }

show_debug_message("gamepad: " + string(gamepad));
if gamepad>=4 gamepad_description="DirectInput Gamepad: " + gamepad_get_description(gamepad);
else if gamepad>=0 gamepad_description="XInput Gamepad: " + gamepad_get_description(gamepad);
else gamepad_description="No Gamepad Detected";

// Detect Type
var desc=string_lower(gamepad_description);

// Xbox
if string_pos("box",desc) || string_pos("360",desc) || string_pos("f310",desc) || string_pos("f710",desc)
    {
    global.gamepad=0;
    scr_gamepad_set_buttons();
    }
// Dualshock
else if string_pos("ps",desc) || string_pos("station",desc)
    {
    global.gamepad=1;
    scr_gamepad_set_buttons();
    }
// Generic
else if string_pos("rumblepad",desc)
    {
    global.gamepad=2;
    scr_gamepad_set_buttons();
    }
 
Last edited:
A

Angel González

Guest
Hey @obscene, thanks a lot for the reply!

This is interesting, maybe that's the reason GM2 is setting the PS4 controll as a "Wireless Controller".

As an FYI, I've also tested on a new fresh project with only one room and no objects and the behavior is the same, the game breaks up if I connect and then disconnect the PS4 controller.
 
Top