mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 14:26:00 +00:00
fix: stop stale Android readbacks snapping Steam's brightness slider back (#1731)
* fix: stop stale Android readbacks snapping Steam's brightness slider back during a held stick * fix: let deploy_fast sign with the release env on macOS and Linux * fix: honor DROIDDECK_SIGNING_ENV first and cover the env signer in tests * fix: honor DROIDDECK_SIGNING_ENV first and cover the env signer in tests * fix: retry held brightness readbacks, use a monotonic hold clock and resolve the signing env path * fix: resolve the build-tools path before signing changes directory * fix: pick the newest build-tools numerically and keep the env file from replacing them * fix: only pick build-tools that have aapt, zipalign and apksigner
This commit is contained in:
1 parent
6469a7693c
commit
52fa41767c
4 files changed
+149
-6
No files matched your search
@@ -23,15 +23,20 @@ BRIGHTNESS_JS = r"""
|
||||
if (window.__droiddeckBrightness) return "present";
|
||||
const display = SteamClient.System?.Display;
|
||||
if (!display?.RegisterForBrightnessChanges || !display?.SetBrightness) return "unavailable";
|
||||
const self = { expected: null, updating: true, revision: 0 };
|
||||
const self = { expected: null, updating: true, revision: 0, localAt: -Infinity };
|
||||
// A held stick steps Steam faster than Android's readback returns; those stale readbacks would snap the slider back.
|
||||
const HOLD_MS = 750;
|
||||
// Returns "held" while a readback is being ignored, so the caller retries it after the hold.
|
||||
self.set = value => {
|
||||
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) return;
|
||||
if (!self.updating && self.expected !== null && Math.abs(value - self.expected) < 0.0001) return;
|
||||
if (typeof value !== "number" || !Number.isFinite(value) || value < 0 || value > 1) return true;
|
||||
if (performance.now() - self.localAt < HOLD_MS) return "held";
|
||||
if (!self.updating && self.expected !== null && Math.abs(value - self.expected) < 0.0001) return true;
|
||||
self.expected = value;
|
||||
self.updating = true;
|
||||
const revision = ++self.revision;
|
||||
setTimeout(() => { if (self.revision === revision) self.updating = false; }, 500);
|
||||
display.SetBrightness(value);
|
||||
return true;
|
||||
};
|
||||
self.subscription = display.RegisterForBrightnessChanges(state => {
|
||||
const value = state?.flBrightness;
|
||||
@@ -39,6 +44,7 @@ BRIGHTNESS_JS = r"""
|
||||
if (Math.abs(value - self.expected) < 0.0001) { self.updating = false; return; }
|
||||
if (self.updating) { self.updating = false; return; }
|
||||
self.expected = value;
|
||||
self.localAt = performance.now();
|
||||
if (typeof window.__BINDING__ === "function") window.__BINDING__(String(value));
|
||||
});
|
||||
window.__droiddeckBrightness = self;
|
||||
@@ -764,9 +770,10 @@ class Helper:
|
||||
if not self.controls_installed:
|
||||
return
|
||||
if state != self.controls_state:
|
||||
if self.page.evaluate("!!window.__droiddeckBrightness && (window.__droiddeckBrightness.set(%s), true)" % json.dumps(value)) is True:
|
||||
applied = self.page.evaluate("window.__droiddeckBrightness ? window.__droiddeckBrightness.set(%s) : false" % json.dumps(value))
|
||||
if applied is True:
|
||||
self.controls_state = state
|
||||
else:
|
||||
elif applied != "held":
|
||||
self.controls_installed = False
|
||||
self.controls_state = None
|
||||
except (OSError, ValueError, TypeError):
|
||||
|
||||
Reference in new issue
Block a user