mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-02 11:05:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
717c47f58d |
No files matched your search
@@ -336,7 +336,7 @@ FRAME_LIMIT_JS = r"""
|
||||
service = null;
|
||||
}
|
||||
if (!service || !settings?.clientSettings || typeof SteamClient.Settings?.SetSetting !== "function") return "unavailable";
|
||||
const self = { timer: null };
|
||||
const self = { timer: null, wanted: null, written: null };
|
||||
const write = value => (__SET_SETTING__)(21002, value);
|
||||
self.check = async () => {
|
||||
let rates;
|
||||
@@ -349,9 +349,15 @@ FRAME_LIMIT_JS = r"""
|
||||
}
|
||||
if (!Array.isArray(rates) || rates.length === 0) return;
|
||||
const current = settings.clientSettings;
|
||||
if (!current.gamescope_enable_app_target_framerate || rates.includes(current.gamescope_app_target_framerate)) return;
|
||||
const value = current.gamescope_app_target_framerate;
|
||||
if (value !== self.written) self.wanted = value;
|
||||
if (!current.gamescope_enable_app_target_framerate) return;
|
||||
const fitting = rates.filter(rate => rate <= self.wanted);
|
||||
const next = fitting.length ? Math.max(...fitting) : Math.min(...rates);
|
||||
if (next === value) return;
|
||||
try {
|
||||
await write(Math.max(...rates));
|
||||
await write(next);
|
||||
self.written = next;
|
||||
} catch (e) {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,30 +55,33 @@ const change = async next => { rates = next; notify.forEach(callback => callback
|
||||
assert.strictEqual(eval(script), 'installed');
|
||||
assert.strictEqual(eval(script), 'present');
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144], 'a remembered limit the panel does not offer moves to the highest value');
|
||||
assert.deepStrictEqual(writes, [72], 'a remembered limit the panel does not offer moves to the highest offered rate below it');
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144], 'unchanged choices are not written again');
|
||||
assert.deepStrictEqual(writes, [72], 'unchanged choices are not written again');
|
||||
await change([24, 30, 40, 60, 120]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [72, 120], 'the chosen limit comes back once the panel offers it again');
|
||||
settingsStore.clientSettings.gamescope_app_target_framerate = 72;
|
||||
await change([24, 30, 40, 60, 120]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144, 120], '72 is not offered at 120 Hz');
|
||||
assert.deepStrictEqual(writes, [72, 120, 60], '72 is not offered at 120 Hz: the cap is lowered to 60, not lifted');
|
||||
settingsStore.clientSettings.gamescope_app_target_framerate = 60;
|
||||
await change([12, 15, 20, 30, 60]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144, 120], '60 is still offered at 60 Hz and is kept');
|
||||
assert.deepStrictEqual(writes, [72, 120, 60], '60 is still offered at 60 Hz and is kept');
|
||||
await change([18, 24, 36, 72]);
|
||||
await change([24, 30, 40, 60, 120]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144, 120], 'a passing rate during a mode switch is not acted on');
|
||||
assert.deepStrictEqual(writes, [72, 120, 60], 'a passing rate during a mode switch is not acted on');
|
||||
settingsStore.clientSettings.gamescope_enable_app_target_framerate = false;
|
||||
settingsStore.clientSettings.gamescope_app_target_framerate = 72;
|
||||
await change([36, 48, 144]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144, 120], 'nothing changes while Steam has the frame limit turned off');
|
||||
assert.deepStrictEqual(writes, [72, 120, 60], 'nothing changes while Steam has the frame limit turned off');
|
||||
settingsStore.clientSettings.gamescope_enable_app_target_framerate = true;
|
||||
window.__droiddeckFrameLimit.schedule();
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144, 120, 144], 'turning the limit on after a rate change moves an unoffered value');
|
||||
assert.deepStrictEqual(writes, [72, 120, 60, 48], 'turning the limit on after a rate change lowers an unoffered value');
|
||||
settingsStore.clientSettings.gamescope_app_target_framerate = 72;
|
||||
const setSetting = SteamClient.Settings.SetSetting;
|
||||
SteamClient.Settings.SetSetting = () => { throw new Error('busy'); };
|
||||
@@ -87,7 +90,7 @@ const change = async next => { rates = next; notify.forEach(callback => callback
|
||||
SteamClient.Settings.SetSetting = setSetting;
|
||||
window.__droiddeckFrameLimit.schedule();
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144, 120, 144, 144], 'a failed write is tried again on the next check');
|
||||
assert.deepStrictEqual(writes, [72, 120, 60, 48, 48], 'a failed write is tried again on the next check');
|
||||
settingsStore.clientSettings.gamescope_app_target_framerate = 72;
|
||||
SteamClient.Settings.SetSetting = () => Promise.reject(new Error('busy'));
|
||||
window.__droiddeckFrameLimit.schedule();
|
||||
@@ -95,7 +98,18 @@ const change = async next => { rates = next; notify.forEach(callback => callback
|
||||
SteamClient.Settings.SetSetting = setSetting;
|
||||
window.__droiddeckFrameLimit.schedule();
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [144, 120, 144, 144, 144], 'a rejected write is caught and tried again');
|
||||
assert.deepStrictEqual(writes, [72, 120, 60, 48, 48, 48], 'a rejected write is caught and tried again');
|
||||
settingsStore.clientSettings.gamescope_app_target_framerate = 60;
|
||||
await change([33, 55, 165]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [72, 120, 60, 48, 48, 48, 55], 'a 60 fps limit on a panel held at 165 Hz becomes 55, not 165');
|
||||
await change([24, 30, 40, 60, 120]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [72, 120, 60, 48, 48, 48, 55, 60], 'the 60 fps limit returns when 120 Hz is available again');
|
||||
settingsStore.clientSettings.gamescope_app_target_framerate = 20;
|
||||
await change([36, 48, 144]);
|
||||
await fire();
|
||||
assert.deepStrictEqual(writes, [72, 120, 60, 48, 48, 48, 55, 60, 36], 'a limit below every offered rate moves to the lowest one');
|
||||
delete window.__droiddeckFrameLimit;
|
||||
webpackChunksteamui.push = ([, , callback]) => callback(webpack({ 1: modules[1], 2: modules[2] }));
|
||||
assert.strictEqual(eval(script), 'unavailable');
|
||||
@@ -104,7 +118,7 @@ const change = async next => { rates = next; notify.forEach(callback => callback
|
||||
|
||||
|
||||
class FrameLimitSyncTest(unittest.TestCase):
|
||||
def test_limit_is_kept_when_offered_and_moved_to_the_highest_value_otherwise(self):
|
||||
def test_limit_is_kept_when_offered_and_lowered_to_the_nearest_offered_rate_otherwise(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
script = Path(directory) / "frame_limit.js"
|
||||
script.write_text(LIVE["FRAME_LIMIT_JS"])
|
||||
|
||||
Reference in new issue
Block a user