Problem with multiple gamepads (they act as one gamepad)

mX273

Member
Hi Guys

I have a strange problem with my gamepads. I use 8 Gamepads called "MICREAL Wireless Controller" which are configured as XInput Controllers.
In the configuration of windows, they all work correctly and independent:
Gamepads.png

I wrote a little Testprogram to find out, which gampad uses which slot:

GML:
for (var i = 0; i < 12;i++)
{
    for (var k = gp_face1; k < gp_axisrv; k++)
    {
        if (gamepad_button_check(i, k))
        {
            draw_text(50 + i*40,100, string(i))
        }
    }
}
when i press a single button of a single gamepad, i get many slots at the same time. For example "4 5 6 7 8 ". If i unplug some of them, then plug it in again and restart the application, there are sometimes oher gamepads linked together. Very strange.
I didnt find a rule. The problem seems to be in game maker, because in the windows dialog they always work correctly. I also tried it when I configured some of them (up to 4) as XBox 360 controller) - same problem.

Can you help me?

Kind regards

mX273

can you help me
 

kburkhart84

Firehammer Games
I don't know what is going on for sure with your pads. But I CAN tell you that XInput only supports 4 devices(IDs 0 to 3). I can ALSO tell you that normal XBOX gamepads also show up as DirectInput devices, and so it is normal for those to show up both as some device between 0 and 3 and then ALSO show up as something between 4 and 11. It is certainly possible that your gamepads are doing something similar.

In my input system, I handle that by storing a device id along with the actual input(button/axis) as they get assigned to actions. I don't assign gamepads to players, rather individual actions. So a given action(like player 1's jump action) knows it is using gamepad 2, button 5, and so on and so on. The player has to actually hit the button to assign it to the action. By forcing the actual input to happen to assign it, my input system can check for the XINPUT versions first(IDs 0 to 3), and then checks the rest of the indices. This means that even if the device comes up multiple times, it registers the better version first(XINPUT has better support, and the DInput version has certain gotchas/glitches).

So indeed, if you are running into the same thing I am referring to, the solution is simply to ignore the gamepad IDs higher than 3 if you detect multiple at the same time. If however you are finding multiple with both values higher than 3 and NONE below 3, then you have a completely different issue.
 

mX273

Member
Ok, thank you for that info! I didnt know that it is normal for some gamepads to use 2 slots at the same time. Sorry, in this case i wrote it wrong. they are usually configured as DirectInput device (Slot 4..11). To change my input configuration like your description, it would be a huge effort now... i use gamepad-objects which are linked with a player-object by a reference.
Strange is, that there are sometimes used so many slots for 1 gamepad (e.g Slot 4, 5, 6, 7 and 8) - so i dont think it is the same issue as you described (with a single XInput and DirectInput Slot).
 

kburkhart84

Firehammer Games
Ok, thank you for that info! I didnt know that it is normal for some gamepads to use 2 slots at the same time. Sorry, in this case i wrote it wrong. they are usually configured as DirectInput device (Slot 4..11). To change my input configuration like your description, it would be a huge effort now... i use gamepad-objects which are linked with a player-object by a reference.
Strange is, that there are sometimes used so many slots for 1 gamepad (e.g Slot 4, 5, 6, 7 and 8) - so i dont think it is the same issue as you described (with a single XInput and DirectInput Slot).
If there is more than 2 being used, and they are all over 3(as in 4 - 12), then certainly it isn't the issue I brought up. I've never seen this issue myself honestly. Though I've never tried 8 identical gamepads on the same system either. I've done several gamepads all at once, but all different(except I've used multiple gamecube ones connected through an adapter that has 4 gamecube controller ports). I've never had issues with gamepads showing up separately though.
 

mX273

Member
It seems so. Anyway, how could i save and reload the input configuration? Unfortunately the IDs of all 8 Gamepads are the same and the Slots are not always the same (for example after a reboot of my computer, they can change).
 

kburkhart84

Firehammer Games
My input system currently does it just using the gamepad id(which rarely changes in my experience, even after reboots, though it happens every now and then). However, my next update is going to have it use GUIDs instead so that if the normal ids change I'll be able to detect that. It wouldn't help in your case since you seem to have a bigger issue though. You may have to do something much less extreme as using 8 identical gamepads unless you can figure out how to get around that issue.
 
However, my next update is going to have it use GUIDs instead so that if the normal ids change I'll be able to detect that. It wouldn't help in your case since you seem to have a bigger issue though.
If they're really identical controllers, they'll have the same GUID.
One of the thing is he's trying to use 8 DirectInput controllers as Xinput, which only 4 can be supported. That can only do no good.
Another thing to look for would be if the USB receiver can actually manage 8 controllers?
First, I would ditch all Xinput conversion, reboot the machine, and if that doesn't solve it, look at the hardware documentation online. This may not be GMS-related at all.
 

FoxyOfJungle

Kazan Games
when i press a single button of a single gamepad, i get many slots at the same time. For example "4 5 6 7 8 ". If i unplug some of them, then plug it in again and restart the application, there are sometimes oher gamepads linked together. Very strange.
I didnt find a rule. The problem seems to be in game maker, because in the windows dialog they always work correctly. I also tried it when I configured some of them (up to 4) as XBox 360 controller) - same problem.

