void initTracker(pp_uint32 bpp, PPDisplayDevice::Orientations orientation, bool swapRedBlue, bool noSplash) { // Initialize SDL if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); exit(EXIT_FAILURE); } // Enable drag and drop SDL_EventState(SDL_DROPFILE, SDL_ENABLE); #if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__)) && \ (!defined(__CYGWIN32__) && !defined(ENABLE_NANOX) && \ !defined(__QNXNTO__) && !defined(__AROS__)) // Initialise crash handler struct sigaction act; struct sigaction oldAct; memset(&act, 0, sizeof(act)); act.sa_handler = crashHandler; act.sa_flags = SA_RESETHAND; sigaction(SIGTERM | SIGILL | SIGABRT | SIGFPE | SIGSEGV, &act, &oldAct); sigaction(SIGILL, &act, &oldAct); sigaction(SIGABRT, &act, &oldAct); sigaction(SIGFPE, &act, &oldAct); sigaction(SIGSEGV, &act, &oldAct); #endif #if defined(HAVE_X11) SDL_SysWMinfo info; SDL_VERSION(&info.version); if ( SDL_GetWindowWMInfo(0, &info) && info.subsystem == SDL_SYSWM_X11) isX11 = true; // Used in SDL_KeyTranslation.cpp #endif // ------------ Initialise tracker --------------- myTracker = new Tracker(); PPSize windowSize = myTracker->getWindowSizeFromDatabase(); bool fullScreen = myTracker->getFullScreenFlagFromDatabase(); pp_int32 scaleFactor = myTracker->getScreenScaleFactorFromDatabase(); #ifdef __LOWRES__ windowSize.width = DISPLAYDEVICE_WIDTH; windowSize.height = DISPLAYDEVICE_HEIGHT; #endif #ifdef __OPENGL__ myDisplayDevice = new PPDisplayDeviceOGL(windowSize.width, windowSize.height, scaleFactor, bpp, fullScreen, orientation, swapRedBlue); #else myDisplayDevice = new PPDisplayDeviceFB(windowSize.width, windowSize.height, scaleFactor, bpp, fullScreen, orientation, swapRedBlue); #endif SDL_SetWindowTitle(myDisplayDevice->getWindow(), "Loading MilkyTracker..."); myDisplayDevice->init(); myTrackerScreen = new PPScreen(myDisplayDevice, myTracker); myTracker->setScreen(myTrackerScreen); // Kickstart SDL event loop early so that the splash screen is made visible SDL_PumpEvents(); // Startup procedure myTracker->startUp(noSplash); #ifdef HAVE_LIBASOUND InitMidi(); #endif // Try to create timer timer = SDL_AddTimer(20, timerCallback, NULL); // Start capturing text input events SDL_StartTextInput(); ticking = true; }
void initTracker(pp_uint32 bpp, PPDisplayDevice::Orientations orientation, bool swapRedBlue, bool fullScreen, bool noSplash) { /* Initialize SDL */ if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0 ) { fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); exit(1); } // atexit(SDL_Quit); Not really needed, and needs a wrapper for OS/2 #ifdef __GP2X__ if ( SDL_Init(SDL_INIT_JOYSTICK) < 0 || !SDL_JoystickOpen(0)) { fprintf(stderr, "Couldn't initialize SDL Joystick: %s\n",SDL_GetError()); exit(1); } mouse.x = 0; mouse.y = 0; mouse.ticks = 0; mouse.button = 0; #endif SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_EnableUNICODE(1); #if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__)) && \ (!defined(__CYGWIN32__) && !defined(ENABLE_NANOX) && \ !defined(__QNXNTO__) && !defined(__AROS__)) // Initialise crash handler struct sigaction act; struct sigaction oldAct; memset(&act, 0, sizeof(act)); act.sa_handler = crashHandler; act.sa_flags = SA_RESETHAND; sigaction(SIGTERM | SIGILL | SIGABRT | SIGFPE | SIGSEGV, &act, &oldAct); sigaction(SIGILL, &act, &oldAct); sigaction(SIGABRT, &act, &oldAct); sigaction(SIGFPE, &act, &oldAct); sigaction(SIGSEGV, &act, &oldAct); #endif #if defined(HAVE_X11) && !defined(__QTOPIA__) SDL_SysWMinfo info; SDL_VERSION(&info.version); if ( SDL_GetWMInfo(&info) && info.subsystem == SDL_SYSWM_X11) isX11 = true; // Used in SDL_KeyTranslation.cpp #endif SDL_WM_SetCaption("Loading MilkyTracker...", "MilkyTracker"); // ------------ initialise tracker --------------- myTracker = new Tracker(); PPSize windowSize = myTracker->getWindowSizeFromDatabase(); if (!fullScreen) fullScreen = myTracker->getFullScreenFlagFromDatabase(); pp_int32 scaleFactor = myTracker->getScreenScaleFactorFromDatabase(); #ifdef __LOWRES__ windowSize.width = DISPLAYDEVICE_WIDTH; windowSize.height = DISPLAYDEVICE_HEIGHT; #endif #ifdef __OPENGL__ myDisplayDevice = new PPDisplayDeviceOGL(screen, windowSize.width, windowSize.height, 1, bpp, fullScreen, orientation, swapRedBlue); #else myDisplayDevice = new PPDisplayDeviceFB(screen, windowSize.width, windowSize.height, scaleFactor, bpp, fullScreen, orientation, swapRedBlue); #endif myDisplayDevice->init(); myTrackerScreen = new PPScreen(myDisplayDevice, myTracker); myTracker->setScreen(myTrackerScreen); #ifdef __QTOPIA__ // On Qtopia I have to run a short event loop // until drawing/blitting can be performed // so the splash screen will be visible for (pp_int32 i = 0; i < 500; i++) { SDL_Event event; SDL_PollEvent(&event); } #endif // Startup procedure myTracker->startUp(noSplash); #ifdef HAVE_LIBASOUND InitMidi(); #endif // try to create timer SDL_SetTimer(20, timerCallback); timerMutex->lock(); ticking = true; timerMutex->unlock(); }