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

SOLVED XInput name?

Neptune

Member
So it seems a lot of XInput controllers, with varying button configuration like Switch vs Xbox, have the exact same gamepad_get_description in GMS2 - "XInput STANDARD GAMEPAD"

Is there any other way to parse out and differentiate what kind of controller it is WITHOUT having the player need to tell us?
At least for the big ones like Switch, Xbox, PS (though PS seems to have an easily parsed named)
 

kburkhart84

Firehammer Games
So it seems a lot of XInput controllers, with varying button configuration like Switch vs Xbox, have the exact same gamepad_get_description in GMS2 - "XInput STANDARD GAMEPAD"

Is there any other way to parse out and differentiate what kind of controller it is WITHOUT having the player need to tell us?
At least for the big ones like Switch, Xbox, PS (though PS seems to have an easily parsed named)
You should be able to use the GUID to do it. However, since with XInput, the controllers all should have the same stuff(even if it is slightly in a different position), it shouldn't matter. That is actually kinda the whole point of XInput as compared to DInput supporting all the different things.

Also, last I heard, the switch wasn't natively supported by Windows or XInput, and so if it is working properly, it has a 3rd party driver doing it. The PS3 DualShock was the same way, requiring 3rd party stuff to work. In those cases, the user had to find the driver themselves and install it, and likely has an idea what is going on and what to expect. So in my opinion you should simply handle them like any other XInput device and just accept the standard inputs using the gp_constants as they are.
 
I've done that. I could send it your way if you want, it's pretty easy to use.
Not 100% compatible, but probably good enough for your needs (i.e. at least get the brand).

EDIT: Major brands and models are all there, and it's pretty easy to expand if needed.
As for the switch controller, it will recognize it, but good luck making it work as you expect!
There you go
It's pretty much all commented in there, even the GUID "magic swap trick" (yeah, I named that)
 
Last edited:

kburkhart84

Firehammer Games
GML has a function for retreiving the GUID. As Slow Fingers's code works, it grabs the GUID, swaps a couple bits(for some reason it comes in backwards), and then it compares the GUID with what amounts to basically a massive database and returns the brand/model.
 

kburkhart84

Firehammer Games
I see! @Slow Fingers Holy crap, you really got a bunch of em in that script!!
Yup, once I'm done with my audio system I plan to integrate that thing into my input system with a few other features. @Slow Fingers did some heavy work converting that database to GML form. I'm giving them my input system and upcoming audio system in exchange for allowing me to use that code, its 100% worth it.
 
I see! @Slow Fingers Holy crap, you really got a bunch of em in that script!!
I managed to figure a good workflow. Once I figured how it all works and where I could get a good database of USB stuff, I was cruising, man!
Looks more intimidating that what it really is!

What is this GUID? A constant I can reference?
Yes. It's kind of a unique digital serial number. Every USB thing has got one. It's formatted so the vendor name (it's code) is always on the same spot, as is the product "id".
Your webcam has one, mouse, USB sticks, gamepads... A LOT of stuff!
It can't never be changed, so it's pretty reliable way of identifying digital stuff

Oh, and by the way, if you (or anyone who downloads this, I'll leave it in my Dropbox) stumble on a controller or a brand that's not recognized at all with this, can you kindly send a shoutout with the GUID, brand and manufacturer info to either me or @kburkhart84 so we can add it? Particularly looking for those Retro-bit controllers, but I don't own any of them.
Would help keeping it up to date and more compatible. Thanks!
 
Last edited:

Neptune

Member
Will do! Thanks a bunch for the script.
I think I will just use this portion as a quick "is microsoft?", "is sony?", "is nintendo?"kind of check.

GML:
/// @param device_index
function scr_gamepad_vendor()
{
    var guid = gamepad_get_guid(argument[0]);
    
    var vuid = string_char_at(guid, 3) + string_char_at(guid, 4) + string_char_at(guid, 1) + string_char_at(guid, 2);
    var vendor = "";

    switch(vuid)
    {
        case "0079" :    vendor =     "DragonRise";    break;
        case "0414" :    vendor =     "Giga-Byte Technology";    break;
        case "0810" :    vendor =     "PCS";    break;
        case "0955" :    vendor =     "NVIDIA Corp.";    break;
        case "1617" :    vendor =     "Sony";    break;
        case "1949" :    vendor =     "Lab126";    break;
        case "2563" :    vendor =     "ShenZhen";    break;
        case "6472" :    vendor =     "Sony ";    break;
        case "044f" :    vendor =     "ThrustMaster";    break;
        case "045e" :    vendor =     "Microsoft";    break;
        case "046d" :    vendor =     "Logitech";    break;
        case "0483" :    vendor =     "STMicroelectronics";    break;
        case "04b4" :    vendor =     "Cypress Semiconductor";    break;
        case "054c" :    vendor =     "Sony";    break;
        case "057e" :    vendor =     "Nintendo";    break;
        case "06a3" :    vendor =     "Saitek";    break;
        case "06cb" :    vendor =     "Synaptics";    break;
        case "0738" :    vendor =     "Mad Catz";    break;
        case "07af" :    vendor =     "MicroTech";    break;
        case "07b5" :    vendor =     "Mega World International";    break;
        case "08f1" :    vendor =     "CTI Electronics";    break;
        case "0a51" :    vendor =     "Sony";    break;
        case "0c12" :    vendor =     "Zeroplus";    break;
        case "0ca3" :    vendor =     "Sega";    break;
        case "0e6f" :    vendor =     "Logic3";    break;
        case "0e8f" :    vendor =     "GreenAsia";    break;
        case "0f0d" :    vendor =     "Hori";    break;
        case "0fce" :    vendor =     "Sony";    break;
        case "11c0" :    vendor =     "Betop";    break;
        case "12ba" :    vendor =     "Licensed by Sony";    break;
        case "12bd" :    vendor =     "Gembird";    break;
        case "1345" :    vendor =     "Sino Lite Technology";    break;
        case "1430" :    vendor =     "RedOctane";    break;
        case "146b" :    vendor =     "BigBen Interactive";    break;
        case "1532" :    vendor =     "Razer USA";    break;
        case "1689" :    vendor =     "Razer USA";    break;
        case "16c0" :    vendor =     "Van Ooijen Technische Informatica";    break;
        case "187c" :    vendor =     "Alienware";    break;
        case "18d1" :    vendor =     "Google";    break;
        case "19fa" :    vendor =     "Gampaq";    break;
        case "1a34" :    vendor =     "ACRUX";    break;
        case "1d57" :    vendor =     "Xenta";    break;
        case "22ba" :    vendor =     "Technology Innovation Holdings";    break;
        case "2341" :    vendor =     "Arduino";    break;
        case "25f0" :    vendor =     "ShanWan";    break;
        case "2dc8" :    vendor =     "8BitDo";    break;
        case "6666" :    vendor =     "Prototype product Vendor ID";    break;
        case "9886" :    vendor =     "Astro Gaming";    break;
        case "d209" :    vendor =     "Ultimarc";    break;
        case "289b" :    vendor =     "Raphnet";    break;   
    }
    return (vendor);
}
 
Top