def __init__(self, parent, index): self.index = index if index: self.key = Option.SECONDARY_JOYSTICK else: self.key = Option.PRIMARY_JOYSTICK fsui.Group.__init__(self, parent) self.layout = fsui.HorizontalLayout() devices = ["", get_keyboard_title()] # for i, name in enumerate(DeviceManager.get_joystick_names()): # devices.append(name) for device_name in DeviceManager.get_joystick_names(): if DeviceManager.is_joystick(device_name): devices.append(device_name) self.device_choice = fsui.ComboBox(self, devices) self.layout.add(self.device_choice, expand=True) # Config.add_listener(self) self.initialize_from_settings() self.set_settings_handlers()
def update_default_device(self, had_default=None): config = {} for port in range(4): key = "joystick_port_{0}".format(port) if self.port == port: config[key] = "" else: config[key] = get_config(self).get(key) key = "joystick_port_{0}_mode".format(port) config[key] = DeviceManager.get_calculated_port_mode( get_config(self), port) device = DeviceManager.get_device_for_port(config, self.port) default_description = gettext("Default ({0})").format( fix_device_name(device.name)) # print("default_description = ", default_description) if had_default is None: had_default = self.device_choice.index() == 0 # print("had default", had_default, self.device_choice.index()) self.device_choice.set_item_text(0, default_description) # print("had_default", had_default) if had_default: # print("set text for", self.port, default_description) # self.device_choice.set_index(1) self.device_choice.set_text(default_description) self.device_choice.set_index(0)
def __init__(self, parent): super().__init__(parent) icon = fsui.Icon("joystick-settings", "pkg:workspace") # gettext("Joystick Settings") title = gettext("Controllers") subtitle = gettext( "Configure joysticks and set preferred joystick " "devices" ) self.add_header(icon, title, subtitle) label = fsui.Label( self, gettext("Double-click a controller to configure it:") ) self.layout.add(label, margin_bottom=10) self.list_view = fsui.ListView(self) self.list_view.set_min_height(140) self.list_view.item_activated.connect(self.on_joystick_activated) image = fsui.Image("workspace:res/16x16/gamepad.png") for device_name in DeviceManager.get_joystick_names(): if DeviceManager.is_joystick(device_name): self.list_view.add_item(device_name, icon=image) self.layout.add(self.list_view, fill=True, expand=True) self.layout.add_spacer(20) self.pref_group = PreferredJoysticksGroup(self) self.layout.add(self.pref_group, fill=True) # For reset to defaults function self.options_on_page.add(Option.PRIMARY_JOYSTICK) self.options_on_page.add(Option.SECONDARY_JOYSTICK)
def save_config(self): device_name = self.device_name.rsplit("#", 1)[0] device_type = self.device_type_ids[self.type_field.get_index()] device_make = self.make_field.get_text().strip() device_model = self.model_field.get_text().strip() guid = DeviceManager.joystick_guid(self.device_name) buttons = DeviceManager.joystick_buttons(self.device_name) axes = DeviceManager.joystick_axes(self.device_name) hats = DeviceManager.joystick_hats(self.device_name) balls = DeviceManager.joystick_balls(self.device_name) config = [ "[fs-uae-controller]", "name = {}".format(device_name), "platform = {}".format(platform), "", "[device]", "make = {}".format(device_make), "model = {}".format(device_model), "type = {}".format(device_type), "", "[sdl]", "guid = {}".format(guid), "buttons = {}".format(buttons), "hats = {}".format(hats), "axes = {}".format(axes), "balls = {}".format(balls), "", "[default]", "include = universal_gamepad", ] button_config = [] for i, button in enumerate(BUTTONS): panel = self.button_panels[i] if panel.event_name: button_config.append( "{0} = {1}".format(panel.event_name, button[3]) ) config.extend(sorted(button_config)) with open( self.get_save_path(self.get_joystick_id() + ".conf"), "w", encoding="UTF-8", ) as f: for line in config: f.write(line) f.write("\n") if len(guid) == 32: with open( self.get_save_path(guid + ".fs-uae-controller"), "w", encoding="UTF-8", ) as f: for line in config: f.write(line) f.write("\n")
def save_config(self): device_name = self.device_name.rsplit("#", 1)[0] device_type = self.device_type_ids[self.type_field.get_index()] # device_make = self.make_field.get_text().strip() device_model = self.model_field.get_text().strip() guid = DeviceManager.joystick_guid(self.device_name) buttons = DeviceManager.joystick_buttons(self.device_name) axes = DeviceManager.joystick_axes(self.device_name) hats = DeviceManager.joystick_hats(self.device_name) balls = DeviceManager.joystick_balls(self.device_name) config = [ "[fs-uae-controller]", "name = {}".format(device_name), "platform = {}".format(platform), "", "[device]", # "make = {}".format(device_make), "model = {}".format(device_model), "type = {}".format(device_type), "", "[sdl]", "guid = {}".format(guid), "buttons = {}".format(buttons), "hats = {}".format(hats), "axes = {}".format(axes), "balls = {}".format(balls), "", "[default]", "include = universal_gamepad", ] button_config = [] for i, button in enumerate(BUTTONS): panel = self.button_panels[i] if panel.event_name: button_config.append( "{0} = {1}".format(panel.event_name, button[3]) ) config.extend(sorted(button_config)) with open( self.get_save_path(self.get_joystick_id() + ".conf"), "w", encoding="UTF-8", ) as f: for line in config: f.write(line) f.write("\n") if len(guid) == 32: with open( self.get_save_path(guid + ".fs-uae-controller"), "w", encoding="UTF-8", ) as f: for line in config: f.write(line) f.write("\n")
def rebuild_device_list(self): self.device_values = ["", "none"] devices = ["", gettext("No Host Device")] for i, name in enumerate(DeviceManager.get_joystick_names()): devices.append(fix_device_name(name)) self.device_values.append(DeviceManager.device_ids[i]) self.set_items(devices)
def update_default_device(self, had_default=None): config = {"platform": self._platform} for port in range(1, 4 + 1): key = "{}_port_{}".format(self._platform, port) if self.port == port: config[key] = "" else: config[key] = get_config(self).get(key) key = "{}_port_{}_type".format(self._platform, port) config[key] = get_config(self).get(key) # config[key] = DeviceManager.get_calculated_port_mode( # get_config(self), port) device = DeviceManager.get_non_amiga_device_for_port(config, self.port) default_description = "{} (*)".format(fix_device_name(device.name)) # print("default_description = ", default_description) if had_default is None: had_default = self.index() == 0 # print("had default", had_default, self.index()) self.set_item_text(0, default_description) # print("had_default", had_default) if had_default: # print("set text for", self.port, default_description) # self.set_index(1) self.set_text(default_description) self.set_index(0)
def get_joystick_id(self): device_name = self.device_name.rsplit("#", 1)[0] buttons = DeviceManager.joystick_buttons(self.device_name) axes = DeviceManager.joystick_axes(self.device_name) hats = DeviceManager.joystick_hats(self.device_name) balls = DeviceManager.joystick_balls(self.device_name) name_lower = device_name.lower() name = "" for c in name_lower: if c in "abcdefghijklmnopqrstuvwxyz0123456789": name = name + c else: if not name.endswith("_"): name += "_" name = name.strip("_") return "{0}_{1}_{2}_{3}_{4}_{5}".format( name, buttons, axes, hats, balls, platform)
def get_joystick_id(self): device_name = self.device_name.rsplit("#", 1)[0] buttons = DeviceManager.joystick_buttons(self.device_name) axes = DeviceManager.joystick_axes(self.device_name) hats = DeviceManager.joystick_hats(self.device_name) balls = DeviceManager.joystick_balls(self.device_name) name_lower = device_name.lower() name = "" for c in name_lower: if c in "abcdefghijklmnopqrstuvwxyz0123456789": name = name + c else: if not name.endswith("_"): name += "_" name = name.strip("_") return "{0}_{1}_{2}_{3}_{4}_{5}".format( name, buttons, axes, hats, balls, platform )
def on_config(self, key, value): if key == "platform": self.layout.update() return if key == "amiga_model": value = get_config(self).get("joystick_port_{0}_mode".format( self.port)) self.set_value_or_default(value) if key == self.mode_option_key or key == "amiga_model": value = DeviceManager.get_calculated_port_mode( get_config(self), self.port) for i, config in enumerate(self.joystick_mode_values): if config == value: if self.mode_choice is not None: self.mode_choice.set_index(i) if self.port >= 4: self.device_choice.set_enabled(i != 0) break else: print("FIXME: could not set mode") elif key == self.device_option_key or key == "amiga_model": # print(self.joystick_values) value_lower = value.lower() for i, name in enumerate(self.joystick_values): if value_lower == name.lower(): self.device_choice.set_index(i) break elif key == self.autofire_mode_option_key: if self.autofire_button is not None: if value == "1": self.autofire_button.set_tooltip( gettext("Auto-Fire is On")) self.autofire_button.set_icon_name( "16x16/lightning_red.png") else: self.autofire_button.set_tooltip( gettext("Auto-Fire is Off")) self.autofire_button.set_icon_name( "16x16/lightning_off.png") # this is intended to catch all config changes for all ports (both # mode and device) to update the defaults if key.startswith("joystick_port_") or key == "amiga_model": self.update_default_device()
def default_port_selection(self, ports, options): print("[INPUT] Default port selection (EnumerateHelper)") self.init() # for device in self.devices: # print(" #", device.id) # device.configure("megadrive") if len(ports) > 0: if ports[0].type_option: print("[INPUT] New-style port device selection:") # Supports new-style port selection port_devices = DeviceManager.get_non_amiga_devices_for_ports( options ) from fsgs.platform import Platform if ports[0].type_option == Option.C64_PORT_2_TYPE: print("[INPUT] Hack for inverted C64 port order") temp = port_devices[1] port_devices[1] = port_devices[2] port_devices[2] = temp for i, port in enumerate(ports): for device in self.devices: if port_devices[i + 1].id == device.id: port.device = device print("[INPUT]", port.name, "<-", device.id) break else: print("[INPUT]", port.name, "<- [None]") return joystick_like_devices = self.joystick_like_devices[:] print("[INPUT] Old-style port device selection:") for port in ports: for i, device in enumerate(joystick_like_devices): # device.configure() if True: joystick_like_devices.pop(i) port.device = device break print("[INPUT] Old Selection:", port.name, port.device)
def on_config(self, key, value): config = get_config(self) if key in JOYSTICK_KEYS: prev_value = self.using_joy_emu devices = DeviceManager.get_devices_for_ports(config) for device in devices: if device.id == "keyboard": self.using_joy_emu = True break else: self.using_joy_emu = False if prev_value != self.using_joy_emu: self.rebuild_warnings_and_refresh() elif key.startswith("__"): pass # elif LauncherConfig.is_implicit_option(key): # pass elif LauncherConfig.is_custom_uae_option(key): changed = False if value: if key not in self.custom_uae_config: self.custom_uae_config.add(key) changed = True else: if key in self.custom_uae_config: self.custom_uae_config.remove(key) changed = True if changed: self.rebuild_warnings_and_refresh() elif LauncherConfig.is_custom_option(key): changed = False if value: if key not in self.custom_config: self.custom_config.add(key) changed = True else: if key in self.custom_config: self.custom_config.remove(key) changed = True if changed: self.rebuild_warnings_and_refresh()
def default_port_selection(self, ports, options): print("[INPUT] Default port selection (EnumerateHelper)") self.init() # for device in self.devices: # print(" #", device.id) # device.configure("megadrive") if len(ports) > 0: if ports[0].type_option: print("[INPUT] New-style port device selection:") # Supports new-style port selection port_devices = DeviceManager.get_non_amiga_devices_for_ports( options) from fsgs.platform import Platform if ports[0].type_option == Option.C64_PORT_2_TYPE: print("[INPUT] Hack for inverted C64 port order") temp = port_devices[1] port_devices[1] = port_devices[2] port_devices[2] = temp for i, port in enumerate(ports): for device in self.devices: if port_devices[i + 1].id == device.id: port.device = device print("[INPUT]", port.name, "<-", device.id) break else: print("[INPUT]", port.name, "<- [None]") return joystick_like_devices = self.joystick_like_devices[:] print("[INPUT] Old-style port device selection:") for port in ports: for i, device in enumerate(joystick_like_devices): # device.configure() if True: joystick_like_devices.pop(i) port.device = device break print("[INPUT] Old Selection:", port.name, port.device)
def on_config(self, key, value): if key in JOYSTICK_KEYS: prev_value = self.using_joy_emu devices = DeviceManager.get_devices_for_ports(LauncherConfig) for device in devices: if device.id == "keyboard": self.using_joy_emu = True break else: self.using_joy_emu = False if prev_value != self.using_joy_emu: self.rebuild_warnings_and_refresh() elif key.startswith("__"): pass # elif LauncherConfig.is_implicit_option(key): # pass elif LauncherConfig.is_custom_uae_option(key): changed = False if value: if key not in self.custom_uae_config: self.custom_uae_config.add(key) changed = True else: if key in self.custom_uae_config: self.custom_uae_config.remove(key) changed = True if changed: self.rebuild_warnings_and_refresh() elif LauncherConfig.is_custom_option(key): changed = False if value: if key not in self.custom_config: self.custom_config.add(key) changed = True else: if key in self.custom_config: self.custom_config.remove(key) changed = True if changed: self.rebuild_warnings_and_refresh()
def get_joystick_guid(self): return DeviceManager.joystick_guid(self.device_name)
def prepare(self): print("FSUAEAmigaDriver.prepare") if not self.options["joystick_port_0_mode"]: self.options["joystick_port_0_mode"] = "mouse" if not self.options["joystick_port_1_mode"]: if self.options["amiga_model"].startswith("CD32"): self.options["joystick_port_1_mode"] = "cd32 gamepad" else: self.options["joystick_port_1_mode"] = "joystick" if not self.options["joystick_port_2_mode"]: self.options["joystick_port_2_mode"] = "none" if not self.options["joystick_port_3_mode"]: self.options["joystick_port_3_mode"] = "none" from launcher.devicemanager import DeviceManager devices = DeviceManager.get_devices_for_ports(self.options) for port in range(4): key = "joystick_port_{0}".format(port) if not self.options[key]: # key not set, use calculated default value self.options[key] = devices[port].id for remove_key in [ "database_username", "database_password", "database_username", "database_email", "database_auth", "device_id", ]: if remove_key in self.options: del self.options[remove_key] # overwrite netplay config if self.options["__netplay_host"]: self.options["netplay_server"] = self.options["__netplay_host"] if self.options["__netplay_password"]: self.options["netplay_password"] = self.options[ "__netplay_password"] if self.options["__netplay_port"]: self.options["netplay_port"] = self.options["__netplay_port"] # copy actual kickstart options from x_ options self.options["kickstart_file"] = self.options["x_kickstart_file"] self.options["kickstart_ext_file"] = self.options[ "x_kickstart_ext_file"] if not self.options["kickstart_file"]: # Warning will have been shown on the status bar self.options["kickstart_file"] = "internal" # Copy default configuration values from model defaults. The main # purpose of this is to let the launch code know about implied defaults # so it can for example configure correct ROM files for expansions. model_config = Amiga.get_current_config(self.options) for key, value in model_config["defaults"].items(): if not self.options[key]: self.options[key] = value # make sure FS-UAE does not load other config files (Host.fs-uae) self.options["end_config"] = "1" # Make FS-UAE check that version matches (except for development) if VERSION != "9.8.7dummy": self.options[Option.EXPECT_VERSION] = VERSION if self.options["__netplay_game"]: print("\nfixing config for netplay game") for key in [x for x in config.keys() if x.startswith("uae_")]: print("* removing option", key) del self.options[key] # self.temp_dir = self.fsgc.temp_dir("amiga") # self.change_handler = GameChangeHandler(self.temp_dir) # self.firmware_dir = self.prepare_firmware("Amiga Firmware") # config = self.fsgc.config.copy() model = self.options[Option.AMIGA_MODEL] if model.startswith("CD32"): platform = "CD32" elif model == "CDTV": platform = "CDTV" else: platform = "Amiga" # name = Settings.get("config_name") # name = self.fsgc.game.name # uuid = Config.get("x_game_uuid") # uuid = None from fsgs.saves import SaveHandler # save_state_handler = SaveHandler(self.fsgc, self.get_name(), platform) save_state_handler = SaveHandler( self.fsgc, app.settings.get("config_name"), platform, options=self.options, ) print( "[INPUT] joystick_port_1", self.options["joystick_port_1"], "->", self.ports[0].device_id or "none", ) print( "[INPUT] joystick_port_0", self.options["joystick_port_0"], "->", self.ports[1].device_id or "none", ) # self.options["joystick_port_1"] = self.ports[0].device_id or "none" # self.options["joystick_port_0"] = self.ports[1].device_id or "none" self.launch_handler = LaunchHandler( self.fsgc, self.get_name(), self.options, save_state_handler, temp_dir=self.cwd.path, ) # self.change_handler.init(self.fsgc.get_game_state_dir(), # ignore=["*.uss", "*.sdf"]) # self.launch_handler.config["joystick_port_0"] = \ # self.inputs[1].device_id # self.launch_handler.config["joystick_port_1"] = \ # self.inputs[0].device_id if self.use_fullscreen(): self.launch_handler.config["fullscreen"] = "1" if not self.launch_handler.config.get("fullscreen_mode", ""): # Check if fullscreen mode is overridden by temporary setting. if Settings.instance()["__fullscreen_mode"]: self.launch_handler.config[ "fullscreen_mode"] = Settings.instance( )["__fullscreen_mode"] if Settings.instance()["__arcade"]: # Remove window border when launched from FS-UAE Arcade in # order to reduce flickering self.launch_handler.config["window_border"] = "0" # Set fade out duration to 500, if not already specified. if not self.launch_handler.config.get("fade_out_duration", ""): self.launch_handler.config["fade_out_duration"] = "500" else: self.launch_handler.config["fullscreen"] = "0" self.launch_handler.prepare() config = self.launch_handler.create_config() config_file = self.temp_file("config.fs-uae").path with open(config_file, "w", encoding="UTF-8") as f: for line in config: print(line) f.write(line + "\n") self.emulator.args.extend([config_file])
def _create_sdl_gamecontroller_mapping(self): # The mapping to SDL game controller config here is not perfect. # The entire tool should be rewritten to register better what # range of axes is used, etc. fs_to_sdl_mapping = { "south_button": "a", "east_button": "b", "select_button": "back", "dpad_down": "dpdown", "dpad_left": "dpleft", "dpad_right": "dpright", "dpad_up": "dpup", "menu_button": "guide", "left_shoulder": "leftshoulder", "lstick_button": "leftstick", "left_trigger": "lefttrigger", "lstick_left": "leftx", "lstick_right": "leftx", "lstick_up": "lefty", "lstick_down": "lefty", "right_shoulder": "rightshoulder", "rstick_button": "rightstick", "right_trigger": "righttrigger", "rstick_left": "rightx", "rstick_right": "rightx", "rstick_up": "righty", "rstick_down": "righty", "start_button": "start", "west_button": "x", "north_button": "y", } device_name = self.device_name.rsplit("#", 1)[0] # device_make = self.make_field.get_text().strip() device_model = self.model_field.get_text().strip() guid = DeviceManager.joystick_guid(self.device_name) axes = DeviceManager.joystick_axes(self.device_name) balls = DeviceManager.joystick_balls(self.device_name) buttons = DeviceManager.joystick_buttons(self.device_name) hats = DeviceManager.joystick_hats(self.device_name) mapping = {} for i, button in enumerate(BUTTONS): panel = self.button_panels[i] fs_key = button[3] sdl_key = fs_to_sdl_mapping[fs_key] value = panel.event_name if not value: continue # if value.startswith("button_"): if value.startswith("axis_"): value = value.replace("axis_", "a") if value.endswith("_pos"): value = "+" + value[:-4] elif value.endswith("_neg"): value = "-" + value[:-4] # existing = mapping.get(sdl_key, "") # if existing: # if value.replace("+", "-") == existing: # # OK, same axis in correct order # value = value.replace("+", "") # else: # raise Exception("Unexpected axis ordering") elif value.startswith("hat_"): value = value.replace("hat_", "h") value = value.replace("_up", ".1") value = value.replace("_right", ".2") value = value.replace("_down", ".4") value = value.replace("_left", ".8") else: value = value.replace("button_", "b") existing = mapping.get(sdl_key, "") if existing: assert sdl_key in ["leftx", "lefty", "rightx", "righty"] if ( value.startswith("+a") and value.replace("+", "-") == existing ): # OK, same axis in correct order value = value.replace("+", "") else: # raise Exception("Unexpected axis ordering") # Split into half-axes del mapping[sdl_key] mapping["-" + sdl_key] = existing sdl_key = "+" + sdl_key mapping[sdl_key] = value lt = mapping.get("lefttrigger", "") rt = mapping.get("righttrigger", "") if lt.startswith("+") and rt.startswith("+"): # If both triggers have "positive axes", assume the entire axis # range is in use (from - to +). mapping["lefttrigger"] = lt[1:] mapping["righttrigger"] = rt[1:] sorted_mapping = [ "{}:{}".format(x[0], x[1]) for x in sorted(mapping.items()) ] name = self.get_joystick_sdl_name() # Escape escape character (%) name = name.replace("%", "%25") # Escape commas name = name.replace(",", "%2C") # if device_make or device_model: # name = "{} {}".format(device_make, device_model).strip() if platform == "linux": platform_str = "Linux" elif platform == "macos": platform_str = "Mac OS X" elif platform == "windows": platform_str = "Windows" else: platform_str = "Unknown" mapping_str = "{guid},{name}{comma}{mapping},platform:{platform},".format( guid=guid, name=name, comma=("," if mapping else ""), mapping=",".join(sorted_mapping), platform=platform_str, ) mapping_str_2 = "axes:{axes},balls:{balls},buttons:{buttons},hats:{hats},".format( axes=axes, balls=balls, buttons=buttons, hats=hats, platform=platform_str, ) # mapping_str = "{guid},{name}{comma}{mapping},axes:{axes},balls:{balls},buttons:{buttons},hats:{hats},platform:{platform},".format( # guid=guid, # name=name, # comma=("," if mapping else ""), # mapping=",".join(sorted_mapping), # axes=axes, # balls=balls, # buttons=buttons, # hats=hats, # platform=platform_str, # ) return mapping_str, mapping_str_2
def prepare(self): print("FSUAEAmigaDriver.prepare") if not self.options["joystick_port_0_mode"]: self.options["joystick_port_0_mode"] = "mouse" if not self.options["joystick_port_1_mode"]: if self.options["amiga_model"].startswith("CD32"): self.options["joystick_port_1_mode"] = "cd32 gamepad" else: self.options["joystick_port_1_mode"] = "joystick" if not self.options["joystick_port_2_mode"]: self.options["joystick_port_2_mode"] = "none" if not self.options["joystick_port_3_mode"]: self.options["joystick_port_3_mode"] = "none" from launcher.devicemanager import DeviceManager devices = DeviceManager.get_devices_for_ports(self.options) for port in range(4): key = "joystick_port_{0}".format(port) if not self.options[key]: # key not set, use calculated default value self.options[key] = devices[port].id for remove_key in [ "database_username", "database_password", "database_username", "database_email", "database_auth", "device_id", ]: if remove_key in self.options: del self.options[remove_key] # overwrite netplay config if self.options["__netplay_host"]: self.options["netplay_server"] = self.options["__netplay_host"] if self.options["__netplay_password"]: self.options["netplay_password"] = self.options[ "__netplay_password"] if self.options["__netplay_port"]: self.options["netplay_port"] = self.options["__netplay_port"] # copy actual kickstart options from x_ options self.options["kickstart_file"] = self.options["x_kickstart_file"] self.options["kickstart_ext_file"] = self.options[ "x_kickstart_ext_file"] # FIXME: Temporarily disabled # if not self.options["kickstart_file"]: # # Warning will have been shown on the status bar # self.options["kickstart_file"] = "internal" # Copy default configuration values from model defaults. The main # purpose of this is to let the launch code know about implied defaults # so it can for example configure correct ROM files for expansions. model_config = Amiga.get_current_config(self.options) for key, value in model_config["defaults"].items(): if not self.options[key]: self.options[key] = value # make sure FS-UAE does not load other config files (Host.fs-uae) self.options["end_config"] = "1" # Make FS-UAE check that version matches (except for development) if VERSION != "9.8.7dummy": self.options[Option.EXPECT_VERSION] = VERSION if self.options["__netplay_game"]: print("\nfixing config for netplay game") for key in [x for x in config.keys() if x.startswith("uae_")]: print("* removing option", key) del self.options[key] # self.temp_dir = self.fsgc.temp_dir("amiga") # self.change_handler = GameChangeHandler(self.temp_dir) # self.firmware_dir = self.prepare_firmware("Amiga Firmware") # config = self.fsgc.config.copy() model = self.options[Option.AMIGA_MODEL] if model.startswith("CD32"): platform = "CD32" elif model == "CDTV": platform = "CDTV" else: platform = "Amiga" # name = Settings.get("config_name") # name = self.fsgc.game.name # uuid = Config.get("x_game_uuid") # uuid = None from fsgamesys.saves import SaveHandler # save_state_handler = SaveHandler(self.fsgc, self.get_name(), platform) save_state_handler = SaveHandler( self.fsgc, self.options["config_name"], platform, options=self.options, ) print( "[INPUT] joystick_port_1", self.options["joystick_port_1"], "->", self.ports[0].device_id or "none", ) print( "[INPUT] joystick_port_0", self.options["joystick_port_0"], "->", self.ports[1].device_id or "none", ) # self.options["joystick_port_1"] = self.ports[0].device_id or "none" # self.options["joystick_port_0"] = self.ports[1].device_id or "none" self.launch_handler = LaunchHandler( self.fsgc, self.get_name(), self.options, save_state_handler, temp_dir=self.filesdir.path, ) # self.change_handler.init(self.fsgc.get_game_state_dir(), # ignore=["*.uss", "*.sdf"]) # self.launch_handler.config["joystick_port_0"] = \ # self.inputs[1].device_id # self.launch_handler.config["joystick_port_1"] = \ # self.inputs[0].device_id if self.use_fullscreen(): self.launch_handler.config["fullscreen"] = "1" if not self.launch_handler.config.get("fullscreen_mode", ""): # Check if fullscreen mode is overridden by temporary setting. if self.options.get("__fullscreen_mode"): self.launch_handler.config[ "fullscreen_mode"] = self.options.get( "__fullscreen_mode") if self.options.get("__arcade"): # Remove window border when launched from FS-UAE Arcade in # order to reduce flickering self.launch_handler.config["window_border"] = "0" # Set fade out duration to 500, if not already specified. if not self.launch_handler.config.get("fade_out_duration", ""): self.launch_handler.config["fade_out_duration"] = "500" else: self.launch_handler.config["fullscreen"] = "0" self.launch_handler.prepare() run_dir = self.filesdir.path from fsgamesys.amiga.amigaconfig import AmigaConfig # config = AmigaConfig(self.options) self.options = self.launch_handler.config.copy() self.options["run_dir"] = run_dir files = prepare_amiga(self.options) # FIXME: Move function def file_sha1_to_stream(sha1): stream = self.fsgs.file.open("sha1://{0}".format(sha1)) if stream is not None: return stream # FIXME: Move import from fsgamesys.plugins.pluginmanager import PluginManager path = PluginManager.instance().find_file_by_sha1(sha1) if path: return open(path, "rb") # dst = path # dst_partial = dst + ".partial" # sha1_obj = hashlib.sha1() # with open(src, "rb") as fin: # with open(dst_partial, "wb") as fout: # while True: # data = fin.read(65536) # if not data: # break # fout.write(data) # sha1_obj.update(data) # if sha1_obj.hexdigest() != sha1: # raise Exception("File from plugin does not match SHA-1") # os.rename(dst_partial, dst) # return # pass return None install_files(files, run_dir, file_sha1_to_stream) config = ConfigWriter(self.config).create_fsuae_config() config_file = self.temp_file("Config.fs-uae").path with open(config_file, "w", encoding="UTF-8") as f: for line in config: print(line) f.write(line + "\n") self.emulator.args.extend([config_file])
def get_joystick_sdl_name(self): return DeviceManager.joystick_sdl_name(self.device_name)