def test_generate_specials(self): controllers = controllersConfig.loadControllerConfig( 0, GPIOUUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = libretroControllers.generateControllerConfig(controllers["1"]) print config self.assertEquals(config['input_exit_emulator_btn'], '7')
def test_generate_with_recalbox_conf_es_menu_off_doesnt_save_hotkeys(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = libretroControllers.generateControllerConfig(controllers["1"], True) self.assertFalse('input_load_state_btn' in config) self.assertFalse('input_menu_toggle_btn' in config) self.assertFalse('input_state_slot_increase_axis' in config)
def test_generate_specialsKeys_off_save_exit_special(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = libretroControllers.generateControllerConfig( controllers["1"], True) self.assertEquals(config['input_exit_emulator_btn'], '3')
def main(args): playersControllers = dict() if not args.demo: # Read the controller configuration playersControllers = controllers.loadControllerConfig(args.p1index, args.p1guid, args.p1name, args.p1devicepath, args.p1nbaxes, args.p2index, args.p2guid, args.p2name, args.p2devicepath, args.p2nbaxes, args.p3index, args.p3guid, args.p3name, args.p3devicepath, args.p3nbaxes, args.p4index, args.p4guid, args.p4name, args.p4devicepath, args.p4nbaxes, args.p5index, args.p5guid, args.p5name, args.p5devicepath, args.p5nbaxes) systemName = args.system # Main Program # A generator will configure its emulator, and return a command if systemName in emulators: system = emulators[systemName] system.configure(args.emulator, args.core, args.ratio, args.netplay) # Save dir dirname = os.path.join(recalboxFiles.savesDir, system.name) if not os.path.exists(dirname): os.makedirs(dirname) if system.config['emulator'] not in recalboxFiles.recalboxBins: strErr = "ERROR : {} is not a known emulator".format(system.config['emulator']) print >> sys.stderr, strErr exit(2) command = generators[system.config['emulator']].generate(system, args.rom, playersControllers) # The next line is commented and will eventually be used instead of the previous one # if we even want the binary to be set from here rather than from the generator # command.array.insert(0, recalboxFiles.recalboxBins[system.config['emulator']]) print(command.array) return runner.runCommand(command)
def test_generate_joystick_as_directions(self): controllers = controllersConfig.loadControllerConfig(0, GPIOUUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_player1_up_axis'], '-1') self.assertEquals(config['input_player1_down_axis'], '+1') self.assertEquals(config['input_player1_right_axis'], '+0') self.assertEquals(config['input_player1_left_axis'], '-0')
def test_generate_ps3_controller_specials(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = fba2xControllers.generateControllerConfig( "1", controllers["1"]) self.assertEquals(config['HOTKEY'], '16') self.assertEquals(config['QUIT'], '3')
def test_generate_only_axis_controller_doesnt_put_zero_in_directions(self): controllers = controllersConfig.loadControllerConfig(0, GPIOUUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = fba2xControllers.generateControllerConfig("1", controllers["1"], True) self.assertFalse('RIGHT_1' in config) self.assertFalse('LEFT_1' in config) self.assertFalse('UP_1' in config) self.assertFalse('DOWN_1' in config)
def test_generate_ps3_controller_joystick(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = fba2xControllers.generateControllerConfig( "1", controllers["1"]) self.assertEquals(config['JA_UD_1'], '1') self.assertEquals(config['JA_LR_1'], '0')
def test_generate_ps3_controller_joysticks(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_player1_l_y_plus_axis'], '+1') self.assertEquals(config['input_player1_l_y_minus_axis'], '-1') self.assertEquals(config['input_player1_l_x_plus_axis'], '+0') self.assertEquals(config['input_player1_l_x_minus_axis'], '-0')
def test_associate_controllers_with_players_with_differentuuid(self): uuid1 = "060000004c0500006802000000010000" uuid2 = "030000005e0400008e02000014010000" players = controllersConfig.loadControllerConfig("-1", uuid1, "p1controller", "-1", uuid2, "p2controller", "-1", uuid2, "p3controller", "-1", uuid2, "p4controller") self.assertEquals(4, len(players)) self.assertEquals(uuid1, players["1"].guid) self.assertEquals(uuid2, players["2"].guid) self.assertEquals("13", players["1"].inputs["a"].id);
def test_generate_joystick_as_directions(self): controllers = controllersConfig.loadControllerConfig(0, GPIOUUID, "p1controller", -1, 0, "p2controller", -1, 0, "p3controller", -1, 0, "p4controller") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_device'], '"p1controller"') self.assertEquals(config['input_up_axis'], '-1') self.assertEquals(config['input_down_axis'], '+1') self.assertEquals(config['input_right_axis'], '+0') self.assertEquals(config['input_left_axis'], '-0')
def test_controllers_defaults(self): uuid1 = "060000004c0500006802000000010000" players = controllersConfig.loadControllerConfig("0", uuid1, "p1controller", "", "-1", "FAKEUUID", "DEFAULTNAME", "", "-1", "FAKEUUID", "DEFAULTNAME", "", "-1", "FAKEUUID", "DEFAULTNAME", "") self.assertEquals(1, len(players)) self.assertEquals("0", players["1"].index)
def test_generate_with_recalbox_conf_es_menu_off_doesnt_save_hotkeys(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = libretroControllers.generateControllerConfig( controllers["1"], True) self.assertFalse('input_load_state_btn' in config) self.assertFalse('input_menu_toggle_btn' in config) self.assertFalse('input_state_slot_increase_axis' in config)
def test_write_ps3_controller_joysticks(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller", -1, 0, "p2controller", -1, 0, "p3controller", -1, 0, "p4controller") config = libretroControllers.writeControllerConfig(controllers["1"]) with open(libretroControllers.settingsRoot + "/inputs/p1controller.cfg") as controllerFile : lines = [] for line in controllerFile: lines.append(line) self.assertTrue('input_l2_btn = 8\n' in lines)
def test_controllers_defaults(self): uuid1 = "060000004c0500006802000000010000" players = controllersConfig.loadControllerConfig( "0", uuid1, "p1controller", "", "-1", "FAKEUUID", "DEFAULTNAME", "", "-1", "FAKEUUID", "DEFAULTNAME", "", "-1", "FAKEUUID", "DEFAULTNAME", "") self.assertEquals(1, len(players)) self.assertEquals("0", players["1"].index)
def test_write_only_joystick_controller(self): controllers = controllersConfig.loadControllerConfig( 0, GPIOUUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = libretroControllers.writeControllerConfig( controllers["1"], "1", snes) self.assertTrue( libretroControllers.libretroSettings.load( "input_player1_analog_dpad_mode"), "0")
def test_write_controller_config(self): controllers = controllersConfig.loadControllerConfig(2, PS3UUID, "p1controller","", 1, PS3UUID, "p2controller","", -1, PS3UUID, "p3controller","", -1, PS3UUID, "p4controller","") fba2xControllers.writeControllersConfig("fba", "sf2.zip", controllers) self.assertEquals(self.fbaSettings.load('SDLID_1'), '2') self.assertEquals(self.fbaSettings.load('SDLID_2'), '1') self.assertEquals(self.fbaSettings.load('SDLID_3'), '-1') self.assertEquals(self.fbaSettings.load('SDLID_4'), '-1')
def test_generate_ps3_controller_joysticks_right(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller", -1, 0, "p2controller", -1, 0, "p3controller", -1, 0, "p4controller") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_device'], '"p1controller"') self.assertEquals(config['input_r_y_plus_axis'], '+3') self.assertEquals(config['input_r_y_minus_axis'], '-3') self.assertEquals(config['input_r_x_plus_axis'], '+2') self.assertEquals(config['input_r_x_minus_axis'], '-2')
def test_remove_hotkeys_on_configure_with_es_menu_none(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") command = libretroGen.generate(self.snes, rom, controllers) self.assertEquals(libretroConfig.libretroSettings.load('input_menu_toggle_btn'), '14') self.snes2.config['specials'] = "none" command = libretroGen.generate(self.snes2, rom, controllers) self.assertEquals(libretroConfig.libretroSettings.load('input_menu_toggle_btn'), None)
def test_generate_ps3_controller_joysticks(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_player1_l_y_plus_axis'], '+1') self.assertEquals(config['input_player1_l_y_minus_axis'], '-1') self.assertEquals(config['input_player1_l_x_plus_axis'], '+0') self.assertEquals(config['input_player1_l_x_minus_axis'], '-0')
def test_generate_ps3_controller_directions(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = fba2xControllers.generateControllerConfig("1", controllers["1"]) self.assertEquals(config['UP_1'], '4') self.assertEquals(config['DOWN_1'], '6') self.assertEquals(config['LEFT_1'], '7') self.assertEquals(config['RIGHT_1'], '5')
def main(args): playersControllers = dict() # Read the controller configuration playersControllers = controllers.loadControllerConfig( args.p1index, args.p1guid, args.p1name, args.p1devicepath, args.p1nbaxes, args.p2index, args.p2guid, args.p2name, args.p2devicepath, args.p2nbaxes, args.p3index, args.p3guid, args.p3name, args.p3devicepath, args.p3nbaxes, args.p4index, args.p4guid, args.p4name, args.p4devicepath, args.p4nbaxes, args.p5index, args.p5guid, args.p5name, args.p5devicepath, args.p5nbaxes) # find the system to run systemName = args.system eslog.log("Running system: {}".format(systemName)) system = Emulator(systemName) eslog.debug("Settings: {}".format(system.config)) if "emulator" in system.config and "core" in system.config: eslog.log("emulator: {}, core: {}".format(system.config["emulator"], system.config["core"])) else: if "emulator" in system.config: eslog.log("emulator: {}".format(system.config["emulator"])) # the resolution must be changed before configuration while the configuration may depend on it (ie bezels) wantedGameMode = generators[system.config['emulator']].getResolutionMode( system.config) systemMode = videoMode.getCurrentMode() resolutionChanged = False exitCode = -1 try: eslog.log("current video mode: {}".format(systemMode)) eslog.log("wanted video mode: {}".format(wantedGameMode)) if wantedGameMode != 'default' and wantedGameMode != systemMode: videoMode.changeMode(wantedGameMode) resolutionChanged = True gameResolution = videoMode.getCurrentResolution() eslog.log("resolution: {}x{}".format(str(gameResolution["width"]), str(gameResolution["height"]))) # savedir: create the save directory if not already done dirname = os.path.join(batoceraFiles.savesDir, system.name) if not os.path.exists(dirname): os.makedirs(dirname) # run the emulator exitCode = runCommand(generators[system.config['emulator']].generate( system, args.rom, playersControllers, gameResolution)) finally: # always restore the resolution if resolutionChanged: try: videoMode.changeMode(systemMode) except Exception: pass # don't fail # exit return exitCode
def test_associate_controllers_with_players_with_differentuuid(self): uuid1 = "060000004c0500006802000000010000" uuid2 = "030000005e0400008e02000014010000" players = controllersConfig.loadControllerConfig( "-1", uuid1, "p1controller", "-1", uuid2, "p2controller", "-1", uuid2, "p3controller", "-1", uuid2, "p4controller") self.assertEquals(4, len(players)) self.assertEquals(uuid1, players["1"].guid) self.assertEquals(uuid2, players["2"].guid) self.assertEquals("13", players["1"].inputs["a"].id)
def test_write_controller_config(self): controllers = controllersConfig.loadControllerConfig( 2, PS3UUID, "p1controller", "", 1, PS3UUID, "p2controller", "", -1, PS3UUID, "p3controller", "", -1, PS3UUID, "p4controller", "") fba2xControllers.writeControllersConfig("fba", "sf2.zip", controllers) self.assertEquals(self.fbaSettings.load('SDLID_1'), '2') self.assertEquals(self.fbaSettings.load('SDLID_2'), '1') self.assertEquals(self.fbaSettings.load('SDLID_3'), '-1') self.assertEquals(self.fbaSettings.load('SDLID_4'), '-1')
def test_generate_ps3_controller_6buttons(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = fba2xControllers.generateControllerConfig("1", controllers["1"], True) self.assertEquals(config['X_1'], '12') self.assertEquals(config['Y_1'], '14') self.assertEquals(config['A_1'], '15') self.assertEquals(config['B_1'], '10') self.assertEquals(config['L_1'], '13') self.assertEquals(config['R_1'], '11')
def test_generate_only_axis_controller_doesnt_put_zero_in_directions(self): controllers = controllersConfig.loadControllerConfig( 0, GPIOUUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = fba2xControllers.generateControllerConfig( "1", controllers["1"], True) self.assertFalse('RIGHT_1' in config) self.assertFalse('LEFT_1' in config) self.assertFalse('UP_1' in config) self.assertFalse('DOWN_1' in config)
def test_write_ps3_controller_joysticks(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = libretroControllers.writeControllerConfig(controllers["1"], "1", snes) with open(RETROARCH_CONFIG) as controllerFile: lines = [] for line in controllerFile: lines.append(line) self.assertTrue('input_player1_l2_btn = 8\n' in lines) self.assertTrue(libretroControllers.libretroSettings.load("input_player1_analog_dpad_mode"), "1")
def test_generate_ps3_controller_joysticks_right(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", -1, 0, "p2controller", -1, 0, "p3controller", -1, 0, "p4controller") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_device'], '"p1controller"') self.assertEquals(config['input_driver'], '"udev"') self.assertEquals(config['input_r_y_plus_axis'], '+3') self.assertEquals(config['input_r_y_minus_axis'], '-3') self.assertEquals(config['input_r_x_plus_axis'], '+2') self.assertEquals(config['input_r_x_minus_axis'], '-2')
def test_generate_ps3_controller_directions(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = fba2xControllers.generateControllerConfig( "1", controllers["1"]) self.assertEquals(config['UP_1'], '4') self.assertEquals(config['DOWN_1'], '6') self.assertEquals(config['LEFT_1'], '7') self.assertEquals(config['RIGHT_1'], '5')
def test_associate_controllers_with_players_with_sameuuid(self): uuid = "060000004c0500006802000000010000" players = controllersConfig.loadControllerConfig("-1", uuid, "p1controller", "-1", uuid, "p2controller", "-1", uuid, "p3controller", "-1", uuid, "p4controller") self.assertEquals(4, len(players)) self.assertEquals(uuid, players["1"].guid) self.assertEquals(players["1"].realName, "p1controller") self.assertEquals(players["2"].realName, "p2controller") self.assertEquals(players["3"].realName, "p3controller") self.assertEquals(players["4"].realName, "p4controller") self.assertEquals(players["3"].name, players["1"].name)
def test_generate_ps3_controller_6buttons(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = fba2xControllers.generateControllerConfig( "1", controllers["1"], True) self.assertEquals(config['X_1'], '12') self.assertEquals(config['Y_1'], '14') self.assertEquals(config['A_1'], '15') self.assertEquals(config['B_1'], '10') self.assertEquals(config['L_1'], '13') self.assertEquals(config['R_1'], '11')
def test_associate_controllers_with_players_with_sameuuid(self): uuid = "060000004c0500006802000000010000" players = controllersConfig.loadControllerConfig( "-1", uuid, "p1controller", "-1", uuid, "p2controller", "-1", uuid, "p3controller", "-1", uuid, "p4controller") self.assertEquals(4, len(players)) self.assertEquals(uuid, players["1"].guid) self.assertEquals(players["1"].realName, "p1controller") self.assertEquals(players["2"].realName, "p2controller") self.assertEquals(players["3"].realName, "p3controller") self.assertEquals(players["4"].realName, "p4controller") self.assertEquals(players["3"].name, players["1"].name)
def test_generate_ps3_controller_buttons(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_player1_select_btn'], '0') self.assertEquals(config['input_player1_a_btn'], '13') self.assertEquals(config['input_player1_start_btn'], '3') self.assertEquals(config['input_player1_b_btn'], '14') self.assertEquals(config['input_player1_l2_btn'], '8') self.assertEquals(config['input_player1_r_btn'], '11') self.assertEquals(config['input_player1_y_btn'], '15') self.assertEquals(config['input_player1_x_btn'], '12') self.assertEquals(config['input_player1_l_btn'], '10')
def test_generate_ps3_controller_buttons(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = libretroControllers.generateControllerConfig(controllers["1"]) self.assertEquals(config['input_player1_select_btn'], '0') self.assertEquals(config['input_player1_a_btn'], '13') self.assertEquals(config['input_player1_start_btn'], '3') self.assertEquals(config['input_player1_b_btn'], '14') self.assertEquals(config['input_player1_l2_btn'], '8') self.assertEquals(config['input_player1_r_btn'], '11') self.assertEquals(config['input_player1_y_btn'], '15') self.assertEquals(config['input_player1_x_btn'], '12') self.assertEquals(config['input_player1_l_btn'], '10')
def test_write_ps3_controller_joysticks(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") config = libretroControllers.writeControllerConfig( controllers["1"], "1", snes) with open(RETROARCH_CONFIG) as controllerFile: lines = [] for line in controllerFile: lines.append(line) self.assertTrue('input_player1_l2_btn = 8\n' in lines) self.assertTrue( libretroControllers.libretroSettings.load( "input_player1_analog_dpad_mode"), "1")
def main(args): playersControllers = dict() if not args.demo: # Read the controller configuration playersControllers = controllers.loadControllerConfig(args.p1index, args.p1guid, args.p1name, args.p1devicepath, args.p1nbaxes, args.p2index, args.p2guid, args.p2name, args.p2devicepath, args.p2nbaxes, args.p3index, args.p3guid, args.p3name, args.p3devicepath, args.p3nbaxes, args.p4index, args.p4guid, args.p4name, args.p4devicepath, args.p4nbaxes, args.p5index, args.p5guid, args.p5name, args.p5devicepath, args.p5nbaxes) # find the system to run systemName = args.system eslog.log("Running system: " + systemName) system = getDefaultEmulator(systemName) if system is None: eslog.log("no emulator defined. exiting.") return 1 system.configure(args.emulator, args.core, args.ratio, args.netplay) # the resolution must be changed before configuration while the configuration may depend on it (ie bezels) newResolution = generators[system.config['emulator']].getResolution(system.config) exitCode = -1 try: videoMode.changeResolution(newResolution) gameResolution = videoMode.getCurrentResolution() eslog.log("resolution: " + str(gameResolution["width"]) + "x" + str(gameResolution["height"])) # savedir: create the save directory is not already done dirname = os.path.join(recalboxFiles.savesDir, system.name) if not os.path.exists(dirname): os.makedirs(dirname) # run the emulator exitCode = runCommand(generators[system.config['emulator']].generate(system, args.rom, playersControllers, gameResolution)) finally: # always restore the resolution if newResolution != 'default': try: videoMode.resetResolution() except Exception: pass # don't fail # exit return exitCode
def test_generate_specials(self): controllers = controllersConfig.loadControllerConfig(0, GPIOUUID, "p1controller", -1, 0, "p2controller", -1, 0, "p3controller", -1, 0, "p4controller") config = libretroControllers.generateControllerConfig(controllers["1"]) print config self.assertEquals(config['input_exit_emulator_btn'], '7')
def main(args, maxnbplayers): playersControllers = dict() controllersInput = [] for p in range(1, maxnbplayers + 1): ci = {} ci["index"] = getattr(args, "p{}index".format(p)) ci["guid"] = getattr(args, "p{}guid".format(p)) ci["name"] = getattr(args, "p{}name".format(p)) ci["devicepath"] = getattr(args, "p{}devicepath".format(p)) ci["nbbuttons"] = getattr(args, "p{}nbbuttons".format(p)) ci["nbhats"] = getattr(args, "p{}nbhats".format(p)) ci["nbaxes"] = getattr(args, "p{}nbaxes".format(p)) controllersInput.append(ci) # Read the controller configuration playersControllers = controllers.loadControllerConfig(controllersInput) # find the system to run systemName = args.system eslog.log("Running system: {}".format(systemName)) system = Emulator(systemName, args.rom) if args.emulator is not None: system.config["emulator"] = args.emulator system.config["emulator-forced"] = True if args.core is not None: system.config["core"] = args.core system.config["core-forced"] = True debugDisplay = system.config.copy() if "retroachievements.password" in debugDisplay: debugDisplay["retroachievements.password"] = "******" eslog.debug("Settings: {}".format(debugDisplay)) if "emulator" in system.config and "core" in system.config: eslog.log("emulator: {}, core: {}".format(system.config["emulator"], system.config["core"])) else: if "emulator" in system.config: eslog.log("emulator: {}".format(system.config["emulator"])) # the resolution must be changed before configuration while the configuration may depend on it (ie bezels) wantedGameMode = generators[system.config['emulator']].getResolutionMode( system.config) systemMode = videoMode.getCurrentMode() resolutionChanged = False mouseChanged = False exitCode = -1 try: # lower the resolution if mode is auto newsystemMode = systemMode # newsystemmode is the mode after minmax (ie in 1K if tv was in 4K), systemmode is the mode before (ie in es) if system.config["videomode"] == "" or system.config[ "videomode"] == "default": eslog.log("minTomaxResolution") eslog.log("video mode before minmax: {}".format(systemMode)) videoMode.minTomaxResolution() newsystemMode = videoMode.getCurrentMode() if newsystemMode != systemMode: resolutionChanged = True eslog.log("current video mode: {}".format(newsystemMode)) eslog.log("wanted video mode: {}".format(wantedGameMode)) if wantedGameMode != 'default' and wantedGameMode != newsystemMode: videoMode.changeMode(wantedGameMode) resolutionChanged = True gameResolution = videoMode.getCurrentResolution() # if resolution is reversed (ie ogoa boards), reverse it in the gameResolution to have it correct if system.isOptSet('resolutionIsReversed') and system.getOptBoolean( 'resolutionIsReversed') == True: x = gameResolution["width"] gameResolution["width"] = gameResolution["height"] gameResolution["height"] = x eslog.log("resolution: {}x{}".format(str(gameResolution["width"]), str(gameResolution["height"]))) # savedir: create the save directory if not already done dirname = os.path.join(batoceraFiles.savesDir, system.name) if not os.path.exists(dirname): os.makedirs(dirname) # core effectiveCore = "" if "core" in system.config and system.config["core"] is not None: effectiveCore = system.config["core"] effectiveRom = "" if args.rom is not None: effectiveRom = args.rom # network options if args.netplaymode is not None: system.config["netplay.mode"] = args.netplaymode if args.netplaypass is not None: system.config["netplay.password"] = args.netplaypass if args.netplayip is not None: system.config["netplay.server.ip"] = args.netplayip if args.netplayport is not None: system.config["netplay.server.port"] = args.netplayport # autosave arguments if args.state_slot is not None: system.config["state_slot"] = args.state_slot if args.autosave is not None: system.config["autosave"] = args.autosave if generators[system.config['emulator']].getMouseMode(system.config): mouseChanged = True videoMode.changeMouse(True) # run a script before emulator starts callExternalScripts("/usr/share/batocera/configgen/scripts", "gameStart", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) callExternalScripts("/userdata/system/scripts", "gameStart", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) # run the emulator try: Evmapy.start(systemName, system.config['emulator'], effectiveCore, effectiveRom, playersControllers) exitCode = runCommand( generators[system.config['emulator']].generate( system, args.rom, playersControllers, gameResolution)) finally: Evmapy.stop() # run a script after emulator shuts down callExternalScripts("/userdata/system/scripts", "gameStop", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) callExternalScripts("/usr/share/batocera/configgen/scripts", "gameStop", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) finally: # always restore the resolution if resolutionChanged: try: videoMode.changeMode(systemMode) except Exception: pass # don't fail if mouseChanged: try: videoMode.changeMouse(False) except Exception: pass # don't fail # exit return exitCode
def main(args, maxnbplayers): playersControllers = dict() controllersInput = [] for p in range(1, maxnbplayers + 1): ci = {} ci["index"] = getattr(args, "p{}index".format(p)) ci["guid"] = getattr(args, "p{}guid".format(p)) ci["name"] = getattr(args, "p{}name".format(p)) ci["devicepath"] = getattr(args, "p{}devicepath".format(p)) ci["nbbuttons"] = getattr(args, "p{}nbbuttons".format(p)) ci["nbhats"] = getattr(args, "p{}nbhats".format(p)) ci["nbaxes"] = getattr(args, "p{}nbaxes".format(p)) controllersInput.append(ci) # Read the controller configuration playersControllers = controllers.loadControllerConfig(controllersInput) # find the system to run systemName = args.system eslog.log("Running system: {}".format(systemName)) system = Emulator(systemName, args.rom) system.config["emulator-forced"] = False system.config["core-forced"] = False if args.emulator is not None: system.config["emulator"] = args.emulator system.config[ "emulator-forced"] = True # tip to indicated that the emulator was forced if args.core is not None: system.config["core"] = args.core system.config["core-forced"] = True eslog.debug("Settings: {}".format(system.config)) if "emulator" in system.config and "core" in system.config: eslog.log("emulator: {}, core: {}".format(system.config["emulator"], system.config["core"])) else: if "emulator" in system.config: eslog.log("emulator: {}".format(system.config["emulator"])) # the resolution must be changed before configuration while the configuration may depend on it (ie bezels) wantedGameMode = generators[system.config['emulator']].getResolutionMode( system.config) systemMode = videoMode.getCurrentMode() resolutionChanged = False exitCode = -1 try: eslog.log("current video mode: {}".format(systemMode)) eslog.log("wanted video mode: {}".format(wantedGameMode)) if wantedGameMode != 'default' and wantedGameMode != systemMode: videoMode.changeMode(wantedGameMode) resolutionChanged = True gameResolution = videoMode.getCurrentResolution() eslog.log("resolution: {}x{}".format(str(gameResolution["width"]), str(gameResolution["height"]))) # savedir: create the save directory if not already done dirname = os.path.join(batoceraFiles.savesDir, system.name) if not os.path.exists(dirname): os.makedirs(dirname) # core effectiveCore = "" if "core" in system.config and system.config["core"] is not None: effectiveCore = system.config["core"] effectiveRom = "" if args.rom is not None: effectiveRom = args.rom # network options if args.netplaymode is not None: system.config["netplay.mode"] = args.netplaymode if args.netplayspectator is not None: system.config["netplay.spectator"] = args.netplayspectator if args.netplayip is not None: system.config["netplay.server.ip"] = args.netplayip if args.netplayport is not None: system.config["netplay.server.port"] = args.netplayport # run a script before emulator starts callExternalScripts("/usr/share/batocera/configgen/scripts", "gameStart", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) callExternalScripts("/userdata/system/scripts", "gameStart", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) # run the emulator exitCode = runCommand(generators[system.config['emulator']].generate( system, args.rom, playersControllers, gameResolution)) # run a script after emulator shuts down callExternalScripts("/userdata/system/scripts", "gameStop", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) callExternalScripts("/usr/share/batocera/configgen/scripts", "gameStop", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) finally: # always restore the resolution if resolutionChanged: try: videoMode.changeMode(systemMode) except Exception: pass # don't fail # exit return exitCode
def main(args): playersControllers = dict() # Read the controller configuration playersControllers = controllers.loadControllerConfig( args.p1index, args.p1guid, args.p1name, args.p1devicepath, args.p1nbaxes, args.p2index, args.p2guid, args.p2name, args.p2devicepath, args.p2nbaxes, args.p3index, args.p3guid, args.p3name, args.p3devicepath, args.p3nbaxes, args.p4index, args.p4guid, args.p4name, args.p4devicepath, args.p4nbaxes, args.p5index, args.p5guid, args.p5name, args.p5devicepath, args.p5nbaxes) # find the system to run systemName = args.system eslog.log("Running system: {}".format(systemName)) system = Emulator(systemName, args.rom) if args.emulator is not None: system.config["emulator"] = args.emulator if args.core is not None: system.config["core"] = args.core eslog.debug("Settings: {}".format(system.config)) if "emulator" in system.config and "core" in system.config: eslog.log("emulator: {}, core: {}".format(system.config["emulator"], system.config["core"])) else: if "emulator" in system.config: eslog.log("emulator: {}".format(system.config["emulator"])) # the resolution must be changed before configuration while the configuration may depend on it (ie bezels) wantedGameMode = generators[system.config['emulator']].getResolutionMode( system.config) systemMode = videoMode.getCurrentMode() resolutionChanged = False exitCode = -1 try: eslog.log("current video mode: {}".format(systemMode)) eslog.log("wanted video mode: {}".format(wantedGameMode)) if wantedGameMode != 'default' and wantedGameMode != systemMode: videoMode.changeMode(wantedGameMode) resolutionChanged = True gameResolution = videoMode.getCurrentResolution() eslog.log("resolution: {}x{}".format(str(gameResolution["width"]), str(gameResolution["height"]))) # savedir: create the save directory if not already done dirname = os.path.join(batoceraFiles.savesDir, system.name) if not os.path.exists(dirname): os.makedirs(dirname) # core effectiveCore = "" if "core" in system.config and system.config["core"] is not None: effectiveCore = system.config["core"] effectiveRom = "" if args.rom is not None: effectiveRom = args.rom # network options if args.netplaymode is not None: system.config["netplay.mode"] = args.netplaymode if args.netplayip is not None: system.config["netplay.server.ip"] = args.netplayip if args.netplayport is not None: system.config["netplay.server.port"] = args.netplayport # run a script before emulator starts callExternalScripts("/userdata/system/scripts", "gameStart", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) # run the emulator exitCode = runCommand(generators[system.config['emulator']].generate( system, args.rom, playersControllers, gameResolution)) # run a script after emulator shuts down callExternalScripts("/userdata/system/scripts", "gameStop", [ systemName, system.config['emulator'], effectiveCore, effectiveRom ]) finally: # always restore the resolution if resolutionChanged: try: videoMode.changeMode(systemMode) except Exception: pass # don't fail # exit return exitCode
parser.add_argument("-p5name", help="player5 controller name", type=str, required=False) parser.add_argument("-p5devicepath", help="player5 controller device", type=str, required=False) parser.add_argument("-system", help="select the system to launch", type=str, required=True) parser.add_argument("-rom", help="rom absolute path", type=str, required=True) parser.add_argument("-emulator", help="force emulator", type=str, required=False) parser.add_argument("-core", help="fore emulator core", type=str, required=False) parser.add_argument("-demo", help="mode demo", type=bool, required=False) args = parser.parse_args() playersControllers = dict() if not args.demo: # Read the controller configuration playersControllers = controllers.loadControllerConfig(args.p1index, args.p1guid, args.p1name, args.p1devicepath, args.p2index, args.p2guid, args.p2name, args.p2devicepath, args.p3index, args.p3guid, args.p3name, args.p3devicepath, args.p4index, args.p4guid, args.p4name, args.p4devicepath, args.p5index, args.p5guid, args.p5name, args.p5devicepath) systemName = args.system # Main Program # A generator will configure its emulator, and return a command if systemName in emulators: system = emulators[systemName] systemManager = ConfigManager() systemManager.configure(system, args.emulator, args.core) # Save dir if not os.path.exists(recalboxFiles.savesDir+system.name): os.makedirs(recalboxFiles.savesDir+system.name)
emulator='libretro', core='stella') emulators["atari7800"] = Emulator(name='atari7800', emulator='libretro', core='prosystem') emulators["msx"] = Emulator(name='msx', emulator='libretro', core='fmsx') emulators["prboom"] = Emulator(name='prboom', emulator='libretro', core='prboom') emulators["psx"] = Emulator(name='psx', emulator='libretro', core='pcsx_rearmed') # Read the controller configuration playersControllers = controllers.loadControllerConfig( args.p1index, args.p1guid, args.p1name, args.p2index, args.p2guid, args.p2name, args.p3index, args.p3guid, args.p3name, args.p4index, args.p4guid, args.p4name) systemName = args.system # Main Program # A generator will configure its emulator, and return a command if systemName in emulators: system = emulators[systemName] # Get the default configuration of the core systemSettings = system.config # Override the config with the global one systemSettings.update(recalSettings.loadAll('global')) # Override the config with the core specific one systemSettings.update(recalSettings.loadAll(system.name))
def test_write_only_joystick_controller(self): controllers = controllersConfig.loadControllerConfig(0, GPIOUUID, "p1controller", -1, 0, "p2controller", -1, 0, "p3controller", -1, 0, "p4controller") config = libretroControllers.writeControllerConfig(controllers["1"], "1", snes) self.assertTrue(libretroControllers.libretroSettings.load("input_player1_analog_dpad_mode"), "0")
def test_generate_ps3_controller_joystick(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = fba2xControllers.generateControllerConfig("1", controllers["1"]) self.assertEquals(config['JA_UD_1'], '1') self.assertEquals(config['JA_LR_1'], '0')
def test_generate_specialsKeys_off_save_exit_special(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = libretroControllers.generateControllerConfig(controllers["1"], True) self.assertEquals(config['input_exit_emulator_btn'], '3')
emulators["lynx"] = Emulator(name='lynx', emulator='libretro', core='mednafen_lynx') emulators["lutro"] = Emulator(name='lutro', emulator='libretro', core='lutro') emulators["wswan"] = Emulator(name='wswan', emulator='libretro', core='mednafen_wswan') emulators["pcengine"] = Emulator(name='pcengine', emulator='libretro', core='mednafen_supergrafx') emulators["atari2600"] = Emulator(name='atari2600', emulator='libretro', core='stella') emulators["atari7800"] = Emulator(name='atari7800', emulator='libretro', core='prosystem') emulators["msx"] = Emulator(name='msx', emulator='libretro', core='fmsx') emulators["prboom"] = Emulator(name='prboom', emulator='libretro', core='prboom') emulators["psx"] = Emulator(name='psx', emulator='libretro', core='pcsx_rearmed') # Read the controller configuration playersControllers = controllers.loadControllerConfig(args.p1index, args.p1guid, args.p1name, args.p2index, args.p2guid, args.p2name, args.p3index, args.p3guid, args.p3name, args.p4index, args.p4guid, args.p4name) systemName = args.system # Main Program # A generator will configure its emulator, and return a command if systemName in emulators: system = emulators[systemName] # Get the default configuration of the core systemSettings = system.config # Override the config with the global one systemSettings.update(recalSettings.loadAll('global')) # Override the config with the core specific one systemSettings.update(recalSettings.loadAll(system.name))
def test_enable_analog_mode_psx(self): controllers = controllersConfig.loadControllerConfig( 0, PS3UUID, "p1controller", "", -1, 0, "p2controller", "", -1, 0, "p3controller", "", -1, 0, "p4controller", "") val = libretroControllers.getAnalogCoreMode(controllers['1']) self.assertEquals("analog", val)
def start_rom(args, maxnbplayers, rom, romConfiguration): # controllers playersControllers = dict() controllersInput = [] for p in range(1, maxnbplayers+1): ci = {} ci["index"] = getattr(args, "p{}index" .format(p)) ci["guid"] = getattr(args, "p{}guid" .format(p)) ci["name"] = getattr(args, "p{}name" .format(p)) ci["devicepath"] = getattr(args, "p{}devicepath".format(p)) ci["nbbuttons"] = getattr(args, "p{}nbbuttons" .format(p)) ci["nbhats"] = getattr(args, "p{}nbhats" .format(p)) ci["nbaxes"] = getattr(args, "p{}nbaxes" .format(p)) controllersInput.append(ci) # Read the controller configuration playersControllers = controllers.loadControllerConfig(controllersInput) # find the system to run systemName = args.system eslog.debug("Running system: {}".format(systemName)) system = Emulator(systemName, romConfiguration) if args.emulator is not None: system.config["emulator"] = args.emulator system.config["emulator-forced"] = True if args.core is not None: system.config["core"] = args.core system.config["core-forced"] = True debugDisplay = system.config.copy() if "retroachievements.password" in debugDisplay: debugDisplay["retroachievements.password"] = "******" eslog.debug("Settings: {}".format(debugDisplay)) if "emulator" in system.config and "core" in system.config: eslog.debug("emulator: {}, core: {}".format(system.config["emulator"], system.config["core"])) else: if "emulator" in system.config: eslog.debug("emulator: {}".format(system.config["emulator"])) # the resolution must be changed before configuration while the configuration may depend on it (ie bezels) wantedGameMode = generators[system.config['emulator']].getResolutionMode(system.config) systemMode = videoMode.getCurrentMode() resolutionChanged = False mouseChanged = False exitCode = -1 try: # lower the resolution if mode is auto newsystemMode = systemMode # newsystemmode is the mode after minmax (ie in 1K if tv was in 4K), systemmode is the mode before (ie in es) if system.config["videomode"] == "" or system.config["videomode"] == "default": eslog.debug("minTomaxResolution") eslog.debug("video mode before minmax: {}".format(systemMode)) videoMode.minTomaxResolution() newsystemMode = videoMode.getCurrentMode() if newsystemMode != systemMode: resolutionChanged = True eslog.debug("current video mode: {}".format(newsystemMode)) eslog.debug("wanted video mode: {}".format(wantedGameMode)) if wantedGameMode != 'default' and wantedGameMode != newsystemMode: videoMode.changeMode(wantedGameMode) resolutionChanged = True gameResolution = videoMode.getCurrentResolution() # if resolution is reversed (ie ogoa boards), reverse it in the gameResolution to have it correct if system.isOptSet('resolutionIsReversed') and system.getOptBoolean('resolutionIsReversed') == True: x = gameResolution["width"] gameResolution["width"] = gameResolution["height"] gameResolution["height"] = x eslog.debug("resolution: {}x{}".format(str(gameResolution["width"]), str(gameResolution["height"]))) # savedir: create the save directory if not already done dirname = os.path.join(batoceraFiles.savesDir, system.name) if not os.path.exists(dirname): os.makedirs(dirname) # core effectiveCore = "" if "core" in system.config and system.config["core"] is not None: effectiveCore = system.config["core"] effectiveRom = "" effectiveRomConfiguration = "" if rom is not None: effectiveRom = rom effectiveRomConfiguration = romConfiguration # network options if args.netplaymode is not None: system.config["netplay.mode"] = args.netplaymode if args.netplaypass is not None: system.config["netplay.password"] = args.netplaypass if args.netplayip is not None: system.config["netplay.server.ip"] = args.netplayip if args.netplayport is not None: system.config["netplay.server.port"] = args.netplayport # autosave arguments if args.state_slot is not None: system.config["state_slot"] = args.state_slot if args.autosave is not None: system.config["autosave"] = args.autosave if generators[system.config['emulator']].getMouseMode(system.config): mouseChanged = True videoMode.changeMouse(True) # SDL VSync is a big deal on OGA and RPi4 if system.isOptSet('sdlvsync') and system.getOptBoolean('sdlvsync') == False: system.config["sdlvsync"] = '0' else: system.config["sdlvsync"] = '1' os.environ.update({'SDL_RENDER_VSYNC': system.config["sdlvsync"]}) # run a script before emulator starts callExternalScripts("/usr/share/batocera/configgen/scripts", "gameStart", [systemName, system.config['emulator'], effectiveCore, effectiveRom]) callExternalScripts("/userdata/system/scripts", "gameStart", [systemName, system.config['emulator'], effectiveCore, effectiveRom]) # run the emulator try: Evmapy.start(systemName, system.config['emulator'], effectiveCore, effectiveRomConfiguration, playersControllers) # change directory if wanted executionDirectory = generators[system.config['emulator']].executionDirectory(system.config, effectiveRom) if executionDirectory is not None: os.chdir(executionDirectory) cmd = generators[system.config['emulator']].generate(system, rom, playersControllers, gameResolution) if system.isOptSet('hud_support') and system.getOptBoolean('hud_support') == True: hud_bezel = getHudBezel(system, rom, gameResolution) if (system.isOptSet('hud') and system.config["hud"] != "" and system.config["hud"] != "none") or hud_bezel is not None: gameinfos = extractGameInfosFromXml(args.gameinfoxml) cmd.env["MANGOHUD_DLSYM"] = "1" hudconfig = getHudConfig(system, args.systemname, system.config['emulator'], effectiveCore, rom, gameinfos, hud_bezel) with open('/var/run/hud.config', 'w') as f: f.write(hudconfig) cmd.env["MANGOHUD_CONFIGFILE"] = "/var/run/hud.config" if generators[system.config['emulator']].hasInternalMangoHUDCall() == False: cmd.array.insert(0, "mangohud") exitCode = runCommand(cmd) finally: Evmapy.stop() # run a script after emulator shuts down callExternalScripts("/userdata/system/scripts", "gameStop", [systemName, system.config['emulator'], effectiveCore, effectiveRom]) callExternalScripts("/usr/share/batocera/configgen/scripts", "gameStop", [systemName, system.config['emulator'], effectiveCore, effectiveRom]) finally: # always restore the resolution if resolutionChanged: try: videoMode.changeMode(systemMode) except Exception: pass # don't fail if mouseChanged: try: videoMode.changeMouse(False) except Exception: pass # don't fail # exit return exitCode
def test_generate_ps3_controller_specials(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") config = fba2xControllers.generateControllerConfig("1", controllers["1"]) self.assertEquals(config['HOTKEY'], '16') self.assertEquals(config['QUIT'], '3')
def test_enable_analog_mode_psx(self): controllers = controllersConfig.loadControllerConfig(0, PS3UUID, "p1controller","", -1, 0, "p2controller","", -1, 0, "p3controller","", -1, 0, "p4controller","") val = libretroControllers.getAnalogCoreMode(controllers['1']) self.assertEquals("analog", val)