Log info about Joysticks

This commit is contained in:
Thomas Bernard 2019-02-20 21:25:54 +01:00
parent 84b4f76102
commit 01c16b488d
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C

View File

@ -750,9 +750,6 @@ int Init_program(int argc,char * argv[])
#if defined(USE_SDL2) #if defined(USE_SDL2)
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE); SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE);
#endif #endif
#if defined(USE_JOYSTICK)
Joystick = SDL_JoystickOpen(0);
#endif
#endif #endif
#if defined(USE_SDL) #if defined(USE_SDL)
SDL_EnableKeyRepeat(250, 32); SDL_EnableKeyRepeat(250, 32);
@ -772,6 +769,26 @@ int Init_program(int argc,char * argv[])
// a video mode may be requested as a command-line parameter // a video mode may be requested as a command-line parameter
file_in_command_line=Analyze_command_line(argc, argv, main_filename, main_directory, spare_filename, spare_directory); file_in_command_line=Analyze_command_line(argc, argv, main_filename, main_directory, spare_filename, spare_directory);
#if defined(USE_JOYSTICK) && (defined(USE_SDL) || defined(USE_SDL2))
GFX2_Log(GFX2_DEBUG, "%d joystick(s) attached\n", SDL_NumJoysticks());
if (SDL_NumJoysticks() > 0)
{
Joystick = SDL_JoystickOpen(0);
if (Joystick == NULL)
{
GFX2_Log(GFX2_ERROR, "Failed to open joystick #0 : %s\n", SDL_GetError());
}
else
{
GFX2_Log(GFX2_DEBUG, "Joystick #0 open : \"%s\" %d axes, %d buttons, %d balls, %d hats\n",
SDL_JoystickName(Joystick), SDL_JoystickNumAxes(Joystick),
SDL_JoystickNumButtons(Joystick), SDL_JoystickNumBalls(Joystick),
SDL_JoystickNumHats(Joystick));
SDL_JoystickEventState(SDL_ENABLE);
}
}
#endif
Pixel_ratio=PIXEL_SIMPLE; Pixel_ratio=PIXEL_SIMPLE;
// On initialise les données sur l'état du programme: // On initialise les données sur l'état du programme:
// Donnée sur la sortie du programme: // Donnée sur la sortie du programme: