Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » handling different joystick button mappings

This thread is locked; no one can reply to it. rss feed Print
handling different joystick button mappings
iam_donald
Member #14,318
May 2012
avatar

Hi guys, i'm looking to create controller manager using allegro that allows for different controllers with different button mapping - eg xbox and ps3 controllers. I figured I could use al_get_joystick_name get specific IDs for connected controllers and use that to load the button mapping for the controller, this way the button mapping for players doesn't change regardless of whatever controller they opt to use.

al_get_joystick_name is not being helpful however, in my tests it just returns "Joystick" - generic. Could someone point me in the right direction please. How do I get controller specific info via allegro? Thanks.

beoran
Member #12,636
March 2011

Well, I think this is a problem of the Windows driver of the Allegro library. On Linux the name comes out just fine. I don't have Windows so I 'm afraid I'll have to ask you if you are willing to look into this and improve the Windows joystick driver so it returns a proper name. You'll have to download the Allegro git version to get down and drirty.

iam_donald
Member #14,318
May 2012
avatar

Actually it's on OSX I'm having this issue. The controller I'm with is a PS3 controller. al_get_joystick_name returns "Joystick". There's also this bug where al_get_num_joysticks returns 2 when you have just one controller connected via both bluetooth and usb.

Evert
Member #794
November 2000
avatar

Well, this may have something to do with it:

// FIXME!
static const char *get_joystick_name(ALLEGRO_JOYSTICK *joy_)
{
   (void)joy_;
   return "Joystick";
}

(From src/macosx/hidjoy.m).

Someone will need to investigate how to do it and implement it, which is probably not very hard but will require some time.

iam_donald
Member #14,318
May 2012
avatar

Alright, will sort it out.

Go to: