diff options
author | Jonathan Gray | 2003-10-01 10:47:19 +0000 |
---|---|---|
committer | Jonathan Gray | 2003-10-01 10:47:19 +0000 |
commit | eecdf67c636a8ff7a04819db4ffbc8717c278b52 (patch) | |
tree | 950f9d56022b6a52f031e66017812932c3bc2733 /backends/sdl | |
parent | 13773455a40f356dfcd65819587c71d516504de5 (diff) | |
download | scummvm-rg350-eecdf67c636a8ff7a04819db4ffbc8717c278b52.tar.gz scummvm-rg350-eecdf67c636a8ff7a04819db4ffbc8717c278b52.tar.bz2 scummvm-rg350-eecdf67c636a8ff7a04819db4ffbc8717c278b52.zip |
disable joystick input by default either command line or config file need to be used to enable it now, ability to choose joystick number to use also added
svn-id: r10518
Diffstat (limited to 'backends/sdl')
-rw-r--r-- | backends/sdl/sdl-common.cpp | 22 | ||||
-rw-r--r-- | backends/sdl/sdl-common.h | 6 |
2 files changed, 17 insertions, 11 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index aabd2d2f80..4421ee17f0 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -41,26 +41,32 @@ #define JOY_BUT_SPACE 4 #define JOY_BUT_F5 5 -OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen, bool aspect_ratio) { - return OSystem_SDL_Common::create(gfx_mode, full_screen, aspect_ratio); +OSystem *OSystem_SDL_create(int gfx_mode, bool full_screen, bool aspect_ratio, int joystick_num) { + return OSystem_SDL_Common::create(gfx_mode, full_screen, aspect_ratio, joystick_num); } -OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen, bool aspect_ratio) { +OSystem *OSystem_SDL_Common::create(int gfx_mode, bool full_screen, bool aspect_ratio, int joystick_num) { OSystem_SDL_Common *syst = OSystem_SDL_Common::create_intern(); - syst->init_intern(gfx_mode, full_screen, aspect_ratio); + syst->init_intern(gfx_mode, full_screen, aspect_ratio, joystick_num); return syst; } -void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect_ratio) { +void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect_ratio, int joystick_num) { _mode = gfx_mode; _full_screen = full_screen; _adjustAspectRatio = aspect_ratio; _mode_flags = 0; + uint32 sdlFlags; - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK) ==-1) { + sdlFlags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER; + + if (joystick_num > -1) + sdlFlags |= SDL_INIT_JOYSTICK; + + if (SDL_Init(sdlFlags) ==-1) { error("Could not initialize SDL: %s.\n", SDL_GetError()); } @@ -77,9 +83,9 @@ void OSystem_SDL_Common::init_intern(int gfx_mode, bool full_screen, bool aspect #endif // enable joystick - if (SDL_NumJoysticks() > 0) { + if (joystick_num > -1 && SDL_NumJoysticks() > 0) { printf("Using joystick: %s\n", SDL_JoystickName(0)); - init_joystick(); + init_joystick(joystick_num); } } diff --git a/backends/sdl/sdl-common.h b/backends/sdl/sdl-common.h index 78ecba892b..2b37d13848 100644 --- a/backends/sdl/sdl-common.h +++ b/backends/sdl/sdl-common.h @@ -117,7 +117,7 @@ public: virtual int16 RGBToColor(uint8 r, uint8 g, uint8 b); virtual void colorToRGB(int16 color, uint8 &r, uint8 &g, uint8 &b); - static OSystem *create(int gfx_mode, bool full_screenm, bool aspect_ratio); + static OSystem *create(int gfx_mode, bool full_screenm, bool aspect_ratio, int joystick_num); protected: OSystem_SDL_Common(); @@ -125,7 +125,7 @@ protected: static OSystem_SDL_Common *create_intern(); - void init_intern(int gfx_mode, bool full_screen, bool aspect_ratio); + void init_intern(int gfx_mode, bool full_screen, bool aspect_ratio, int joystick_num); // unseen game screen SDL_Surface *_screen; @@ -229,7 +229,7 @@ protected: void setup_icon(); void kbd_mouse(); - void init_joystick() { _joystick = SDL_JoystickOpen(0); } + void init_joystick(int joystick_num) { _joystick = SDL_JoystickOpen(joystick_num); } }; #endif |