def setUp(self):
        # Cloning config files
        shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../resources/es_input.cfg.origin")), \
                        os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg")))
        shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/fba2x.cfg.origin')), \
                        fba2xCustom)
        # Injecting test file

        self.fbaSettings = unixSettings.UnixSettings(fba2xCustom)
        fba2xControllers.fbaSettings = self.fbaSettings
Beispiel #2
0
def writeControllersConfig(system, rom, controllers):
    config = dict()
    for controller in controllers:
        playerConfig = generateControllerConfig(controller,
                                                controllers[controller])
        confFile = recalboxFiles.moonlightMapping[int(controller)]
        mappingFile = unixSettings.UnixSettings(confFile, ' ')
        mappingFile.save("# Device name", controllers[controller].realName)
        mappingFile.save("# SDL2 GUID  ", controllers[controller].guid)
        mappingFile.save("# Event path ", controllers[controller].dev)
        for input in playerConfig:
            mappingFile.save(input, playerConfig[input])
            config[confFile] = controllers[controller].dev
    return config
def writeControllersConfig(system, rom, controllers):
    config = dict()
    for controller in controllers:
        playerConfig = generateControllerConfig(controller, controllers[controller])
        confFile = batoceraFiles.moonlightMapping[int(controller)]
        if os.path.isfile(confFile):
            os.remove(confFile)
        os.mknod(confFile)
        mappingFile = unixSettings.UnixSettings(confFile, ' ')
        mappingFile.save("# Device name", controllers[controller].realName)
        mappingFile.save("# SDL2 GUID  ", controllers[controller].guid)
        mappingFile.save("# Event path ", controllers[controller].dev)
        for input in playerConfig:
            mappingFile.save(input, playerConfig[input])
            config[confFile] = controllers[controller].dev
        mappingFile.write()
    return config
#!/usr/bin/env python
import sys
import os

sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))

import settings.unixSettings as unixSettings
import rhgamestationFiles

fbaSettings = unixSettings.UnixSettings(rhgamestationFiles.fbaCustom)

# Map an emulationstation button name to the corresponding fba2x name
fba4bnts = {'a': 'Y', 'b': 'X', 'x': 'B', 'y': 'A', \
            'pageup': 'L', 'pagedown': 'R', \
            'start': 'START', 'select': 'SELECT'}
fba6bnts = {'a': 'L', 'b': 'Y', 'x': 'X', 'y': 'A', \
            'pageup': 'B', 'pagedown': 'R', \
            'start': 'START', 'select': 'SELECT'}

# Map an emulationstation direction to the corresponding fba2x
fbadirs = {'up': 'UP', 'down': 'DOWN', 'left': 'LEFT', 'right': 'RIGHT'}
fbaaxis = {'joystick1up': 'JA_UD', 'joystick1left': 'JA_LR'}
fbaHatToAxis = {'1': 'UP', '2': 'LR', '4': 'UD', '8': 'LR'}

# Map buttons to the corresponding fba2x specials keys
fbaspecials = {'start': 'QUIT', 'hotkey': 'HOTKEY'}


def writeControllersConfig(system, rom, controllers):
    writeIndexes(controllers)
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../resources/retroarchcustom.cfg.origin")), \
                os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/retroarchcustom.cfg")))
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../resources/es_input.cfg.origin")), \
                os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg")))

# Injecting test recalbox.conf
libretroControllers.settingsRoot = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "tmp"))
# Injecting test es_input
controllersConfig.esInputs = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg"))

# Injecting test retroarch.conf
libretroSettingsFile = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "tmp/retroarchcustom.cfg"))
libretroSettings = unixSettings.UnixSettings(libretroSettingsFile)
libretroControllers.libretroSettings = libretroSettings

# Test objects
basicInputs1 = {'a': controllersConfig.Input("a", "button", "10", "1")}
basicController1 = controllersConfig.Controller("contr1", "joypad", "GUID1",
                                                "0", "Joypad1RealName",
                                                basicInputs1)
basicController2 = controllersConfig.Controller("contr2", "joypad", "GUID2",
                                                "1", "Joypad2RealName",
                                                basicInputs1)
basicController3 = controllersConfig.Controller("contr3", "joypad", "GUID3",
                                                "2", "Joypad3RealName",
                                                basicInputs1)
