SFML community forums

Help => Window => Topic started by: Guido_Ion on October 02, 2021, 07:50:11 pm

Title: Gamepad Class that reads from SDL controller database
Post by: Guido_Ion on October 02, 2021, 07:50:11 pm
Hi, I'm trying to do a simple class to read SDL's database of controllers  (https://github.com/gabomdq/SDL_GameControllerDB)(the txt file). The problem is that SDL uses GUID of devices and I can't get that information with sf::Joystick since SFML works with vendorID and ProductID. I've tried also comparing the names of the joysticks but sometimes they are slightly different, for example SFML writes "Logitech Dual Action" while SDL writes "Logitech Dual Action USB".

Is there a way to read GUID from SFML or maybe somehow converting GUID to VendorID and ProductID? Is that info in there?

I'll share the results with the community once it's done (if it can be done)
Title: Re: Gamepad Database: using SDL's database?
Post by: Guido_Ion on October 07, 2021, 03:46:01 am
Ok, I found that the GUID includes the vendorID and the productID, example:

Code: [Select]
030000005e040000d102000000000000
        \__/    \__/
       vendor  product

vendor: 5e04 -> 0x045e Hex -> 1118 decimal (Microsoft)
product: d102 -> 0x02d1 Hex -> 721 decimal (Xbox One Controller)

I'm now working on a generic GamePad Class that receives vendorID and productID and grabs the data from SDL's controllers database and also provides a nice interface to check buttons and axes.

When it's done I'll share it with the community  :D
Title: Re: Gamepad Class that reads from SDL controller database
Post by: Guido_Ion on October 09, 2021, 12:15:55 am
Done, I made a post in the Projects section :): https://en.sfml-dev.org/forums/index.php?topic=28250.msg176807 (https://en.sfml-dev.org/forums/index.php?topic=28250.msg176807)