Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Gamepad Class that reads from SDL controller database  (Read 6845 times)

0 Members and 1 Guest are viewing this topic.

Guido_Ion

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Flow Soccer development
Gamepad Class that reads from SDL controller database
« on: October 02, 2021, 07:50:11 pm »
Hi, I'm trying to do a simple class to read SDL's database of controllers (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)
« Last Edit: October 07, 2021, 03:46:55 am by Guido Bisocoli »

Guido_Ion

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Flow Soccer development
Re: Gamepad Database: using SDL's database?
« Reply #1 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

Guido_Ion

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Flow Soccer development
Re: Gamepad Class that reads from SDL controller database
« Reply #2 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