Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/global/platform.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down
19 changes: 19 additions & 0 deletions core/global/platform_test.gd
Original file line number Diff line number Diff line change
@@ -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")
1 change: 1 addition & 0 deletions core/global/platform_test.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://b0smj2ndlw2sh
10 changes: 4 additions & 6 deletions core/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
37 changes: 23 additions & 14 deletions core/systems/performance/performance_manager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
23 changes: 17 additions & 6 deletions core/ui/common/quick_bar/performance_menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand Down
Loading