The simplest approach is for you to check if the joystick is connected:

GML:
for (var i = 0; i < 12; ++i;)
{
    if gamepad_is_connected(i)
    {
        key_1 = gamepad_button_value(i, gp_face1);
        key_2 = gamepad_button_value(i, gp_face2);
    }
}
And you don't need two for loops for that.
 

kburkhart84

Firehammer Games
If they're really identical controllers, they'll have the same GUID.
One of the thing is he's trying to use 8 DirectInput controllers as Xinput, which only 4 can be supported. That can only do no good.
Another thing to look for would be if the USB receiver can actually manage 8 controllers?
First, I would ditch all Xinput conversion, reboot the machine, and if that doesn't solve it, look at the hardware documentation online. This may not be GMS-related at all.
I think the OP said they miswrote, and that it was all DirectInput devices instead of XInput. That's why I I mentioned my original response about double detection between DInput and XInput as well.

Take a look at Input by Juju and save yourself a ton of headaches.
Doesn't that still use native GML and just add stuff on top of it. Unless I'm wrong about that, it won't fix the issue so easily since GM itself is somehow detecting inputs on multiple gamepad IDs. My input system wouldn't fare any better for the same reason, since it uses GML only and just adds on top of it. If I'm wrong and Juju's system does more than what is available in vanilla GML, then there is that.
 

rIKmAN

Member
Doesn't that still use native GML and just add stuff on top of it. Unless I'm wrong about that, it won't fix the issue so easily since GM itself is somehow detecting inputs on multiple gamepad IDs. My input system wouldn't fare any better for the same reason, since it uses GML only and just adds on top of it. If I'm wrong and Juju's system does more than what is available in vanilla GML, then there is that.
I've tested 4 XB1 controllers that all identify identically in Windows and they all work fine and independently in the multiplayer test case example that is part of Input (once I added code to check extra controllers which is a couple of lines) as well as K&M at the same time.

If the issue is that which Slow Fingers mentioned re: XInput however then that's different.

Either way it would take less than 5mins to download Input and run the multiplayer example and see - maybe 10mins to duplicate some code and tweak some values to allow testing for 8 controllers.

If it works then all the hassle it saves will be worth the time spent testing it out as it handles hotswapping, rebinding, input assignments, has an input history, double press detection all built in etc and supports loads of controllers out of the box as it uses the SDL2 Game Controller Community DB.

It's awesome and I can't recommend it enough - well worth 5mins of OPs time to see if it solves their issues.
 
I think the OP said they miswrote, and that it was all DirectInput devices instead of XInput. That's why I I mentioned my original response about double detection between DInput and XInput as well.
Yeah, I just saw that. Well, this is one less thing to worry about!

@mX273: when you say it 'would require a major effort', that raises some questions on my end. Like, did it work and now it's broken? Or did you move on to other stuff knowing the input system was broken? Is this just happening with this particular combination of controllers? Did you try to add multiplayer code after most of the game was completed?
If we knew a little more about the backstory, that would very much help us help you.
 

mX273

Member
Thany you so much for your reply.
Ok im going to ckeck the input system of juju.

