![]() |
|
Question about joystick events |
Michael Weiss
Member #223
April 2000
|
How do I get the joystick number from the joystick event? I can use: joystick.id (ALLEGRO_JOYSTICK *) From that I can figure a lot of things about that particular joystick, Am I missing something obvious?? Thanks..
|
Neil Roy
Member #2,229
April 2002
![]() |
I would look at the function al_get_joystick() to get the number. See also al_get_joystick_active() and al_get_joystick_name() --- |
Michael Weiss
Member #223
April 2000
|
Thanks Neil, I looked at your answer, but it didn't help. ALLEGRO_JOYSTICK * al_get_joystick(int num) OK, so I've got the joystick handle struct, what can i do with that? bool al_get_joystick_active(ALLEGRO_JOYSTICK *joy) const char *al_get_joystick_name(ALLEGRO_JOYSTICK *joy) Now I don't want to be one of those people who say: This is how it was done in allegro 4: extern JOYSTICK_INFO joy[n]; It was very easy to figure out which joystick was which. All I want to do is: Someone must have a multi joystick example, but I have searched and can't find anything. Thanks
|
Edgar Reynaldo
Major Reynaldo
May 2007
![]() |
Untested, but this should do what you want : int getJoystickNum(ALLEGRO_JOYSTICK* joy) { for (unsigned int i = 0 ; i < al_get_num_joysticks() ; ++i) { if (joy == al_get_joystick(i)) {return i;} } return -1; }
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Michael Weiss
Member #223
April 2000
|
That works perfectly!! Thank you so much for your help!!
|
Peter Hull
Member #1,136
March 2001
|
I don't disagree with Edgar but take a look at the docs for al_reconfigure_joysticks - if you want to support plugging/unplugging sticks you may need to do a bit of extra work, in case Allegro renumbers them. I don't have >1 joystick to test (and I suspect it's platform dependent) so I don't know if this will be a problem in practice.
|
|