diff options
author | Eugene Sandulenko | 2015-01-12 00:36:01 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2015-01-12 00:36:01 +0100 |
commit | dc6c1a5cab2d27cd367b54b08d1cb0189c163fc8 (patch) | |
tree | a477ccba8b10d8170c147fe6b50ea46ad98b3cf8 | |
parent | b0defeed4d10e79a61c7c30480f6c0a83d4c4bd0 (diff) | |
parent | ee9b60676a3efe015638763eed69161ee76ed846 (diff) | |
download | scummvm-rg350-dc6c1a5cab2d27cd367b54b08d1cb0189c163fc8.tar.gz scummvm-rg350-dc6c1a5cab2d27cd367b54b08d1cb0189c163fc8.tar.bz2 scummvm-rg350-dc6c1a5cab2d27cd367b54b08d1cb0189c163fc8.zip |
Merge pull request #558 from klusark/patch-3
SDL: Warn if the selected joystick does not exist
-rw-r--r-- | backends/events/sdl/sdl-events.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 2480e7c370..284e0970fd 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -55,16 +55,18 @@ SdlEventSource::SdlEventSource() memset(&_km, 0, sizeof(_km)); int joystick_num = ConfMan.getInt("joystick_num"); - if (joystick_num > -1) { + if (joystick_num >= 0) { // Initialize SDL joystick subsystem if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) { error("Could not initialize SDL: %s", SDL_GetError()); } // Enable joystick - if (SDL_NumJoysticks() > 0) { - debug("Using joystick: %s", SDL_JoystickName(0)); + if (SDL_NumJoysticks() > joystick_num) { + debug("Using joystick: %s", SDL_JoystickName(joystick_num)); _joystick = SDL_JoystickOpen(joystick_num); + } else { + warning("Invalid joystick: %d", joystick_num); } } } |