The problem is that i already designd my game menu like this. Every player who wants to play in the next game battle has to press start. Then a obj_gamepad object with the corresponding slot is generated... the menu and animations and so on are already generated.
It sometimes works with 8 controllers the way i like, so i thought i could solve that problem later :-(
 

mX273

Member
Unfortunately I can't check the input system of juju, because i still work with version 2.2.5 until my game is finsihed.
I found out, that close and start the game helps sometimes with the multiple slots used for a single controller. A game_restart() doesnt help. i have to close it manually first :-/

any ideas why?
 

rIKmAN

Member
Unfortunately I can't check the input system of juju, because i still work with version 2.2.5 until my game is finsihed.
Ah that's a shame - there is a legacy version of Input that works with 2.2.5 if you still wanted to try it: https://github.com/JujuAdams/input_legacy
It no longer receives updates but I don't remember there being any massive issues with it (though I may be wrong) - would still be worth a try just to see if it works with your 8 controllers and rule out a system / OS level problem.
 

rIKmAN

Member
Thank you!! Im going to test it!
Cool, let us know how it goes.
I'm not sure if the legacy 2.2.5 version has the same features/functionality at the latest 2.3 version or has the built in test cases, so it may be a bit more work to setup a test for the 8 controllers and it ultimately might not work at all.
As I say it's worth testing though for the headaches it could save later if it does work. Nothing gained, nothing ventured and all that.

EDIT:
Just had a quick chat with Juju and he said it should be fine given they are DInput controllers.
Specify the maximum number of players in the config and each function takes a playerIndex as an argument.

As I said though you will probably have to code the test cases yourself as they aren't included in the legacy version by default so it might take a bit more time.
 
Last edited:

mX273

Member
can you give me a tip. I dont understand what that example should help. I didn't find a multiplayer example. only an example
which recognizes if a gamepad is connected. Then it ask i would like to swap it? huuuh? swap with what?
By the way i extended it from 2 to 8 players:
input_set_max_players(8);
But I can't see any difference... there is only one ball which i can control with one of the gamepads.

input.png

Can you help me?
 

rIKmAN

Member
can you give me a tip. I dont understand what that example should help. I didn't find a multiplayer example. only an example
which recognizes if a gamepad is connected. Then it ask i would like to swap it? huuuh? swap with what?
By the way i extended it from 2 to 8 players:
input_set_max_players(8);
But I can't see any difference... there is only one ball which i can control with one of the gamepads.

View attachment 40521

Can you help me?
Yeah I just edited my last post as you posted - the legacy version doesn't have the multiplayer test cases in it, so you would have to write the code yourself to set it up and test them.
I haven't used the legacy version for a long time, but from memory it's just a an example to allow you to hotswap controllers, you'd need to edit/write your own code to allow 8 simultaneous pads controlling a ball each.
 

rIKmAN

Member
ohhh.... what a pitty. ok thanks a lot anyway!
Okay so I spent some time modifying the legacy example for you to allow 8 players to be connected - though I could only test with 4 as I only have 4 XB1 controllers handy, however it should work with upto 8.

I DM'd you the link to the project.

1) Run the project
2) Connect your pads one by one - the message that pops up is for debug purposes so click "Yes" and a new player will be added to the game.
If they are already connected when you start the game then the dialog will still popup - again click "Yes" to add the player to the game.
3) Do this for upto 8 controllers - each ball will be controlled by adifferent pad and are all marked on screen as to what player they are.
4) If you disconnectany pad a debug message will popup telling you what player disconnected, and that player will be removed from the game.

You can try disconnecting/reconnecting different pads and see what happens, I didn't do too much testing with that but it appeared to work fine and slots were freed and re-populated when reconnectiong without any issues.
Take a look at the modified code and it should give you a gopod idea of how to implement it into your existing game.

Let me know if it works for all 8 of your controllers or not - hope it helps!
 

mX273

Member
thank you so much for your effort! i only could test it with my beta version v2.3. there is an error as soon as i connect the first gamepad:
error.png
 

rIKmAN

Member
thank you so much for your effort! i only could thest ist with my beta version v2.3. there is an error as soon as i connect the first gamepad:
View attachment 40531
You said you were using v2.2.5, so I edited the legacy 2.2.5 version - load it into 2.2.5, it won't work in 2.3 due to the changes between versions.

If you are able to use v2.3 then just download the latest version as I said about 8 posts back and you could have saved me the time!
 

mX273

Member
1.png

I dont know what i did wrong the last time. A double click on the *.yyz file opens it in my beta 2.3. If i drag n drop it into my gm 2.2.5 i can import it (didnt work the last time).
Anyway, I could control up to 4 players. On some connected gamepads an error occured as in the screenshot above. any ideas?
 

rIKmAN

Member
View attachment 40534

I dont know what i did wrong the last time. A double click on the *.yyz file opens it in my beta 2.3. If i drag n drop it into my gm 2.2.5 i can import it (didnt work the last time).
Anyway, I could control up to 4 players. On some connected gamepads an error occured as in the screenshot above. any ideas?
No but I noticed that the first 4 slots are empty in the text in the top left.
If you disconnect all controllers, run the game and then connect them one by one, do they get connected starting from 0 or from 4?

