SdlUi::SdlUi(long width, long height, const std::string& title, bool fs_flag) : BaseUi(), zoom_available(true), toggle_fs_available(false), mode_changing(false) { #ifdef GEKKO WPAD_Init(); SYS_SetResetCallback(GekkoResetCallback); #endif uint32_t flags = SDL_INIT_VIDEO; #ifndef EMSCRIPTEN flags |= SDL_INIT_TIMER; #endif #if (!defined(NDEBUG) || defined(_WIN32)) flags |= SDL_INIT_NOPARACHUTE; #endif // Set some SDL env. variables before starting // These are platform dependent, so every port // needs to set them manually // Set window position to the middle of the // screen #ifndef GEKKO putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center")); #endif #if defined(PSP) putenv(const_cast<char *>("SDL_ASPECT_RATIO=4:3")); #endif if (SDL_Init(flags) < 0) { Output::Error("Couldn't initialize SDL.\n%s\n", SDL_GetError()); } #if SDL_MAJOR_VERSION==1 sdl_surface = NULL; SetAppIcon(); #else sdl_window = NULL; #endif BeginDisplayModeChange(); if (!RequestVideoMode(width, height, fs_flag)) { Output::Error("No suitable video resolution found. Aborting."); } EndDisplayModeChange(); SetTitle(title); #if (defined(USE_JOYSTICK) && defined(SUPPORT_JOYSTICK)) || (defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS)) || (defined(USE_JOYSTICK_HAT) && defined(SUPPORT_JOYSTICK_HAT)) if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { Output::Warning("Couldn't initialize joystick.\n%s", SDL_GetError()); } SDL_JoystickEventState(1); SDL_JoystickOpen(0); #endif #if defined(USE_MOUSE) && defined(SUPPORT_MOUSE) ShowCursor(true); #else ShowCursor(false); #endif #if defined(HAVE_SDL_MIXER) audio_.reset(new SdlAudio()); #elif defined(HAVE_OPENAL) audio_.reset(new ALAudio()); #else audio_.reset(new EmptyAudio()); #endif }
SdlUi::SdlUi(long width, long height, bool fs_flag) : BaseUi(), zoom_available(true), toggle_fs_available(false), mode_changing(false) { #ifdef GEKKO WPAD_Init(); SYS_SetResetCallback(GekkoResetCallback); #endif uint32_t flags = SDL_INIT_VIDEO; #ifndef EMSCRIPTEN flags |= SDL_INIT_TIMER; #endif #if (!defined(NDEBUG) || defined(_WIN32)) flags |= SDL_INIT_NOPARACHUTE; #endif // Set some SDL environment variables before starting. These are platform // dependent, so every port needs to set them manually #ifndef GEKKO // Set window position to the middle of the screen putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center")); #endif #ifdef __LINUX__ // Set the application class name setenv("SDL_VIDEO_X11_WMCLASS", GAME_TITLE, 0); #elif defined(PSP) putenv(const_cast<char *>("SDL_ASPECT_RATIO=4:3")); #endif if (SDL_Init(flags) < 0) { Output::Error("Couldn't initialize SDL.\n%s\n", SDL_GetError()); } #if SDL_MAJOR_VERSION==1 sdl_surface = NULL; #else sdl_window = NULL; #endif BeginDisplayModeChange(); if (!RequestVideoMode(width, height, fs_flag)) { Output::Error("No suitable video resolution found. Aborting."); } EndDisplayModeChange(); #ifdef GEKKO // Eliminate debug spew in on-screen console Output::WiiSetConsole(); // Eliminate overscan / add 5% borders WII_ChangeSquare(304, 228, 0, 0); #endif SetTitle(GAME_TITLE); #if (defined(USE_JOYSTICK) && defined(SUPPORT_JOYSTICK)) || (defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS)) || (defined(USE_JOYSTICK_HAT) && defined(SUPPORT_JOYSTICK_HAT)) if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { Output::Warning("Couldn't initialize joystick.\n%s", SDL_GetError()); } SDL_JoystickEventState(1); SDL_JoystickOpen(0); #endif #if defined(USE_MOUSE) && defined(SUPPORT_MOUSE) ShowCursor(true); #else ShowCursor(false); #endif #ifdef HAVE_SDL_MIXER audio_.reset(new SdlAudio()); #elif defined(HAVE_OPENAL) audio_.reset(new ALAudio()); #else audio_.reset(new EmptyAudio()); #endif }