• 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!

Legacy GM Issue Dealing with Using Two Gamepads

M

MrFlippy

Guest
I must be the most unlucky GM:S user of all time since my problems are usually those that rarely ever happen to anyone!

Well anyway, my issue is once again related to gamepads.

I've created a notification system that tells you when you've plugged in a gamepad, and it works:

On 'System' Event...
Code:
//Gamepad 1
if (gamepad_is_connected(0))
{
    if (CanCreateNotification = true) //P.S., I like my code uncompressed, don't judge.
    {
        instance_create(-4,16,Obj_NT_Gamepad);
        CanCreateNotification = false;
    }
}
else
{
    if (CanCreateNotification = false)
    {
        instance_create(-4,16,Obj_NT_Gamepad);
        CanCreateNotification = true;
    }
}
But the issue I'm having is a little hard to explain, which is why I've created a video that shows the issue as it's happening. I'll try to explain, though:

A second after plugging in the first controller (which by the way, is in slot 0), Obj_Control's Draw Event tells me that gamepad_is_connected(1) is true when I haven't plugged in the second gamepad yet! A little less than a second after that, it goes back to false.

Now, if I also plug in my second controller, the same thing happens on the third gamepad slot and tells me that gamepad_is_connected(2) is true when it shouldn't be! The question is...

How can I make GM:S NOT mark gamepad_is_connected(1) as true when ONLY gamepad_is_connected(0) is true?


If there are any questions that can help in resolving this issue, please do ask!!

Video:
 
M

MrFlippy

Guest
I still need help! I hope I'm not too early to bump, and if so, sorry! I know this may be a complicated issue, but everything has a solution (which of course, I'm trying to find). Hope that within at least one week I get some advice!
 

hogwater

Member
A single XInput pad will show up in slots 0 and 4 simultaneously if plugged in after a game starts. DirectInput pads only show up in slots 4+. Strangely enough when I plug in an XInput pad before a game starts it only takes up slot 0.

That may be the source of the confusion, I was just dealing with this recently myself.
 
M

MrFlippy

Guest
So sorry for my late response @hogwater!

Is there anything I can do or anything that you did to solve this issue if you solved it somehow? With my notification system, because it does this, whenever I plug in my first gamepad, I get not only the Gamepad 1 notification but the Gamepad 2 notification as well.
 

hogwater

Member
I'm making a single player game, so I just put the pad_index in a variable and set the buttons differently for XInput and DirectInput. Check the thread I made recently, obscene had a method for selecting the lowest pad_index that he uses.
 

Jakylgamer

Member
async - system event:
Code:
var gp_num = gamepad_get_device_count();
for (var i = 0; i < gp_num; i++;) {
      if gamepad_is_connected(i)
         global.gp[i] = true
      else
         global.gp[i] = false;
}
i forget if gms1.x has the async system event but that will check only when a gamepad is plugged in or unplugged.
tho in that event i have had the game crash if i plug in a gamepad and then unplug it again (sometimes not all the time).
 
M

MrFlippy

Guest
Hey @Jakylgamer! I tried your code but sadly it did not work and the issue still remains. :(

I'll check out what @hogwater said after I get some sleep. If I'm still having trouble in around a week, I'll come back to this thread. For now, thank you guys for trying to help me with this!
 
M

MrFlippy

Guest
I'm sure that might be the best help, but everything in my project is very disorganized—at least for now. Besides that, I like to keep my projects very close to me; I don't usually share my codes with anyone. If this becomes an issue so serious that I have to upload my project file, then I might. :p

Thank you though!! I'll keep trying to find what to do.
 
M

MrFlippy

Guest
Oh! Got ya. I'll do that once I get home. Sorry, I've been so busy that I almost forgot about my issue. :p
 

kburkhart84

Firehammer Games
When you get the notification, couldn't you just hold off(set an alarm or something) before doing final confirmation. You could then do the confirmation and the time in which you find the 'extra' gamepad would have passed.
 
M

MrFlippy

Guest
Hmmm... that gives me an idea. I'm gonna try something like that. If things work out (or don't), I'll come back to the thread. Though, in the meantime, I hope there are other solutions to this. Thanks, @kburkhart84!
 
M

MrFlippy

Guest
Update: I couldn't find the right solution to the problem so I simply removed my game's code to determine which gamepad is connected or how many gamepads are connected. Basically, problem solved- kinda! Thanks to everyone for the help. :D
 
Top