diff options
| author | Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> | 2025-07-19 08:40:49 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-19 08:40:49 -0400 |
| commit | f010473bfdf6b9a58960a5dac71fa48837ae6a1c (patch) | |
| tree | c0392ef13b7cc47bc27369e7840e58fa23e745b7 /py_modules | |
| parent | b9302548a4def670c8600086ba8685c075ceac3d (diff) | |
| parent | 75a94598341899eea5260206975686c05e793956 (diff) | |
| download | decky-lsfg-vk-f010473bfdf6b9a58960a5dac71fa48837ae6a1c.tar.gz decky-lsfg-vk-f010473bfdf6b9a58960a5dac71fa48837ae6a1c.zip | |
Merge pull request #41 from xXJSONDeruloXx/nerd-stuffv0.6.4
Nerd stuff
Diffstat (limited to 'py_modules')
| -rw-r--r-- | py_modules/lsfg_vk/config_schema.py | 34 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/configuration.py | 7 | ||||
| -rw-r--r-- | py_modules/lsfg_vk/plugin.py | 67 |
3 files changed, 75 insertions, 33 deletions
diff --git a/py_modules/lsfg_vk/config_schema.py b/py_modules/lsfg_vk/config_schema.py index 460b0a0..45afc2d 100644 --- a/py_modules/lsfg_vk/config_schema.py +++ b/py_modules/lsfg_vk/config_schema.py @@ -38,13 +38,6 @@ class ConfigField: # Configuration schema definition CONFIG_SCHEMA: Dict[str, ConfigField] = { - "enable": ConfigField( - name="enable", - field_type=ConfigFieldType.BOOLEAN, - default=True, - description="enable/disable lsfg on every game" - ), - "dll": ConfigField( name="dll", field_type=ConfigFieldType.STRING, @@ -55,7 +48,7 @@ CONFIG_SCHEMA: Dict[str, ConfigField] = { "multiplier": ConfigField( name="multiplier", field_type=ConfigFieldType.INTEGER, - default=2, + default=1, description="change the fps multiplier" ), @@ -112,7 +105,6 @@ CONFIG_SCHEMA: Dict[str, ConfigField] = { class ConfigurationData(TypedDict): """Type-safe configuration data structure""" - enable: bool dll: str multiplier: int flow_scale: float @@ -219,25 +211,21 @@ class ConfigurationManager: # Add all configuration fields to the game section for field_name, field_def in CONFIG_SCHEMA.items(): - # Skip dll and enable fields - dll goes in global, enable is handled via multiplier - if field_name in ["dll", "enable"]: + # Skip dll field - dll goes in global section + if field_name == "dll": continue value = config[field_name] - # Handle enable field by setting multiplier to 1 when disabled - if field_name == "multiplier" and not config.get("enable", True): - value = 1 - lines.append(f"# LSFG disabled via plugin - multiplier set to 1") - else: - lines.append(f"# {field_def.description}") + # Add field description comment + lines.append(f"# {field_def.description}") # Format value based on type if isinstance(value, bool): lines.append(f"{field_name} = {str(value).lower()}") elif isinstance(value, str) and value: # Only add non-empty strings lines.append(f'{field_name} = "{value}"') - elif isinstance(value, (int, float)) and value != 0: # Only add non-zero numbers + elif isinstance(value, (int, float)): # Always include numbers, even if 0 or 1 lines.append(f"{field_name} = {value}") lines.append("") # Empty line for readability @@ -306,12 +294,7 @@ class ConfigurationManager: config[key] = value.lower() in ('true', '1', 'yes', 'on') elif field_def.field_type == ConfigFieldType.INTEGER: parsed_value = int(value) - # Handle enable field via multiplier - if key == "multiplier": - config[key] = parsed_value - config["enable"] = parsed_value != 1 - else: - config[key] = parsed_value + config[key] = parsed_value elif field_def.field_type == ConfigFieldType.FLOAT: config[key] = float(value) elif field_def.field_type == ConfigFieldType.STRING: @@ -327,7 +310,7 @@ class ConfigurationManager: return ConfigurationManager.get_defaults() @staticmethod - def create_config_from_args(enable: bool, dll: str, multiplier: int, flow_scale: float, + def create_config_from_args(dll: str, multiplier: int, flow_scale: float, performance_mode: bool, hdr_mode: bool, experimental_present_mode: str = "", experimental_fps_limit: int = 0, @@ -335,7 +318,6 @@ class ConfigurationManager: disable_steamdeck_mode: bool = False) -> ConfigurationData: """Create configuration from individual arguments""" return cast(ConfigurationData, { - "enable": enable, "dll": dll, "multiplier": multiplier, "flow_scale": flow_scale, diff --git a/py_modules/lsfg_vk/configuration.py b/py_modules/lsfg_vk/configuration.py index ae0194b..1952a49 100644 --- a/py_modules/lsfg_vk/configuration.py +++ b/py_modules/lsfg_vk/configuration.py @@ -65,7 +65,7 @@ class ConfigurationService(BaseService): "error": None } - def update_config(self, enable: bool, dll: str, multiplier: int, flow_scale: float, + def update_config(self, dll: str, multiplier: int, flow_scale: float, performance_mode: bool, hdr_mode: bool, experimental_present_mode: str = "", experimental_fps_limit: int = 0, @@ -74,7 +74,6 @@ class ConfigurationService(BaseService): """Update TOML configuration Args: - enable: Whether to enable LSFG dll: Path to Lossless.dll multiplier: LSFG multiplier value flow_scale: LSFG flow scale value @@ -91,7 +90,7 @@ class ConfigurationService(BaseService): try: # Create configuration from individual arguments config = ConfigurationManager.create_config_from_args( - enable, dll, multiplier, flow_scale, performance_mode, hdr_mode, + dll, multiplier, flow_scale, performance_mode, hdr_mode, experimental_present_mode, experimental_fps_limit, enable_wow64, disable_steamdeck_mode ) @@ -109,7 +108,7 @@ 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: enable={enable}, " + 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}', " diff --git a/py_modules/lsfg_vk/plugin.py b/py_modules/lsfg_vk/plugin.py index a44840d..4e19a2a 100644 --- a/py_modules/lsfg_vk/plugin.py +++ b/py_modules/lsfg_vk/plugin.py @@ -10,6 +10,7 @@ import json import subprocess import urllib.request import ssl +import hashlib from typing import Dict, Any from pathlib import Path @@ -101,6 +102,67 @@ class Plugin: return result_dict + async def get_dll_stats(self) -> Dict[str, Any]: + """Get detailed statistics about the detected DLL + + Returns: + Dict containing DLL path, SHA256 hash, and other stats + """ + try: + # First check if DLL is detected + dll_result = self.dll_detection_service.check_lossless_scaling_dll() + + if not dll_result.get("detected") or not dll_result.get("path"): + return { + "success": False, + "error": "DLL not detected", + "dll_path": None, + "dll_sha256": None + } + + dll_path = dll_result["path"] + if dll_path is None: + return { + "success": False, + "error": "DLL path is None", + "dll_path": None, + "dll_sha256": None + } + + dll_path_obj = Path(dll_path) + + # Calculate SHA256 hash + sha256_hash = hashlib.sha256() + try: + with open(dll_path_obj, "rb") as f: + # Read file in chunks to handle large files efficiently + for chunk in iter(lambda: f.read(4096), b""): + sha256_hash.update(chunk) + dll_sha256 = sha256_hash.hexdigest() + except Exception as e: + return { + "success": False, + "error": f"Failed to calculate SHA256: {str(e)}", + "dll_path": dll_path, + "dll_sha256": None + } + + return { + "success": True, + "dll_path": dll_path, + "dll_sha256": dll_sha256, + "dll_source": dll_result.get("source"), + "error": None + } + + except Exception as e: + return { + "success": False, + "error": f"Failed to get DLL stats: {str(e)}", + "dll_path": None, + "dll_sha256": None + } + # Configuration methods async def get_lsfg_config(self) -> Dict[str, Any]: """Read current lsfg script configuration @@ -122,7 +184,7 @@ class Plugin: "defaults": ConfigurationManager.get_defaults() } - async def update_lsfg_config(self, enable: bool, dll: str, multiplier: int, flow_scale: float, + async def update_lsfg_config(self, dll: str, multiplier: int, flow_scale: float, performance_mode: bool, hdr_mode: bool, experimental_present_mode: str = "", experimental_fps_limit: int = 0, @@ -131,7 +193,6 @@ class Plugin: """Update lsfg TOML configuration Args: - enable: Whether to enable LSFG dll: Path to Lossless.dll multiplier: LSFG multiplier value flow_scale: LSFG flow scale value @@ -146,7 +207,7 @@ class Plugin: ConfigurationResponse dict with success status """ return self.configuration_service.update_config( - enable, dll, multiplier, flow_scale, performance_mode, hdr_mode, + dll, multiplier, flow_scale, performance_mode, hdr_mode, experimental_present_mode, experimental_fps_limit, enable_wow64, disable_steamdeck_mode ) |
