std::shared_ptr<mi::InputManager> mir::DefaultServerConfiguration::the_input_manager() { return input_manager( [this]() -> std::shared_ptr<mi::InputManager> { auto const options = the_options(); bool input_opt = options->get<bool>(options::enable_input_opt); // TODO nested input handling (== host_socket) should fold into a platform if (!input_opt || options->is_set(options::host_socket_opt)) { return std::make_shared<mi::NullInputManager>(); } else { auto platforms = probe_input_platforms(*options, the_emergency_cleanup(), the_input_device_registry(), the_input_report(), *the_shared_library_prober_report()); if (platforms.empty()) BOOST_THROW_EXCEPTION(std::runtime_error("No input platforms found")); auto const ret = std::make_shared<mi::DefaultInputManager>(the_input_reading_multiplexer()); for (auto & platform : platforms) ret->add_platform(std::move(platform)); return ret; } } ); }
void Main::launch_game() { SDLSubsystem sdl_subsystem; ConsoleBuffer console_buffer; timelog("controller"); InputManager input_manager(g_config->keyboard_config, g_config->joystick_config); timelog("commandline"); timelog("video"); std::unique_ptr<VideoSystem> video_system = VideoSystem::create(g_config->video); DrawingContext context(video_system->get_renderer(), video_system->get_lightmap()); init_video(); timelog("audio"); SoundManager sound_manager; sound_manager.enable_sound(g_config->sound_enabled); sound_manager.enable_music(g_config->music_enabled); Console console(console_buffer); timelog("scripting"); scripting::Scripting scripting(g_config->enable_script_debugger); timelog("resources"); TileManager tile_manager; SpriteManager sprite_manager; Resources resources; timelog("addons"); AddonManager addon_manager("addons", g_config->addons); timelog(0); const std::unique_ptr<Savegame> default_savegame(new Savegame(std::string())); GameManager game_manager; ScreenManager screen_manager; if(g_config->start_level != "") { // we have a normal path specified at commandline, not a physfs path. // So we simply mount that path here... std::string dir = FileSystem::dirname(g_config->start_level); std::string fileProtocol = "file://"; std::string::size_type position = dir.find(fileProtocol); if(position != std::string::npos) { dir = dir.replace(position, fileProtocol.length(), ""); } log_debug << "Adding dir: " << dir << std::endl; PHYSFS_addToSearchPath(dir.c_str(), true); if(g_config->start_level.size() > 4 && g_config->start_level.compare(g_config->start_level.size() - 5, 5, ".stwm") == 0) { screen_manager.push_screen(std::unique_ptr<Screen>( new worldmap::WorldMap( FileSystem::basename(g_config->start_level), *default_savegame))); } else { std::unique_ptr<GameSession> session ( new GameSession(FileSystem::basename(g_config->start_level), *default_savegame)); g_config->random_seed = session->get_demo_random_seed(g_config->start_demo); g_config->random_seed = gameRandom.srand(g_config->random_seed); graphicsRandom.srand(0); if(g_config->start_demo != "") session->play_demo(g_config->start_demo); if(g_config->record_demo != "") session->record_demo(g_config->record_demo); screen_manager.push_screen(std::move(session)); } } else { screen_manager.push_screen(std::unique_ptr<Screen>(new TitleScreen(*default_savegame))); } screen_manager.run(context); }
void running_machine::start() { // initialize basic can't-fail systems here config_init(*this); m_input = auto_alloc(*this, input_manager(*this)); output_init(*this); palette_init(*this); m_render = auto_alloc(*this, render_manager(*this)); generic_machine_init(*this); generic_sound_init(*this); // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); // init the osd layer m_osd.init(*this); // create the video manager m_video = auto_alloc(*this, video_manager(*this)); ui_init(*this); // initialize the base time (needed for doing record/playback) ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = input_port_init(*this); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(*this); // initialize the streams engine before the sound devices start m_sound = auto_alloc(*this, sound_manager(*this)); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(*this); memory_init(*this); watchdog_init(*this); // must happen after memory_init because this relies on generic.spriteram generic_video_init(*this); // allocate the gfx elements prior to device initialization gfx_init(*this); // initialize natural keyboard support inputx_init(*this); // initialize image devices image_init(*this); tilemap_init(*this); crosshair_init(*this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(*this); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(*this, "Initializing...", true); // start up the devices const_cast<device_list &>(devicelist()).start_all(); // if we're coming in with a savegame request, process it now const char *savegame = options().state(); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); // disallow save state registrations starting here m_save.allow_registration(false); }
void Main::launch_game() { SDLSubsystem sdl_subsystem; ConsoleBuffer console_buffer; timelog("controller"); InputManager input_manager(g_config->keyboard_config, g_config->joystick_config); timelog("commandline"); timelog("video"); std::unique_ptr<VideoSystem> video_system = VideoSystem::create(g_config->video); DrawingContext context(*video_system); init_video(); timelog("audio"); SoundManager sound_manager; sound_manager.enable_sound(g_config->sound_enabled); sound_manager.enable_music(g_config->music_enabled); Console console(console_buffer); timelog("scripting"); scripting::Scripting scripting(g_config->enable_script_debugger); timelog("resources"); TileManager tile_manager; SpriteManager sprite_manager; Resources resources; timelog("addons"); AddonManager addon_manager("addons", g_config->addons); timelog(0); const std::unique_ptr<Savegame> default_savegame(new Savegame(std::string())); GameManager game_manager; ScreenManager screen_manager; if(!g_config->start_level.empty()) { // we have a normal path specified at commandline, not a physfs path. // So we simply mount that path here... std::string dir = FileSystem::dirname(g_config->start_level); std::string filename = FileSystem::basename(g_config->start_level); std::string fileProtocol = "file://"; std::string::size_type position = dir.find(fileProtocol); if(position != std::string::npos) { dir = dir.replace(position, fileProtocol.length(), ""); } log_debug << "Adding dir: " << dir << std::endl; PHYSFS_mount(dir.c_str(), NULL, true); if(g_config->start_level.size() > 4 && g_config->start_level.compare(g_config->start_level.size() - 5, 5, ".stwm") == 0) { screen_manager.push_screen(std::unique_ptr<Screen>( new worldmap::WorldMap(filename, *default_savegame))); } else { std::unique_ptr<GameSession> session ( new GameSession(filename, *default_savegame)); g_config->random_seed = session->get_demo_random_seed(g_config->start_demo); g_config->random_seed = gameRandom.srand(g_config->random_seed); graphicsRandom.srand(0); if (g_config->tux_spawn_pos) { session->get_current_sector()->player->set_pos(*g_config->tux_spawn_pos); } if(!g_config->start_demo.empty()) session->play_demo(g_config->start_demo); if(!g_config->record_demo.empty()) session->record_demo(g_config->record_demo); screen_manager.push_screen(std::move(session)); } } else { screen_manager.push_screen(std::unique_ptr<Screen>(new TitleScreen(*default_savegame))); if (g_config->edit_level) { if (PHYSFS_exists(g_config->edit_level->c_str())) { std::unique_ptr<Editor> editor(new Editor()); editor->set_level(*(g_config->edit_level)); editor->setup(); editor->update(0); screen_manager.push_screen(std::move(editor)); MenuManager::instance().clear_menu_stack(); sound_manager.stop_music(0.5); } else { log_warning << "Level " << *(g_config->edit_level) << " doesn't exist." << std::endl; } } } screen_manager.run(context); }
void running_machine::start() { // initialize basic can't-fail systems here config_init(*this); m_input = auto_alloc(*this, input_manager(*this)); output_init(*this); palette_init(*this); m_render = auto_alloc(*this, render_manager(*this)); generic_machine_init(*this); // allocate a soft_reset timer m_soft_reset_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::soft_reset), this)); // init the osd layer m_osd.init(*this); // create the video manager m_video = auto_alloc(*this, video_manager(*this)); ui_init(*this); // initialize the base time (needed for doing record/playback) ::time(&m_base_time); // initialize the input system and input ports for the game // this must be done before memory_init in order to allow specifying // callbacks based on input port tags time_t newbase = m_ioport.initialize(); if (newbase != 0) m_base_time = newbase; // intialize UI input ui_input_init(*this); // initialize the streams engine before the sound devices start m_sound = auto_alloc(*this, sound_manager(*this)); // first load ROMs, then populate memory, and finally initialize CPUs // these operations must proceed in this order rom_init(*this); m_memory.initialize(); // initialize the watchdog m_watchdog_timer = m_scheduler.timer_alloc(timer_expired_delegate(FUNC(running_machine::watchdog_fired), this)); if (config().m_watchdog_vblank_count != 0 && primary_screen != NULL) primary_screen->register_vblank_callback(vblank_state_delegate(FUNC(running_machine::watchdog_vblank), this)); save().save_item(NAME(m_watchdog_enabled)); save().save_item(NAME(m_watchdog_counter)); // allocate the gfx elements prior to device initialization gfx_init(*this); // initialize image devices image_init(*this); m_tilemap = auto_alloc(*this, tilemap_manager(*this)); crosshair_init(*this); network_init(*this); // initialize the debugger if ((debug_flags & DEBUG_FLAG_ENABLED) != 0) debugger_init(*this); // call the game driver's init function // this is where decryption is done and memory maps are altered // so this location in the init order is important ui_set_startup_text(*this, "Initializing...", true); // register callbacks for the devices, then start them add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(running_machine::reset_all_devices), this)); add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(running_machine::stop_all_devices), this)); save().register_presave(save_prepost_delegate(FUNC(running_machine::presave_all_devices), this)); start_all_devices(); save().register_postload(save_prepost_delegate(FUNC(running_machine::postload_all_devices), this)); // if we're coming in with a savegame request, process it now const char *savegame = options().state(); if (savegame[0] != 0) schedule_load(savegame); // if we're in autosave mode, schedule a load else if (options().autosave() && (m_system.flags & GAME_SUPPORTS_SAVE) != 0) schedule_load("auto"); // set up the cheat engine m_cheat = auto_alloc(*this, cheat_manager(*this)); // allocate autoboot timer m_autoboot_timer = scheduler().timer_alloc(timer_expired_delegate(FUNC(running_machine::autoboot_callback), this)); // initialize lua m_lua_engine.initialize(); // disallow save state registrations starting here m_save.allow_registration(false); }