diff options
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/intern.h | 2 | ||||
| -rw-r--r-- | backends/sdl/sdl-common.cpp | 22 | ||||
| -rw-r--r-- | backends/sdl/sdl-common.h | 6 | 
3 files changed, 18 insertions, 12 deletions
| diff --git a/backends/intern.h b/backends/intern.h index 7b06adfe69..f3fbf07f71 100644 --- a/backends/intern.h +++ b/backends/intern.h @@ -27,7 +27,7 @@  /* Factory functions. This means we don't have to include the headers for   * all backends.   */ -extern OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen, bool aspect_ratio); +extern OSystem *OSystem_SDL_create(int gfx_driver, bool full_screen, bool aspect_ratio, int joystick_num);  extern OSystem *OSystem_NULL_create();  extern OSystem *OSystem_MorphOS_create(int game_id, int gfx_driver, bool full_screen);  extern OSystem *OSystem_Dreamcast_create(); 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 | 
