From 4369582fd95adee1017c321cea6e4dd09142d817 Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Tue, 11 Aug 2026 23:11:08 -0700 Subject: [PATCH] fix: Disable TDP control when in overlay mode, this conflicts with SteamOS-Manager and causes TDP to always apply the OGUI options unless the Steam QAM is open --- core/global/platform.gd | 11 ++++++ core/global/platform_test.gd | 19 ++++++++++ core/global/platform_test.gd.uid | 1 + core/main.gd | 10 ++--- .../performance/performance_manager.gd | 37 ++++++++++++------- core/ui/common/quick_bar/performance_menu.gd | 23 +++++++++--- 6 files changed, 75 insertions(+), 26 deletions(-) create mode 100644 core/global/platform_test.gd create mode 100644 core/global/platform_test.gd.uid diff --git a/core/global/platform.gd b/core/global/platform.gd index 6426e6141..08706b988 100644 --- a/core/global/platform.gd +++ b/core/global/platform.gd @@ -8,6 +8,9 @@ class_name Platform signal platform_loaded +## Command-line arguments that launch OpenGamepadUI in overlay mode +const OVERLAY_MODE_ARGS := ["--overlay-mode", "--only-qam", "--qam-only"] + ## Platforms we support enum PLATFORM { # Hardware platforms @@ -60,6 +63,14 @@ var logger := Log.get_logger("Platform", Log.LEVEL.INFO) var loaded: bool +## Returns whether or not OpenGamepadUI was launched in overlay mode. +static func is_overlay_mode(args := OS.get_cmdline_args()) -> bool: + for arg in args: + if arg in OVERLAY_MODE_ARGS: + return true + return false + + func _init() -> void: var flags := get_platform_flags() diff --git a/core/global/platform_test.gd b/core/global/platform_test.gd new file mode 100644 index 000000000..e26a0157a --- /dev/null +++ b/core/global/platform_test.gd @@ -0,0 +1,19 @@ +extends GutTest + + +# Test detecting overlay mode from the given command-line arguments +func test_is_overlay_mode() -> void: + var args := PackedStringArray(["opengamepadui", "--accessibility", "disabled"]) + assert_false(Platform.is_overlay_mode(args), "should not detect overlay mode") + + args = PackedStringArray(["opengamepadui", "--overlay-mode", "--", "steam"]) + assert_true(Platform.is_overlay_mode(args), "should detect overlay mode") + + +# Test detecting overlay mode from the deprecated command-line arguments +func test_is_overlay_mode_deprecated() -> void: + var args := PackedStringArray(["opengamepadui", "--only-qam"]) + assert_true(Platform.is_overlay_mode(args), "should detect overlay mode from --only-qam") + + args = PackedStringArray(["opengamepadui", "--qam-only"]) + assert_true(Platform.is_overlay_mode(args), "should detect overlay mode from --qam-only") diff --git a/core/global/platform_test.gd.uid b/core/global/platform_test.gd.uid new file mode 100644 index 000000000..2cc20157b --- /dev/null +++ b/core/global/platform_test.gd.uid @@ -0,0 +1 @@ +uid://b0smj2ndlw2sh diff --git a/core/main.gd b/core/main.gd index 5afd83997..c59794820 100644 --- a/core/main.gd +++ b/core/main.gd @@ -12,12 +12,10 @@ func _ready() -> void: return # Launch CardUI in overlay mode - if "--qam-only" in args or "--only-qam" in args: - print("[WARN] Deprecation Warning: --only-qam and --qam-only launch arguments are deprecated\ - and will be removed in a future update. Use --overlay-mode instead.") - _change_to_scene("res://core/ui/card_ui_overlay_mode/card_ui_overlay_mode.tscn") - return - elif "--overlay-mode" in args: + if Platform.is_overlay_mode(args): + if "--qam-only" in args or "--only-qam" in args: + print("[WARN] Deprecation Warning: --only-qam and --qam-only launch arguments are deprecated\ + and will be removed in a future update. Use --overlay-mode instead.") _change_to_scene("res://core/ui/card_ui_overlay_mode/card_ui_overlay_mode.tscn") return diff --git a/core/systems/performance/performance_manager.gd b/core/systems/performance/performance_manager.gd index 590e4af72..5a8854e6b 100644 --- a/core/systems/performance/performance_manager.gd +++ b/core/systems/performance/performance_manager.gd @@ -28,6 +28,8 @@ var _power_station := load("res://core/systems/performance/power_station.tres") var _launch_manager := load("res://core/global/launch_manager.tres") as LaunchManager var display_device := _power_manager.get_display_device() +## Whether or not OpenGamepadUI is running in overlay mode. +var overlay_mode := Platform.is_overlay_mode() var current_profile: PerformanceProfile var current_profile_state: PROFILE_STATE # docked or undocked var logger := Log.get_logger("PerformanceManager", Log.LEVEL.INFO) @@ -181,24 +183,31 @@ func apply_profile(profile: PerformanceProfile) -> void: if card.class != "integrated": continue logger.debug("Applying GPU performance settings from profile") - if card.power_profile != profile.gpu_power_profile: - logger.debug("Applying Power Profile: " + profile.gpu_power_profile) - card.power_profile = profile.gpu_power_profile - if card.manual_clock != profile.gpu_manual_enabled: - logger.debug("Applying Manual Clock Enabled: " + str(profile.gpu_manual_enabled)) - card.manual_clock = profile.gpu_manual_enabled - if profile.gpu_freq_min_current > 0 and card.clock_value_mhz_min != profile.gpu_freq_min_current: - logger.debug("Applying Clock Freq Min: " + str(profile.gpu_freq_min_current)) - card.clock_value_mhz_min = profile.gpu_freq_min_current - if profile.gpu_freq_max_current > 0 and card.clock_value_mhz_max != profile.gpu_freq_max_current: - logger.debug("Applying Clock Freq Max: " + str(profile.gpu_freq_max_current)) - card.clock_value_mhz_max = profile.gpu_freq_max_current + + # The GPU performance level and clock frequency are managed by the + # underlying session when in overlay mode. + if not overlay_mode: + if card.power_profile != profile.gpu_power_profile: + logger.debug("Applying Power Profile: " + profile.gpu_power_profile) + card.power_profile = profile.gpu_power_profile + if card.manual_clock != profile.gpu_manual_enabled: + logger.debug("Applying Manual Clock Enabled: " + str(profile.gpu_manual_enabled)) + card.manual_clock = profile.gpu_manual_enabled + if profile.gpu_freq_min_current > 0 and card.clock_value_mhz_min != profile.gpu_freq_min_current: + logger.debug("Applying Clock Freq Min: " + str(profile.gpu_freq_min_current)) + card.clock_value_mhz_min = profile.gpu_freq_min_current + if profile.gpu_freq_max_current > 0 and card.clock_value_mhz_max != profile.gpu_freq_max_current: + logger.debug("Applying Clock Freq Max: " + str(profile.gpu_freq_max_current)) + card.clock_value_mhz_max = profile.gpu_freq_max_current if profile.gpu_temp_current > 0 and card.thermal_throttle_limit_c != profile.gpu_temp_current: logger.debug("Applying Thermal Throttle Limit: " + str(profile.gpu_temp_current)) card.thermal_throttle_limit_c = profile.gpu_temp_current - # Only apply GPU TDP settings from the given profile if we're in a mode that supports it - if profile.advanced_mode or "max-performance" in get_power_profiles_available(): + # Only apply GPU TDP settings from the given profile if we're in a mode + # that supports it and TDP isn't managed by the underlying session + if overlay_mode: + logger.debug("Overlay mode detected. TDP and GPU clock frequency are managed by the session") + elif profile.advanced_mode or "max-performance" in get_power_profiles_available(): if profile.tdp_current > 0 and card.tdp != profile.tdp_current: logger.debug("Applying TDP: " + str(profile.tdp_current)) card.tdp = profile.tdp_current diff --git a/core/ui/common/quick_bar/performance_menu.gd b/core/ui/common/quick_bar/performance_menu.gd index 211b324ed..b1b13a790 100644 --- a/core/ui/common/quick_bar/performance_menu.gd +++ b/core/ui/common/quick_bar/performance_menu.gd @@ -27,6 +27,10 @@ var _profiles_available: PackedStringArray var _power_station_running := false var _profile_loading := false +## In overlay mode the session we're running on top of (e.g. Steam) manages TDP, +## the GPU performance level, and GPU clock frequency itself, so we don't show +## controls for them. +var _overlay_mode := Platform.is_overlay_mode() var _current_profile: PerformanceProfile var logger := Log.get_logger("Performance", Log.LEVEL.INFO) @@ -121,6 +125,10 @@ func _ready() -> void: # Toggle visibility when the GPU freq manual toggle is on var on_manual_freq := func() -> void: + # GPU clock frequency is managed by the underlying session in overlay mode + if _overlay_mode: + return + # Immediately apply manual GPU frequency so we can read the min/max # values for the sliders var card := _get_integrated_card() @@ -269,22 +277,25 @@ func _setup_interface() -> void: gpu_label.visible = is_advanced - tdp_slider.visible = is_advanced + # Avoid setting TDP/Freq if managed by the underlying session + var gpu_power_manageable := not _overlay_mode + + tdp_slider.visible = is_advanced and gpu_power_manageable tdp_slider.min_value = round(_hardware_manager.gpu.tdp_min) tdp_slider.max_value = round(_hardware_manager.gpu.tdp_max) - tdp_boost_slider.visible = is_advanced + tdp_boost_slider.visible = is_advanced and gpu_power_manageable tdp_boost_slider.max_value = round(_hardware_manager.gpu.max_boost) - gpu_freq_enable.visible = is_advanced + gpu_freq_enable.visible = is_advanced and gpu_power_manageable - power_profile_dropdown.visible = not is_advanced + power_profile_dropdown.visible = not is_advanced and gpu_power_manageable - gpu_freq_min_slider.visible = card.manual_clock and is_advanced + gpu_freq_min_slider.visible = card.manual_clock and is_advanced and gpu_power_manageable gpu_freq_min_slider.min_value = round(card.clock_limit_mhz_min) gpu_freq_min_slider.max_value = round(card.clock_limit_mhz_max) - gpu_freq_max_slider.visible = card.manual_clock and is_advanced + gpu_freq_max_slider.visible = card.manual_clock and is_advanced and gpu_power_manageable gpu_freq_max_slider.min_value = round(card.clock_limit_mhz_min) gpu_freq_max_slider.max_value = round(card.clock_limit_mhz_max)