NeoShade
Member
So I've been playing around with setting up some gamepad stuff, and figured I would start by nailing down the whole connected/disconnected thing. This is what I've got to start with:
This is obviously running in the async system event, and an array has been set up in the create event of the same object. So far, these are the only objects in the room.
I'm also using the array to draw sprites for each controller, to give be an idea of what's connected and what's disconnected.
My problem is this: Plugging my controllers in (or connecting them with bluetooth) works fine. The array populates exactly as expected, and the sprites and debug messages all appear in the correct order. However, when I unplug the controllers, they tend to register a disconnect event for more than one of them at a time, resulting in some very weird issues.
I'm using 8BITDO NES30 Pro gamepads, which I admit can sometimes be a little finicky to get set up, but I've found them to be a really cool pad when they're working. I'd really like to either rule the controllers out as the source of the problem, or prove that they are the source of the problem, so I was hoping that somebody else with 4 USB controllers might be able to give my code a quick run and see if you're experiencing the same issue?
Otherwise, if anybody can see anything obvious that I've got wrong, can you please let me know?
Thanks very much in advance.
Code:
// Save the async_load data into temporary variables for easier use.
var event = async_load[? "event_type"];
var padid = string(async_load[? "pad_index"]);
// Show debug messages whenever a gamepad is connected or disconnected.
// Also update the gamepads array when a controller is connected or disconnected.
switch (event)
{
case "gamepad discovered":
show_debug_message("Gamepad " + padid + " has been connected.");
for (var i=0; i<4; ++i)
{
if (gamepads[i] == noone)
{ gamepads[i] = padid; break; }
}
break;
case "gamepad lost":
show_debug_message("Gamepad " + padid + " has been disconnected.");
for (var i=0; i<4; ++i)
{
if (gamepads[i] == padid)
{ gamepads[i] = noone; break; }
}
break;
}
I'm also using the array to draw sprites for each controller, to give be an idea of what's connected and what's disconnected.
My problem is this: Plugging my controllers in (or connecting them with bluetooth) works fine. The array populates exactly as expected, and the sprites and debug messages all appear in the correct order. However, when I unplug the controllers, they tend to register a disconnect event for more than one of them at a time, resulting in some very weird issues.
I'm using 8BITDO NES30 Pro gamepads, which I admit can sometimes be a little finicky to get set up, but I've found them to be a really cool pad when they're working. I'd really like to either rule the controllers out as the source of the problem, or prove that they are the source of the problem, so I was hoping that somebody else with 4 USB controllers might be able to give my code a quick run and see if you're experiencing the same issue?
Otherwise, if anybody can see anything obvious that I've got wrong, can you please let me know?
Thanks very much in advance.