From c02343e68874efd57c2e312cb6b7e4f02222e43a Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 22 Jul 2025 11:11:44 -0400 Subject: add workaround env vars, rm old tests --- py_modules/lsfg_vk/configuration.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'py_modules/lsfg_vk/configuration.py') diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index 47d0ebc..82982e5 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -65,7 +65,9 @@ class ConfigurationService(BaseService): experimental_present_mode: str = "fifo", dxvk_frame_rate: int = 0, enable_wow64: bool = False, - disable_steamdeck_mode: bool = False) -> ConfigurationResponse: + disable_steamdeck_mode: bool = False, + mangohud_workaround: bool = False, + disable_vkbasalt: bool = False) -> ConfigurationResponse: """Update TOML configuration Args: @@ -78,6 +80,8 @@ class ConfigurationService(BaseService): dxvk_frame_rate: Frame rate cap for DirectX games, before frame multiplier (0 = disabled) enable_wow64: Whether to enable PROTON_USE_WOW64=1 for 32-bit games disable_steamdeck_mode: Whether to disable Steam Deck mode + mangohud_workaround: Whether to enable MangoHud workaround with transparent overlay + disable_vkbasalt: Whether to disable vkBasalt layer Returns: ConfigurationResponse with success status @@ -86,7 +90,8 @@ class ConfigurationService(BaseService): # Create configuration from individual arguments config = ConfigurationManager.create_config_from_args( dll, multiplier, flow_scale, performance_mode, hdr_mode, - experimental_present_mode, dxvk_frame_rate, enable_wow64, disable_steamdeck_mode + experimental_present_mode, dxvk_frame_rate, enable_wow64, disable_steamdeck_mode, + mangohud_workaround, disable_vkbasalt ) # Generate TOML content using centralized manager @@ -108,7 +113,8 @@ class ConfigurationService(BaseService): f"performance_mode={performance_mode}, hdr_mode={hdr_mode}, " f"experimental_present_mode='{experimental_present_mode}', " f"dxvk_frame_rate={dxvk_frame_rate}, " - f"enable_wow64={enable_wow64}, disable_steamdeck_mode={disable_steamdeck_mode}") + f"enable_wow64={enable_wow64}, disable_steamdeck_mode={disable_steamdeck_mode}, " + f"mangohud_workaround={mangohud_workaround}, disable_vkbasalt={disable_vkbasalt}") return self._success_response(ConfigurationResponse, "lsfg configuration updated successfully", @@ -214,6 +220,13 @@ class ConfigurationService(BaseService): if config.get("disable_steamdeck_mode", False): lines.append("export SteamDeck=0") + if config.get("mangohud_workaround", False): + lines.append("export MANGOHUD=1") + lines.append("export MANGOHUD_CONFIG=alpha=0.01,background_alpha=0.01") + + if config.get("disable_vkbasalt", False): + lines.append("export DISABLE_VKBASALT=1") + # Add DXVK_FRAME_RATE if dxvk_frame_rate is set dxvk_frame_rate = config.get("dxvk_frame_rate", 0) if dxvk_frame_rate > 0: -- cgit v1.2.3 From dfe4c033dd1922a63c8393ab467e9aa58fa757e4 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 22 Jul 2025 11:41:49 -0400 Subject: refactor: update configuration handling to use object-based API --- py_modules/lsfg_vk/configuration.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'py_modules/lsfg_vk/configuration.py') diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index 82982e5..68ff577 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -222,7 +222,7 @@ class ConfigurationService(BaseService): if config.get("mangohud_workaround", False): lines.append("export MANGOHUD=1") - lines.append("export MANGOHUD_CONFIG=alpha=0.01,background_alpha=0.01") + lines.append("export MANGOHUD_CONFIG=alpha=0.001,background_alpha=0.001") if config.get("disable_vkbasalt", False): lines.append("export DISABLE_VKBASALT=1") -- cgit v1.2.3 From f8139896f2077a95a78a54c818637f78dd102de8 Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 22 Jul 2025 12:11:53 -0400 Subject: consolidate toml and script values --- py_modules/lsfg_vk/configuration.py | 55 +++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'py_modules/lsfg_vk/configuration.py') diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index 68ff577..b4c7994 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -60,6 +60,47 @@ class ConfigurationService(BaseService): f"Using default configuration due to parse error: {str(e)}", config=config) + def update_config_from_dict(self, config: ConfigurationData) -> ConfigurationResponse: + """Update TOML configuration from configuration dictionary (eliminates parameter duplication) + + Args: + config: Complete configuration data dictionary + + Returns: + ConfigurationResponse with success status + """ + try: + # Generate TOML content using centralized manager + toml_content = ConfigurationManager.generate_toml_content(config) + + # Ensure config directory exists + self.config_dir.mkdir(parents=True, exist_ok=True) + + # Write the updated config directly to preserve inode for file watchers + self._write_file(self.config_file_path, toml_content, 0o644) + + # Update the launch script with the new configuration + script_result = self.update_lsfg_script(config) + if not script_result["success"]: + self.log.warning(f"Failed to update launch script: {script_result['error']}") + + # Log with dynamic field listing + field_values = ", ".join(f"{k}={repr(v)}" for k, v in config.items()) + self.log.info(f"Updated lsfg configuration: {field_values}") + + return self._success_response(ConfigurationResponse, + "lsfg configuration updated successfully", + config=config) + + except (OSError, IOError) as e: + error_msg = f"Error updating lsfg config: {str(e)}" + self.log.error(error_msg) + return self._error_response(ConfigurationResponse, str(e), config=None) + except ValueError as e: + error_msg = f"Invalid configuration arguments: {str(e)}" + self.log.error(error_msg) + return self._error_response(ConfigurationResponse, str(e), config=None) + def update_config(self, dll: str, multiplier: int, flow_scale: float, performance_mode: bool, hdr_mode: bool, experimental_present_mode: str = "fifo", @@ -67,7 +108,9 @@ class ConfigurationService(BaseService): enable_wow64: bool = False, disable_steamdeck_mode: bool = False, mangohud_workaround: bool = False, - disable_vkbasalt: bool = False) -> ConfigurationResponse: + disable_vkbasalt: bool = False, + foobar_toggle: bool = False, + test_config_only: str = "default_value") -> ConfigurationResponse: """Update TOML configuration Args: @@ -82,6 +125,8 @@ class ConfigurationService(BaseService): disable_steamdeck_mode: Whether to disable Steam Deck mode mangohud_workaround: Whether to enable MangoHud workaround with transparent overlay disable_vkbasalt: Whether to disable vkBasalt layer + foobar_toggle: Test script-only toggle that exports FOOBAR=1 + test_config_only: Test TOML-only configuration field Returns: ConfigurationResponse with success status @@ -91,7 +136,7 @@ class ConfigurationService(BaseService): config = ConfigurationManager.create_config_from_args( dll, multiplier, flow_scale, performance_mode, hdr_mode, experimental_present_mode, dxvk_frame_rate, enable_wow64, disable_steamdeck_mode, - mangohud_workaround, disable_vkbasalt + mangohud_workaround, disable_vkbasalt, foobar_toggle, test_config_only ) # Generate TOML content using centralized manager @@ -114,7 +159,8 @@ class ConfigurationService(BaseService): f"experimental_present_mode='{experimental_present_mode}', " f"dxvk_frame_rate={dxvk_frame_rate}, " f"enable_wow64={enable_wow64}, disable_steamdeck_mode={disable_steamdeck_mode}, " - f"mangohud_workaround={mangohud_workaround}, disable_vkbasalt={disable_vkbasalt}") + f"mangohud_workaround={mangohud_workaround}, disable_vkbasalt={disable_vkbasalt}, " + f"foobar_toggle={foobar_toggle}, test_config_only='{test_config_only}'") return self._success_response(ConfigurationResponse, "lsfg configuration updated successfully", @@ -227,6 +273,9 @@ class ConfigurationService(BaseService): if config.get("disable_vkbasalt", False): lines.append("export DISABLE_VKBASALT=1") + if config.get("foobar_toggle", False): + lines.append("export FOOBAR=1") + # Add DXVK_FRAME_RATE if dxvk_frame_rate is set dxvk_frame_rate = config.get("dxvk_frame_rate", 0) if dxvk_frame_rate > 0: -- cgit v1.2.3 From f8c09209513507ad9af7822c32119cf6d6fae0ac Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 22 Jul 2025 12:40:23 -0400 Subject: rm test config options --- py_modules/lsfg_vk/configuration.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'py_modules/lsfg_vk/configuration.py') diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index b4c7994..49653ea 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -108,9 +108,7 @@ class ConfigurationService(BaseService): enable_wow64: bool = False, disable_steamdeck_mode: bool = False, mangohud_workaround: bool = False, - disable_vkbasalt: bool = False, - foobar_toggle: bool = False, - test_config_only: str = "default_value") -> ConfigurationResponse: + disable_vkbasalt: bool = False) -> ConfigurationResponse: """Update TOML configuration Args: @@ -125,8 +123,6 @@ class ConfigurationService(BaseService): disable_steamdeck_mode: Whether to disable Steam Deck mode mangohud_workaround: Whether to enable MangoHud workaround with transparent overlay disable_vkbasalt: Whether to disable vkBasalt layer - foobar_toggle: Test script-only toggle that exports FOOBAR=1 - test_config_only: Test TOML-only configuration field Returns: ConfigurationResponse with success status @@ -136,7 +132,7 @@ class ConfigurationService(BaseService): config = ConfigurationManager.create_config_from_args( dll, multiplier, flow_scale, performance_mode, hdr_mode, experimental_present_mode, dxvk_frame_rate, enable_wow64, disable_steamdeck_mode, - mangohud_workaround, disable_vkbasalt, foobar_toggle, test_config_only + mangohud_workaround, disable_vkbasalt ) # Generate TOML content using centralized manager @@ -159,8 +155,7 @@ class ConfigurationService(BaseService): f"experimental_present_mode='{experimental_present_mode}', " f"dxvk_frame_rate={dxvk_frame_rate}, " f"enable_wow64={enable_wow64}, disable_steamdeck_mode={disable_steamdeck_mode}, " - f"mangohud_workaround={mangohud_workaround}, disable_vkbasalt={disable_vkbasalt}, " - f"foobar_toggle={foobar_toggle}, test_config_only='{test_config_only}'") + f"mangohud_workaround={mangohud_workaround}, disable_vkbasalt={disable_vkbasalt}") return self._success_response(ConfigurationResponse, "lsfg configuration updated successfully", @@ -273,9 +268,6 @@ class ConfigurationService(BaseService): if config.get("disable_vkbasalt", False): lines.append("export DISABLE_VKBASALT=1") - if config.get("foobar_toggle", False): - lines.append("export FOOBAR=1") - # Add DXVK_FRAME_RATE if dxvk_frame_rate is set dxvk_frame_rate = config.get("dxvk_frame_rate", 0) if dxvk_frame_rate > 0: -- cgit v1.2.3 From df0635f1bba611b8b44975057acd579102d209dd Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 22 Jul 2025 13:06:46 -0400 Subject: further automate population of hardcoded fields --- py_modules/lsfg_vk/configuration.py | 44 +++++++++++-------------------------- 1 file changed, 13 insertions(+), 31 deletions(-) (limited to 'py_modules/lsfg_vk/configuration.py') diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index 49653ea..e745e29 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -6,7 +6,9 @@ from pathlib import Path from typing import Dict, Any from .base_service import BaseService -from .config_schema import ConfigurationManager, ConfigurationData, CONFIG_SCHEMA +from .config_schema import ConfigurationManager, CONFIG_SCHEMA +from .config_schema_generated import ConfigurationData, get_script_generation_logic +from .configuration_helpers_generated import log_configuration_update from .types import ConfigurationResponse @@ -149,13 +151,8 @@ class ConfigurationService(BaseService): if not script_result["success"]: self.log.warning(f"Failed to update launch script: {script_result['error']}") - self.log.info(f"Updated lsfg TOML configuration: " - f"dll='{dll}', multiplier={multiplier}, flow_scale={flow_scale}, " - f"performance_mode={performance_mode}, hdr_mode={hdr_mode}, " - f"experimental_present_mode='{experimental_present_mode}', " - f"dxvk_frame_rate={dxvk_frame_rate}, " - f"enable_wow64={enable_wow64}, disable_steamdeck_mode={disable_steamdeck_mode}, " - f"mangohud_workaround={mangohud_workaround}, disable_vkbasalt={disable_vkbasalt}") + # Use auto-generated logging + log_configuration_update(self.log, config) return self._success_response(ConfigurationResponse, "lsfg configuration updated successfully", @@ -254,29 +251,14 @@ class ConfigurationService(BaseService): "# This script sets up the environment for lsfg-vk to work with the plugin configuration" ] - # Add optional export statements based on configuration - if config.get("enable_wow64", False): - lines.append("export PROTON_USE_WOW64=1") + # Use auto-generated script generation logic + generate_script_lines = get_script_generation_logic() + lines.extend(generate_script_lines(config)) - if config.get("disable_steamdeck_mode", False): - lines.append("export SteamDeck=0") - - if config.get("mangohud_workaround", False): - lines.append("export MANGOHUD=1") - lines.append("export MANGOHUD_CONFIG=alpha=0.001,background_alpha=0.001") - - if config.get("disable_vkbasalt", False): - lines.append("export DISABLE_VKBASALT=1") - - # Add DXVK_FRAME_RATE if dxvk_frame_rate is set - dxvk_frame_rate = config.get("dxvk_frame_rate", 0) - if dxvk_frame_rate > 0: - lines.append(f"export DXVK_FRAME_RATE={dxvk_frame_rate}") - - # Always add the LSFG_PROCESS export - lines.append("export LSFG_PROCESS=decky-lsfg-vk") - - # Add the execution line - lines.append('exec "$@"') + # Always add the LSFG_PROCESS export and execution line + lines.extend([ + "export LSFG_PROCESS=decky-lsfg-vk", + 'exec "$@"' + ]) return "\n".join(lines) + "\n" -- cgit v1.2.3 From d063284dea10e82a23c2c332ecd4901d7254171b Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Tue, 22 Jul 2025 13:23:25 -0400 Subject: use generated kwargs and config in more hardcoded places --- py_modules/lsfg_vk/configuration.py | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) (limited to 'py_modules/lsfg_vk/configuration.py') diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index e745e29..b9ee174 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -103,39 +103,18 @@ class ConfigurationService(BaseService): self.log.error(error_msg) return self._error_response(ConfigurationResponse, str(e), config=None) - def update_config(self, dll: str, multiplier: int, flow_scale: float, - performance_mode: bool, hdr_mode: bool, - experimental_present_mode: str = "fifo", - dxvk_frame_rate: int = 0, - enable_wow64: bool = False, - disable_steamdeck_mode: bool = False, - mangohud_workaround: bool = False, - disable_vkbasalt: bool = False) -> ConfigurationResponse: - """Update TOML configuration + def update_config(self, **kwargs) -> ConfigurationResponse: + """Update TOML configuration using generated schema - SIMPLIFIED WITH GENERATED CODE Args: - dll: Path to Lossless.dll - multiplier: LSFG multiplier value - flow_scale: LSFG flow scale value - performance_mode: Whether to enable performance mode - hdr_mode: Whether to enable HDR mode - experimental_present_mode: Experimental Vulkan present mode override - dxvk_frame_rate: Frame rate cap for DirectX games, before frame multiplier (0 = disabled) - enable_wow64: Whether to enable PROTON_USE_WOW64=1 for 32-bit games - disable_steamdeck_mode: Whether to disable Steam Deck mode - mangohud_workaround: Whether to enable MangoHud workaround with transparent overlay - disable_vkbasalt: Whether to disable vkBasalt layer + **kwargs: Configuration field values (see shared_config.py for available fields) Returns: ConfigurationResponse with success status """ try: - # Create configuration from individual arguments - config = ConfigurationManager.create_config_from_args( - dll, multiplier, flow_scale, performance_mode, hdr_mode, - experimental_present_mode, dxvk_frame_rate, enable_wow64, disable_steamdeck_mode, - mangohud_workaround, disable_vkbasalt - ) + # Create configuration from keyword arguments using generated function + config = ConfigurationManager.create_config_from_args(**kwargs) # Generate TOML content using centralized manager toml_content = ConfigurationManager.generate_toml_content(config) @@ -187,8 +166,9 @@ class ConfigurationService(BaseService): else: config = current_response["config"] - # Update just the DLL path - config["dll"] = dll_path + # Update just the DLL path - USE GENERATED CONSTANTS + from .config_schema_generated import DLL + config[DLL] = dll_path # Generate TOML content and write it toml_content = ConfigurationManager.generate_toml_content(config) -- cgit v1.2.3