![]() |
|
[a5] crash on al_get_joystick |
Mark Oates
Member #1,146
March 2001
![]() |
Something with allegro 5.1.11 is causing allegro to crash when calling al_get_joystick(n) where a joystick is not available. It used to simply return NULL if a joystick did not exist, but now in 5.1.11 appears to cause a crash. If the stick is there, everything is fine. A simple example: #include <allegro5/allegro.h> int main(int argc, char *argv[]) { al_init(); al_install_joystick(); ALLEGRO_JOYSTICK *joy = al_get_joystick(0); // ^ if no joystick is there, program will crash. return 0; } I'm using Edgar's 5.1.11 binary build (used in speedhack). -- |
beoran
Member #12,636
March 2011
|
It's possible that a bug was introduced there. Probably by me |
Peter Hull
Member #1,136
March 2001
|
Tried this on the allegro-msvc2013-x86-5.1.11 I got from sourceforge, compiling your program under VS 2013. No crashes, it just returned NULL as you'd expect. Pete *Docs say Quote:
Get a handle for a joystick on the system. The number may be from 0 to I dunno, what does Allegro usually do with an out of range value?
|
Elias
Member #358
May 2000
|
Assertion is the usual way, and the documentation clearly states that you cannot pass an out of range value. However I feel we're gradually changing the assertion error handling to returning NULL, so it probably would be fine to change and document it in this case. -- |
Bruce Pascoe
Member #15,931
April 2015
![]() |
My guess is it's regression introduced by the recent stabilization of the Windows joystick code. It used to crash on init if XInput wasn't available (e.g. WinXP)
|
|