I used 4 XB1 controllers and they connected from 0-3 (the top 4 lines in the debug text at the top left) but I only have those 4 controllers handy to use so couldn't test anymore than that.
 

mX273

Member
error1.png


There are no slots used from 0...3. only higher or equal 4 (4...11). The upper 4 numbers stay -1. It pop up the message box and if I click "yes" the error (last post) occurs on the last 4 gampads I try to connect.
I forgot to say, there was an error after the import (picture above).
I'm going to get some sleep now. checking tomorrow for more replys. thank you and good night :)
 
Last edited:

rIKmAN

Member
View attachment 40536


There are no slots used from 0...3. only higher or equal 4 (4...11). The upper 4 numbers stay -1. It pop up the message box and if I click "yes" the error (last post) occurs on the last 4 gampads I try to connect.
I forgot to say, there was an error after the import (picture above).
I'm going to get some sleep now. checking tomorrow for more replys. thank you and good night :)
To save wasting any more time as we just want to establish whether it will actually work - now you have said you do actually have access to v2.3 then just download the latest version of Input and test that.

There is an "obj_test_mp" object in the "Test Cases" folder that you can drag into the room, modify easily enough to check for 8 players and that should tell us whether it's worth persuing or not. Remember to delete the existing "rm_example" from the room when adding "rm_test_mp".

EDIT:
I DM'd you another link to a modified project to test before you try the v2.3 version of Input.
 
Last edited:

mX273

Member
No I have no access to v2.3, only v2.3 BETA which runs in a seperate installation directory. If i would update to 2.3,(not Beta) my 2.2.5 Version would be overwritten.
I tested your modified version of the input system (v2). After i say "yes" to the fifth controller it pops up the following error:

error.png
 

rIKmAN

Member
No I have no access to v2.3, only v2.3 BETA which runs in a seperate installation directory. If i would update to 2.3,(not Beta) my 2.2.5 Version would be overwritten.
I tested your modified version of the input system (v2). After i say "yes" to the fifth controller it pops up the following error:

View attachment 40546
We're just trying to see if Input would work for your purposes at the moment and whether it's worth persuing over your previous method so feel free to try the 2.3 version of Input in the 2.3 beta.
I don't have 8 DInput controllers so it makes it difficult to make quick changes/edits in response to errors like I could if I did have them handy.

In saying that, try setting input_set_max_players to 12, disconnecting all controllers, running the program and connecting them one by one again.
It's likely my quick edits that are issue as they were made without being able to test them - I have 4 XInput pads.

There's no need to post pictures of the error message, just copy the text and paste that in a code tag.
 

mX273

Member
i tried it in the beta. as soon as i connect the first controller the following error occur:

___________________________________________
############################################################################################
ERROR in
action number 1
of Async Event: System Event
for object obj_input:

Unable to find a handler for exception { longMessage : ERROR in
action number 1
of Async Event: System Event
for object obj_input:

illegal array use
at gml_Object_obj_input_Other_75 (line 6) - if (gamepad_device < 0)
, script : gml_Object_obj_input_Other_75, line : 6, stacktrace : [ "gml_Object_obj_input_Other_75 (line 6)" ], message : illegal array use }
NO CALLSTACK
at gml_Object_obj_input_Other_75 (line 6) - if (gamepad_device < 0)
############################################################################################
gml_Object_obj_input_Other_75 (line 6)
 

rIKmAN

Member
i tried it in the beta. as soon as i connect the first controller the following error occur:

___________________________________________
############################################################################################
ERROR in
action number 1
of Async Event: System Event
for object obj_input:

Unable to find a handler for exception { longMessage : ERROR in
action number 1
of Async Event: System Event
for object obj_input:

illegal array use
at gml_Object_obj_input_Other_75 (line 6) - if (gamepad_device < 0)
, script : gml_Object_obj_input_Other_75, line : 6, stacktrace : [ "gml_Object_obj_input_Other_75 (line 6)" ], message : illegal array use }
NO CALLSTACK
at gml_Object_obj_input_Other_75 (line 6) - if (gamepad_device < 0)
############################################################################################
gml_Object_obj_input_Other_75 (line 6)
As I said before the 2.2.5 project won't work in the v2.3 beta - I meant download the 2.3 version of Input and try that in the Beta.

However - in v2.2.5 of the IDE, load the last modified project I sent you (v2) and try changing input_set_max_players to 12, disconnect all controllers, run the project and then reconnect them one by one and see if that changes anything with regards to the error you posted in post #30
 
Top