diff options
Diffstat (limited to 'py_modules')
| -rw-r--r-- | py_modules/lsfg_vk/config_schema.py | 33 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/config_schema_generated.py | 14 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/configuration.py | 25 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/flatpak_service.py | 12 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/installation.py | 34 |
5 files changed, 22 insertions, 96 deletions
diff --git a/py_modules/lsfg_vk/config_schema.py b/py_modules/lsfg_vk/config_schema.py index f8a9fe6..184d27a 100644 --- a/py_modules/lsfg_vk/config_schema.py +++ b/py_modules/lsfg_vk/config_schema.py @@ -1,7 +1,6 @@ """lsfg-vk v2 configuration and Decky profile management.""" import json -import logging import re import sys import tomllib @@ -31,12 +30,12 @@ CONFIG_SCHEMA: Dict[str, ConfigField] = { ) for name, definition in CONFIG_SCHEMA_DEF.items() } -GLOBAL_SECTION_FIELDS = {"dll", "allow_fp16"} +GLOBAL_SECTION_FIELDS = {"allow_fp16"} SCRIPT_ONLY_FIELDS = { name for name, definition in CONFIG_SCHEMA_DEF.items() if definition["location"] == "script" } -PROFILE_TOML_FIELDS = {"active_in", "gpu", "multiplier", "flow_scale", "performance_mode", "pacing"} +PROFILE_TOML_FIELDS = {"multiplier", "flow_scale", "performance_mode", "pacing"} DEFAULT_PROFILE_NAME = "decky-lsfg-vk" CURRENT_PROFILE_COMMENT = re.compile(r'^\s*#\s*decky-current-profile\s*=\s*"([^"]+)"\s*$') @@ -59,18 +58,6 @@ class ConfigurationManager: return cast(ConfigurationData, dict(get_defaults())) @staticmethod - def get_defaults_with_dll_detection(dll_detection_service=None) -> ConfigurationData: - defaults = ConfigurationManager.get_defaults() - if dll_detection_service: - try: - result = dll_detection_service.check_lossless_scaling_dll() - if result.get("detected") and result.get("path"): - defaults["dll"] = result["path"] - except (OSError, IOError, KeyError, TypeError) as error: - logging.getLogger(__name__).debug("DLL detection failed: %s", error) - return defaults - - @staticmethod def get_field_names() -> list[str]: return list(CONFIG_SCHEMA) @@ -108,8 +95,6 @@ class ConfigurationManager: if field not in profile: continue value = profile[field] - if field == "active_in" and isinstance(value, list): - value = ", ".join(str(item) for item in value) config[field] = value for field in GLOBAL_SECTION_FIELDS: if field in global_config: @@ -134,20 +119,11 @@ class ConfigurationManager: "", "[global]", ] - if global_config.get("dll"): - lines.append(f"dll = {_toml_string(str(global_config['dll']))}") lines.append(f"allow_fp16 = {str(bool(global_config.get('allow_fp16', True))).lower()}") for profile_name, raw_config in profile_data["profiles"].items(): config = ConfigurationManager.validate_config({**raw_config, **global_config}) lines.extend(["", "[[profile]]", f"name = {_toml_string(profile_name)}"]) - active_in = [entry.strip() for entry in config["active_in"].split(",") if entry.strip()] - if len(active_in) == 1: - lines.append(f"active_in = {_toml_string(active_in[0])}") - elif active_in: - lines.append("active_in = [" + ", ".join(_toml_string(entry) for entry in active_in) + "]") - if config["gpu"]: - lines.append(f"gpu = {_toml_string(config['gpu'])}") lines.extend([ f"multiplier = {config['multiplier']}", f"flow_scale = {config['flow_scale']}", @@ -160,7 +136,6 @@ class ConfigurationManager: def _profile_data_from_v1(data: Dict[str, Any]) -> ProfileData: old_global = data.get("global", {}) global_config = { - "dll": str(old_global.get("dll", "")), "allow_fp16": not bool(old_global.get("no_fp16", False)), } profiles: Dict[str, ConfigurationData] = {} @@ -199,7 +174,6 @@ class ConfigurationManager: raw_global = dict(data.get("global", {})) global_config = { - "dll": str(raw_global.get("dll", "")), "allow_fp16": bool(raw_global.get("allow_fp16", True)), } profiles: Dict[str, ConfigurationData] = {} @@ -260,9 +234,6 @@ class ConfigurationManager: raise ValueError(f"Profile '{normalized}' already exists") source = source_profile if source_profile in profile_data["profiles"] else profile_data["current_profile"] new_profile = dict(profile_data["profiles"][source]) - # A cloned profile may inherit Active In values that collide with its source. - # Force the newly selected profile until the user explicitly enables native matching. - new_profile["use_native_matching"] = False return ProfileData( current_profile=profile_data["current_profile"], profiles={**profile_data["profiles"], normalized: new_profile}, diff --git a/py_modules/lsfg_vk/config_schema_generated.py b/py_modules/lsfg_vk/config_schema_generated.py index 9cfda51..db337fe 100644 --- a/py_modules/lsfg_vk/config_schema_generated.py +++ b/py_modules/lsfg_vk/config_schema_generated.py @@ -13,15 +13,11 @@ sys.path.insert(0, str(Path(__file__).parent.parent.parent)) from shared_config import CONFIG_SCHEMA_DEF, ConfigFieldType # Field name constants for type-safe access -DLL = "dll" ALLOW_FP16 = "allow_fp16" MULTIPLIER = "multiplier" FLOW_SCALE = "flow_scale" PERFORMANCE_MODE = "performance_mode" PACING = "pacing" -ACTIVE_IN = "active_in" -USE_NATIVE_MATCHING = "use_native_matching" -GPU = "gpu" DISABLE_LSFGVK = "disable_lsfgvk" DXVK_FRAME_RATE = "dxvk_frame_rate" ENABLE_WOW64 = "enable_wow64" @@ -35,15 +31,11 @@ ENABLE_ZINK = "enable_zink" class ConfigurationData(TypedDict): """Type-safe configuration data structure - AUTO-GENERATED""" - dll: str allow_fp16: bool multiplier: int flow_scale: float performance_mode: bool pacing: str - active_in: str - use_native_matching: bool - gpu: str disable_lsfgvk: bool dxvk_frame_rate: int enable_wow64: bool @@ -70,8 +62,6 @@ def get_script_parsing_logic(): value = value.strip() # Auto-generated parsing logic: - if key == "DECKY_LSFGVK_AUTO_PROFILE": - script_values["use_native_matching"] = value == "1" if key == "DISABLE_LSFGVK": script_values["disable_lsfgvk"] = value == "1" if key == "DXVK_FRAME_RATE": @@ -106,8 +96,6 @@ def get_script_generation_logic(): """Return the script generation logic as a callable""" def generate_script_lines(config): lines = [] - if config.get("use_native_matching", False): - lines.append("export DECKY_LSFGVK_AUTO_PROFILE=1") if config.get("disable_lsfgvk", False): lines.append("export DISABLE_LSFGVK=1") dxvk_frame_rate = config.get("dxvk_frame_rate", 0) @@ -133,4 +121,4 @@ def get_script_generation_logic(): return generate_script_lines -ALL_FIELDS = ['dll', 'allow_fp16', 'multiplier', 'flow_scale', 'performance_mode', 'pacing', 'active_in', 'use_native_matching', 'gpu', 'disable_lsfgvk', 'dxvk_frame_rate', 'enable_wow64', 'disable_steamdeck_mode', 'mangohud_workaround', 'disable_vkbasalt', 'force_enable_vkbasalt', 'enable_wsi', 'enable_zink'] +ALL_FIELDS = ['allow_fp16', 'multiplier', 'flow_scale', 'performance_mode', 'pacing', 'disable_lsfgvk', 'dxvk_frame_rate', 'enable_wow64', 'disable_steamdeck_mode', 'mangohud_workaround', 'disable_vkbasalt', 'force_enable_vkbasalt', 'enable_wsi', 'enable_zink'] diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index 6511745..490689c 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -17,10 +17,8 @@ class ConfigurationService(BaseService): """Service for managing TOML-based lsfg configuration""" @staticmethod - def _profile_selection_lines(profile_name: str, config: ConfigurationData) -> list[str]: - """Force the selected profile unless the user explicitly opts into native matching.""" - if config.get("use_native_matching", False): - return ["# lsfg-vk will select a matching profile from Active In."] + def _profile_selection_lines(profile_name: str) -> list[str]: + """Force the profile selected in Decky for every launch.""" return [f"export LSFGVK_PROFILE={shlex.quote(profile_name)}"] def get_config(self) -> ConfigurationResponse: @@ -31,9 +29,7 @@ class ConfigurationService(BaseService): """ try: if not self.config_file_path.exists(): - from .dll_detection import DllDetectionService - dll_service = DllDetectionService(self.log) - toml_config = ConfigurationManager.get_defaults_with_dll_detection(dll_service) + toml_config = ConfigurationManager.get_defaults() else: content = self.config_file_path.read_text(encoding='utf-8') toml_config = ConfigurationManager.parse_toml_content(content) @@ -58,9 +54,7 @@ class ConfigurationService(BaseService): except Exception as e: error_msg = f"Error parsing config file: {str(e)}" self.log.error(error_msg) - from .dll_detection import DllDetectionService - dll_service = DllDetectionService(self.log) - config = ConfigurationManager.get_defaults_with_dll_detection(dll_service) + config = ConfigurationManager.get_defaults() return self._success_response(ConfigurationResponse, f"Using default configuration due to parse error: {str(e)}", config=config) @@ -134,7 +128,7 @@ class ConfigurationService(BaseService): lines.extend([ f"export LSFGVK_CONFIG={shlex.quote(str(self.config_file_path))}", - *self._profile_selection_lines(DEFAULT_PROFILE_NAME, config), + *self._profile_selection_lines(DEFAULT_PROFILE_NAME), ]) lines.extend(self._generate_game_launch_lines()) @@ -166,7 +160,7 @@ class ConfigurationService(BaseService): lines.extend([ f"export LSFGVK_CONFIG={shlex.quote(str(self.config_file_path))}", - *self._profile_selection_lines(current_profile, cast(ConfigurationData, merged_config)), + *self._profile_selection_lines(current_profile), ]) lines.extend(self._generate_game_launch_lines()) @@ -193,14 +187,11 @@ class ConfigurationService(BaseService): def _get_profile_data(self) -> ProfileData: """Get current profile data from config file""" if not self.config_file_path.exists(): - from .dll_detection import DllDetectionService - dll_service = DllDetectionService(self.log) - default_config = ConfigurationManager.get_defaults_with_dll_detection(dll_service) + default_config = ConfigurationManager.get_defaults() return ProfileData( current_profile=DEFAULT_PROFILE_NAME, profiles={DEFAULT_PROFILE_NAME: default_config}, global_config={ - "dll": default_config.get("dll", ""), "allow_fp16": default_config.get("allow_fp16", True) } ) @@ -416,7 +407,7 @@ class ConfigurationService(BaseService): profile_data["profiles"][profile_name] = config # Update global config fields if they're in the config - for field_name in ["dll", "allow_fp16"]: + for field_name in ["allow_fp16"]: if field_name in config: profile_data["global_config"][field_name] = config[field_name] diff --git a/py_modules/lsfg_vk/flatpak_service.py b/py_modules/lsfg_vk/flatpak_service.py index 8410496..da01d8b 100644 --- a/py_modules/lsfg_vk/flatpak_service.py +++ b/py_modules/lsfg_vk/flatpak_service.py @@ -8,7 +8,6 @@ from pathlib import Path from typing import Dict, Any, List, Optional from .base_service import BaseService -from .config_schema import ConfigurationManager from .constants import ( BIN_DIR, FLATPAK_23_08_FILENAME, @@ -63,17 +62,6 @@ class FlatpakService(BaseService): """Return the v2 config directory and directory containing Lossless.dll.""" config_path = str(self.config_dir) dll_directory = str(self.user_home / ".local/share/Steam/steamapps/common") - if not self.config_file_path.exists(): - return config_path, dll_directory - try: - profile_data = ConfigurationManager.parse_toml_content_multi_profile( - self.config_file_path.read_text(encoding="utf-8") - ) - configured_dll = profile_data["global_config"].get("dll", "") - if configured_dll: - dll_directory = str(Path(str(configured_dll)).parent) - except (OSError, ValueError, KeyError, TypeError) as error: - self.log.debug("Could not read configured DLL path for Flatpak override: %s", error) return config_path, dll_directory def _get_bundled_extension_path(self, version: str) -> Path: diff --git a/py_modules/lsfg_vk/installation.py b/py_modules/lsfg_vk/installation.py index 1ba091a..899804b 100644 --- a/py_modules/lsfg_vk/installation.py +++ b/py_modules/lsfg_vk/installation.py @@ -183,9 +183,6 @@ class InstallationService(BaseService): def _create_config_file(self) -> ProfileData: """Migrate v1 once, normalize v2, and retain Decky launch workarounds.""" - from .dll_detection import DllDetectionService - - dll_service = DllDetectionService(self.log) profile_data: ProfileData was_legacy = False self._config_recovery_backup = None @@ -201,23 +198,23 @@ class InstallationService(BaseService): self._config_recovery_backup, error, ) - default = ConfigurationManager.get_defaults_with_dll_detection(dll_service) + default = ConfigurationManager.get_defaults() profile_data = ProfileData( current_profile="decky-lsfg-vk", profiles={"decky-lsfg-vk": default}, - global_config={"dll": default["dll"], "allow_fp16": default["allow_fp16"]}, + global_config={"allow_fp16": default["allow_fp16"]}, ) if was_legacy: self._backup_legacy_config(content) else: - default = ConfigurationManager.get_defaults_with_dll_detection(dll_service) + default = ConfigurationManager.get_defaults() profile_data = ProfileData( current_profile="decky-lsfg-vk", profiles={"decky-lsfg-vk": default}, - global_config={"dll": default["dll"], "allow_fp16": default["allow_fp16"]}, + global_config={"allow_fp16": default["allow_fp16"]}, ) - profile_data = self._merge_config_with_defaults(profile_data, dll_service) + profile_data = self._merge_config_with_defaults(profile_data) script_values = self._read_script_values() current_profile = profile_data["current_profile"] profile_data["profiles"][current_profile] = ConfigurationManager.merge_config_with_script( @@ -267,21 +264,12 @@ class InstallationService(BaseService): script = configuration_service._generate_script_content_for_profile(profile_data) self._write_file(self.lsfg_launch_script_path, script, 0o755) - def _merge_config_with_defaults(self, existing: ProfileData, dll_service) -> ProfileData: - defaults = ConfigurationManager.get_defaults_with_dll_detection(dll_service) - global_config = dict(existing.get("global_config", {})) - configured_dll = str(global_config.get("dll", "") or "").strip() - detected_dll = str(defaults.get("dll", "") or "").strip() - if configured_dll and Path(configured_dll).is_file(): - global_config["dll"] = configured_dll - elif detected_dll and Path(detected_dll).is_file(): - self.log.warning("Replacing stale configured Lossless.dll path %s with %s", configured_dll, detected_dll) - global_config["dll"] = detected_dll - else: - if configured_dll: - self.log.warning("Clearing stale configured Lossless.dll path %s", configured_dll) - global_config["dll"] = "" - global_config.setdefault("allow_fp16", defaults["allow_fp16"]) + def _merge_config_with_defaults(self, existing: ProfileData) -> ProfileData: + defaults = ConfigurationManager.get_defaults() + existing_global = existing.get("global_config", {}) + global_config = { + "allow_fp16": existing_global.get("allow_fp16", defaults["allow_fp16"]), + } profiles: Dict[str, Any] = {} for name, existing_config in existing.get("profiles", {}).items(): |
