def generate(self, system, rom, playersControllers, gameResolution): retroconfig = UnixSettings(gamestationFiles.amiberryRetroarchCustom, separator=' ') if not os.path.exists(dirname( gamestationFiles.amiberryRetroarchCustom)): os.makedirs(dirname(gamestationFiles.amiberryRetroarchCustom)) romIsWhd = self.isWhdFile(rom) commandArray = [ gamestationFiles.gamestationBins[system.config['emulator']], "-G" ] if not romIsWhd: commandArray.append("-core=" + system.config['core']) # floppies n = 0 for img in self.floppiesFromRom(rom): if n < 4: commandArray.append("-" + str(n)) commandArray.append(img) n += 1 # floppy path if romIsWhd: commandArray.append("-autowhdload=" + rom) else: commandArray.append("-s") commandArray.append( "pandora.floppy_path=/gamestation/share/roms/amiga/" + system.config['core']) # controller libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) if not os.path.exists(gamestationFiles.amiberryRetroarchInputsDir): os.makedirs(gamestationFiles.amiberryRetroarchInputsDir) nplayer = 1 for playercontroller, pad in sorted(playersControllers.items()): replacements = {'_player' + str(nplayer) + '_': '_'} playerInputFilename = gamestationFiles.amiberryRetroarchInputsDir + "/" + pad.realName + ".cfg" with open( gamestationFiles.amiberryRetroarchCustom) as infile, open( playerInputFilename, 'w') as outfile: for line in infile: for src, target in replacements.iteritems(): newline = line.replace(src, target) if not newline.isspace(): outfile.write(newline) nplayer += 1 # fps if system.config['showFPS'] == 'true': commandArray.append("-s") commandArray.append("show_leds=true") os.chdir("/usr/share/amiberry") return Command.Command(array=commandArray)
def test_2_last_controllers(self): val = libretroControllers.writeControllersConfig( snes, controllers2weird) self.assertEquals(libretroSettings.load("input_player2_joypad_index"), "2") self.assertEquals(libretroSettings.load("input_player3_joypad_index"), "3")
def test_4_controller(self): val = libretroControllers.writeControllersConfig(snes, controllers4) self.assertEquals(libretroSettings.load("input_player1_joypad_index"), "0") self.assertEquals(libretroSettings.load("input_player2_joypad_index"), "1") self.assertEquals(libretroSettings.load("input_player3_joypad_index"), "2") self.assertEquals(libretroSettings.load("input_player4_joypad_index"), "3")
def generate(self, system, rom, playersControllers, gameResolution): retroconfig = UnixSettings(batoceraFiles.amiberryRetroarchCustom, separator=' ') if not os.path.exists(dirname(batoceraFiles.amiberryRetroarchCustom)): os.makedirs(dirname(batoceraFiles.amiberryRetroarchCustom)) romType = self.getRomType(rom) eslog.log("romType"+romType) if romType != 'UNKNOWN' : commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-G" ] if romType != 'WHDL' : commandArray.append("-model=" + system.config['core']) if romType == 'WHDL' : commandArray.append("-autoload="+rom) elif romType == 'HDF' : commandArray.append("-s") commandArray.append("hardfile2=rw,DH0:"+rom+",32,1,2,512,0,,uae0") commandArray.append("-s") commandArray.append("uaehf0=hdf,rw,DH0:"+rom+",32,1,2,512,0,,uae0") elif romType == 'CD' : commandArray.append("-cdimage="+rom) elif romType == 'DISK': # floppies n = 0 for img in self.floppiesFromRom(rom): if n < 4: commandArray.append("-" + str(n)) commandArray.append(img) n += 1 # floppy path commandArray.append("-s") # Use disk folder as floppy path romPathIndex = rom.rfind('/') commandArray.append("amiberry.floppy_path="+rom[0:romPathIndex]) # controller libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) if not os.path.exists(batoceraFiles.amiberryRetroarchInputsDir): os.makedirs(batoceraFiles.amiberryRetroarchInputsDir) nplayer = 1 for playercontroller, pad in sorted(playersControllers.items()): replacements = {'_player' + str(nplayer) + '_':'_'} # amiberry remove / included in pads names like "USB Downlo01.80 PS3/USB Corded Gamepad" padfilename = pad.realName.replace("/", "") playerInputFilename = batoceraFiles.amiberryRetroarchInputsDir + "/" + padfilename + ".cfg" with open(batoceraFiles.amiberryRetroarchCustom) as infile, open(playerInputFilename, 'w') as outfile: for line in infile: for src, target in replacements.iteritems(): newline = line.replace(src, target) if not newline.isspace(): outfile.write(newline) if nplayer == 1: # 1 = joystick port commandArray.append("-s") commandArray.append("joyport1_friendlyname=" + padfilename) if romType == 'CD' : commandArray.append("-s") commandArray.append("joyport1_mode=cd32joy") if nplayer == 2: # 0 = mouse for the player 2 commandArray.append("-s") commandArray.append("joyport0_friendlyname=" + padfilename) nplayer += 1 # fps if system.config['showFPS'] == 'true': commandArray.append("-s") commandArray.append("show_leds=true") # disable port 2 (otherwise, the joystick goes on it) commandArray.append("-s") commandArray.append("joyport2=") # display vertical centering commandArray.append("-s") commandArray.append("gfx_center_vertical=smart") os.chdir("/usr/share/amiberry") return Command.Command(array=commandArray)
def generate(self, system, rom, playersControllers, gameResolution): retroconfig = UnixSettings(batoceraFiles.amiberryRetroarchCustom, separator=' ') if not os.path.exists(dirname(batoceraFiles.amiberryRetroarchCustom)): os.makedirs(dirname(batoceraFiles.amiberryRetroarchCustom)) romIsWhd = self.isWhdFile(rom) commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-G" ] if not romIsWhd: commandArray.append("-model=" + system.config['core']) # floppies n = 0 for img in self.floppiesFromRom(rom): if n < 4: commandArray.append("-" + str(n)) commandArray.append(img) n += 1 # floppy path if romIsWhd: commandArray.append("-autoload=" + rom) else: commandArray.append("-s") commandArray.append("amiberry.floppy_path=/userdata/roms/amiga/" + system.config['core']) # controller libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) if not os.path.exists(batoceraFiles.amiberryRetroarchInputsDir): os.makedirs(batoceraFiles.amiberryRetroarchInputsDir) nplayer = 1 for playercontroller, pad in sorted(playersControllers.items()): replacements = {'_player' + str(nplayer) + '_': '_'} # amiberry remove / included in pads names like "USB Downlo01.80 PS3/USB Corded Gamepad" padfilename = pad.realName.replace("/", "") playerInputFilename = batoceraFiles.amiberryRetroarchInputsDir + "/" + padfilename + ".cfg" with open(batoceraFiles.amiberryRetroarchCustom) as infile, open( playerInputFilename, 'w') as outfile: for line in infile: for src, target in replacements.iteritems(): newline = line.replace(src, target) if not newline.isspace(): outfile.write(newline) if nplayer == 1: # 1 = joystick port commandArray.append("-s") commandArray.append("joyport1_friendlyname=" + padfilename) if nplayer == 2: # 0 = mouse for the player 2 commandArray.append("-s") commandArray.append("joyport0_friendlyname=" + padfilename) nplayer += 1 # fps if system.config['showFPS'] == 'true': commandArray.append("-s") commandArray.append("show_leds=true") # disable port 2 (otherwise, the joystick goes on it) commandArray.append("-s") commandArray.append("joyport2=") # display vertical centering commandArray.append("-s") commandArray.append("gfx_center_vertical=smart") os.chdir("/usr/share/amiberry") return Command.Command(array=commandArray)
def generate(self, system, rom, playersControllers, gameResolution): retroconfig = UnixSettings(batoceraFiles.amiberryRetroarchCustom, separator=' ') if not os.path.exists(dirname(batoceraFiles.amiberryRetroarchCustom)): os.makedirs(dirname(batoceraFiles.amiberryRetroarchCustom)) romType = self.getRomType(rom) eslog.debug("romType: " + romType) if romType != 'UNKNOWN': commandArray = [ batoceraFiles.batoceraBins[system.config['emulator']], "-G" ] if romType != 'WHDL': commandArray.append("--model") commandArray.append(system.config['core']) if romType == 'WHDL': commandArray.append("--autoload") commandArray.append(rom) elif romType == 'HDF': commandArray.append("-s") commandArray.append("hardfile2=rw,DH0:" + rom + ",32,1,2,512,0,,uae0") commandArray.append("-s") commandArray.append("uaehf0=hdf,rw,DH0:" + rom + ",32,1,2,512,0,,uae0") elif romType == 'CD': commandArray.append("--cdimage") commandArray.append(rom) elif romType == 'DISK': # floppies n = 0 for img in self.floppiesFromRom(rom): if n < 4: commandArray.append("-" + str(n)) commandArray.append(img) n += 1 # floppy path commandArray.append("-s") # Use disk folder as floppy path romPathIndex = rom.rfind('/') commandArray.append("amiberry.floppy_path=" + rom[0:romPathIndex]) # controller libretroControllers.writeControllersConfig(retroconfig, system, playersControllers) retroconfig.write() if not os.path.exists(batoceraFiles.amiberryRetroarchInputsDir): os.makedirs(batoceraFiles.amiberryRetroarchInputsDir) nplayer = 1 for playercontroller, pad in sorted(playersControllers.items()): replacements = {'_player' + str(nplayer) + '_': '_'} # amiberry remove / included in pads names like "USB Downlo01.80 PS3/USB Corded Gamepad" padfilename = pad.realName.replace("/", "") playerInputFilename = batoceraFiles.amiberryRetroarchInputsDir + "/" + padfilename + ".cfg" with open( batoceraFiles.amiberryRetroarchCustom) as infile, open( playerInputFilename, 'w') as outfile: for line in infile: for src, target in replacements.items(): newline = line.replace(src, target) if not newline.isspace(): outfile.write(newline) if nplayer == 1: # 1 = joystick port commandArray.append("-s") commandArray.append("joyport1_friendlyname=" + padfilename) if romType == 'CD': commandArray.append("-s") commandArray.append("joyport1_mode=cd32joy") if nplayer == 2: # 0 = mouse for the player 2 commandArray.append("-s") commandArray.append("joyport0_friendlyname=" + padfilename) nplayer += 1 # fps if system.config['showFPS'] == 'true': commandArray.append("-s") commandArray.append("show_leds=true") # disable port 2 (otherwise, the joystick goes on it) commandArray.append("-s") commandArray.append("joyport2=") # remove interlace artifacts if system.isOptSet("amiberry_flickerfixer") and system.config[ 'amiberry_flickerfixer'] == 'true': commandArray.append("-s") commandArray.append("gfx_flickerfixer=true") else: commandArray.append("-s") commandArray.append("gfx_flickerfixer=false") # auto height if system.isOptSet("amiberry_auto_height") and system.config[ 'amiberry_auto_height'] == 'true': commandArray.append("-s") commandArray.append("amiberry.gfx_auto_height=true") else: commandArray.append("-s") commandArray.append("amiberry.gfx_auto_height=false") # line mode if system.isOptSet("amiberry_linemode"): if system.config['amiberry_linemode'] == 'none': commandArray.append("-s") commandArray.append("gfx_linemode=none") elif system.config['amiberry_linemode'] == 'scanlines': commandArray.append("-s") commandArray.append("gfx_linemode=scanlines") elif system.config['amiberry_linemode'] == 'double': commandArray.append("-s") commandArray.append("gfx_linemode=double") else: commandArray.append("-s") commandArray.append("gfx_linemode=double") # video resolution if system.isOptSet("amiberry_resolution"): if system.config['amiberry_resolution'] == 'lores': commandArray.append("-s") commandArray.append("gfx_resolution=lores") elif system.config['amiberry_resolution'] == 'superhires': commandArray.append("-s") commandArray.append("gfx_resolution=superhires") elif system.config['amiberry_resolution'] == 'hires': commandArray.append("-s") commandArray.append("gfx_resolution=hires") else: commandArray.append("-s") commandArray.append("gfx_resolution=hires") # Scaling method if system.isOptSet("amiberry_scalingmethod"): if system.config['amiberry_scalingmethod'] == 'automatic': commandArray.append("-s") commandArray.append("gfx_lores_mode=false") commandArray.append("-s") commandArray.append("amiberry.scaling_method=-1") elif system.config['amiberry_scalingmethod'] == 'smooth': commandArray.append("-s") commandArray.append("gfx_lores_mode=true") commandArray.append("-s") commandArray.append("amiberry.scaling_method=1") elif system.config['amiberry_scalingmethod'] == 'pixelated': commandArray.append("-s") commandArray.append("gfx_lores_mode=true") commandArray.append("-s") commandArray.append("amiberry.scaling_method=0") else: commandArray.append("-s") commandArray.append("gfx_lores_mode=false") commandArray.append("-s") commandArray.append("amiberry.scaling_method=-1") # display vertical centering commandArray.append("-s") commandArray.append("gfx_center_vertical=smart") # fix sound buffer commandArray.append("-s") commandArray.append("sound_max_buff=4096") os.chdir("/usr/share/amiberry") return Command.Command( array=commandArray, env={ "SDL_GAMECONTROLLERCONFIG": controllersConfig.generateSdlGameControllerConfig( playersControllers) }) # otherwise, unknown format return Command.Command(array=[])
def test_2_last_controllers(self): val = libretroControllers.writeControllersConfig(snes,controllers2weird) self.assertEquals(libretroSettings.load("input_player2_joypad_index"), "2") self.assertEquals(libretroSettings.load("input_player3_joypad_index"), "3")
def test_reversed_controller(self): val = libretroControllers.writeControllersConfig(snes,controllers4reversed) self.assertEquals(libretroSettings.load("input_player1_joypad_index"), "3") self.assertEquals(libretroSettings.load("input_player2_joypad_index"), "2") self.assertEquals(libretroSettings.load("input_player3_joypad_index"), "1") self.assertEquals(libretroSettings.load("input_player4_joypad_index"), "0")