basicController4 = controllersConfig.Controller("contr4", "joypad", "GUID4",
                                                "3", "Joypad4RealName",
import generators.libretro.libretroGenerator as libretroGen
import settings.unixSettings as unixSettings
import settings.recalboxSettings as recalSettings

retroarchcustomFile = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'tmp/retroarchcustom.cfg'))
recalboxConfFile = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'tmp/recalbox.conf'))

# Cloning config files
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/retroarchcustom.cfg.origin')), \
                retroarchcustomFile)
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/recalbox.conf.origin')), \
                recalboxConfFile)

libretroSettings = unixSettings.UnixSettings(retroarchcustomFile, ' ')

# test Systems
snes = Emulator(name='snes',
                videomode='4',
                core='pocketsnes',
                shaders='',
                ratio='auto',
                smooth='2',
                rewind='false',
                emulator='libretro')
nes = Emulator(name='nes',
               videomode='4',
               core='pocketsnes',
               shaders='',
               ratio='16/9',
RETROARCH_CUSTOM_CFG_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tmp/retroarchcustom.cfg'))
RECALBOX_CFG_FILE = os.path.abspath(os.path.join(os.path.dirname(__file__), 'tmp/recalbox.conf'))

# Cloning config files
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/retroarchcustom.cfg.origin')), \
                RETROARCH_CUSTOM_CFG_FILE)
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/retroarchcustom.cfg.origin')), \
                RETROARCH_ORIGIN_CFG_FILE)
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/recalbox.conf.origin')), \
                RECALBOX_CFG_FILE)

# Injecting test files
libretroGenerator.recalboxFiles.retroarchCustom = RETROARCH_CUSTOM_CFG_FILE
libretroGenerator.recalboxFiles.retroarchCustomOrigin = RETROARCH_ORIGIN_CFG_FILE

libretroConfig.libretroSettings = unixSettings.UnixSettings(RETROARCH_CUSTOM_CFG_FILE, separator=' ')

PS3UUID = "060000004c0500006802000000010000"

rom = "MyRom.nes"

libretroGen = LibretroGenerator()


class TestLibretroGenerator(unittest.TestCase):
    def setUp(self):
        self.snes = Emulator(name='snes', videomode='4', core='pocketsnes', shaders='', ratio='auto', smooth='2',
                             rewind='false', emulator='libretro')
        self.snes2 = Emulator(name='snes', videomode='4', core='pocketsnes', shaders='', ratio='auto', smooth='2',
                              rewind='false', emulator='libretro')
        self.nes = Emulator(name='nes', videomode='6', core='catsfc', shaders='', ratio='16/9', smooth='1',
FBA2X_ORIGIN_CFG_FILE = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'tmp/fba2x.cfg.origin'))
FBA2X_CUSTOM_CFG_FILE = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'tmp/fba2x.cfg'))
RECALBOX_CFG_FILE = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'tmp/recalbox.conf'))

# Cloning config files
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/fba2x.cfg.origin')), \
                FBA2X_ORIGIN_CFG_FILE)

# Injecting test files
fba2xGenerator.recalboxFiles.fbaCustom = FBA2X_CUSTOM_CFG_FILE
fba2xGenerator.recalboxFiles.fbaCustomOrigin = FBA2X_ORIGIN_CFG_FILE

fba2xConfig.fbaSettings = unixSettings.UnixSettings(FBA2X_CUSTOM_CFG_FILE)

# test Systems
fbaSystem = Emulator(name='fba',
                     videomode='4',
                     shaders='',
                     ratio='auto',
                     smooth='2',
                     emulator='pifba')

fbaSystemCustom = Emulator(name='fba',
                           videomode='6',
                           shaders='',
                           ratio='auto',
                           smooth='2',
                           emulator='pifba',
Beispiel #9
0
import shutil

sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")))
import settings.unixSettings as unixSet
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), "../resources/unixSettings.cfg")), \
                os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/unixSettings.cfg")))
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), "../resources/retroarchcustom.cfg.origin")), \
                os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/retroarchcustom.cfg")))
# Injecting test unixSettings
noSeparatorFile = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "tmp/unixSettings.cfg"))
spaceSeparatorFile = os.path.abspath(
    os.path.join(os.path.dirname(__file__), "tmp/retroarchcustom.cfg"))

unixSettings = unixSet.UnixSettings(noSeparatorFile)
recalboxSettings = unixSet.UnixSettings(spaceSeparatorFile, ' ')


class TestUnixSettings(unittest.TestCase):
    def test_load_empty_value_should_return_none(self):
        name = "I dont exists"
        loaded = unixSettings.load(name)
        self.assertEquals(None, loaded)

    def test_load_disabled_value_return_none(self):
        name = "aspect_ratio_index"
        loaded = unixSettings.load(name)
        self.assertEquals(None, loaded)

    def test_load_enabled_value_without_quotes(self):
Beispiel #10
0
#!/usr/bin/env python
import sys
import os

sys.path.append(
    os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))

import settings.unixSettings as unixSettings
import recalboxFiles

fbaSettings = unixSettings.UnixSettings(recalboxFiles.fbaCustom)

# Map an emulationstation button name to the corresponding fba2x name
fba4bnts = {'a': 'Y', 'b': 'X', 'x': 'B', 'y': 'A', \
            'pageup': 'L', 'pagedown': 'R', \
            'start': 'START', 'select': 'SELECT'}
fba6bnts = {'a': 'L', 'b': 'Y', 'x': 'X', 'y': 'A', \
            'pageup': 'B', 'pagedown': 'R', \
            'start': 'START', 'select': 'SELECT'}

# Map an emulationstation direction to the corresponding fba2x
fbadirs = {'up': 'UP', 'down': 'DOWN', 'left': 'LEFT', 'right': 'RIGHT'}
fbaaxis = {'up': 'UD', 'down': 'UD', 'left': 'LR', 'right': 'LR'}
fbaHatToAxis = {'1': 'UD', '2': 'LR', '4': 'UD', '8': 'LR'}

# Map an emulationstation joystick to the corresponding fba2x
retroarchjoysticks = {'joystickup': 'l_y', 'joystickleft': 'l_x'}

# Map an emulationstation input type to the corresponding retroarch type
typetoname = {'button': 'btn', 'hat': 'btn', 'axis': 'axis', 'key': 'key'}
Beispiel #11
0
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/fba2x.cfg.origin')), \
                fba2xCustom)

# Injecting test recalbox.conf
controllersConfig.esInputs = os.path.abspath(os.path.join(os.path.dirname(__file__), "tmp/es_input.cfg"))

# Test objects
basicInputs1 = {'a': controllersConfig.Input("a", "button", "10", "1"),'hotkey': controllersConfig.Input("hotkey", "button", "10", "1")}
basicController1 = controllersConfig.Controller("contr1", "joypad", "GUID1", "0", "Joypad1RealName", basicInputs1)
PS3UUID = "060000004c0500006802000000010000"
GPIOUUID = "15000000010000000100000000010000"



fbaSettings = unixSettings.UnixSettings(fba2xCustom)

class TestFba2xController(unittest.TestCase):
    def setUp(self):
        # Injecting test file
        fba2xControllers.fbaSettings = fbaSettings
    def test_generate_simple_controller(self):
        config = fba2xControllers.generateControllerConfig(basicController1)
        self.assertEquals(config['Y'], '"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_device'], '"p1controller"')
        self.assertEquals(config['input_device'], '"p1controller"')
import generators.mupen.mupenControllers as mupenControllers

MUPEN_CUSTOM_CFG_FILE = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'tmp/mupen64plus.cfg'))
RECALBOX_CFG_FILE = os.path.abspath(
    os.path.join(os.path.dirname(__file__), 'tmp/recalbox.conf'))

# Cloning config files
shutil.copyfile(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../resources/mupen64plus.cfg')), \
                MUPEN_CUSTOM_CFG_FILE)

# Injecting test files
mupenControllers.recalboxFiles.mupenCustom = MUPEN_CUSTOM_CFG_FILE

mupenControllers.mupenSettings = unixSettings.UnixSettings(
    MUPEN_CUSTOM_CFG_FILE, separator=' ')

# test Systems
n64 = Emulator(name='n64',
               videomode='4',
               core='n64',
               shaders='',
               ratio='auto',
               smooth='2',
               rewind='false',
               emulator='mupen64plus')

# test inputs
basicInputs1 = {
    'hotkey': controllersConfig.Input("hotkey", "button", "10", "1")
}