120 lines
5.1 KiB
HTML
120 lines
5.1 KiB
HTML
<html>
|
|
<head>
|
|
<link rel="stylesheet" href="/steam_resource/css/2.css">
|
|
<link rel="stylesheet" href="/steam_resource/css/39.css">
|
|
<link rel="stylesheet" href="/steam_resource/css/library.css">
|
|
<script src="/static/library.js"></script>
|
|
<script>
|
|
// Python functions
|
|
function setCPUs(value) {
|
|
return call_plugin_method("set_cpus", {"count":value});
|
|
}
|
|
|
|
function getCPUs() {
|
|
return call_plugin_method("get_cpus", {});
|
|
}
|
|
|
|
function setCPUBoost(value) {
|
|
return call_plugin_method("set_boost", {"enabled": value});
|
|
}
|
|
|
|
function getCPUBoost() {
|
|
return call_plugin_method("get_boost", {});
|
|
}
|
|
|
|
// other logic
|
|
|
|
async function onSetCPUs() {
|
|
let target = document.getElementById("cpu_threads");
|
|
let ok = await setCPUs(target.value);
|
|
target.value = await getCPUs();
|
|
}
|
|
|
|
async function onReady() {
|
|
document.getElementById("cpu_threads").value = await getCPUs();
|
|
let boostToggle = document.getElementById("boostToggle");
|
|
setToggleState(boostToggle, await getCPUBoost());
|
|
}
|
|
|
|
async function decrementCPUs() {
|
|
let target = document.getElementById("cpu_threads");
|
|
if (target.value >= 2) {
|
|
target.value -= 1;
|
|
}
|
|
await onSetCPUs();
|
|
}
|
|
|
|
async function incrementCPUs() {
|
|
let target = document.getElementById("cpu_threads");
|
|
if (target.value <= 7) {
|
|
target.value += 1;
|
|
}
|
|
await onSetCPUs();
|
|
}
|
|
|
|
async function resetCPUs() {
|
|
let target = document.getElementById("cpu_threads");
|
|
target.value = 8;
|
|
await onSetCPUs();
|
|
}
|
|
|
|
function setToggleState(toggle, state) {
|
|
const ENABLED_CLASS = "gamepaddialog_On_yLrDA";
|
|
if (state && !toggle.classList.contains(ENABLED_CLASS)) {
|
|
toggle.classList.add(ENABLED_CLASS);
|
|
}
|
|
|
|
if (!state && toggle.classList.contains(ENABLED_CLASS)) {
|
|
toggle.classList.remove(ENABLED_CLASS);
|
|
}
|
|
}
|
|
|
|
function getToggleState(toggle) {
|
|
return toggle.classList.contains("gamepaddialog_On_yLrDA");
|
|
}
|
|
|
|
async function toggleCPUBoost() {
|
|
let toggle = document.getElementById("boostToggle");
|
|
let isActive = getToggleState(toggle);
|
|
await setCPUBoost(!isActive);
|
|
setToggleState(toggle, await getCPUBoost());
|
|
}
|
|
|
|
</script>
|
|
<style type="text/css" media="screen">
|
|
input::-webkit-outer-spin-button,
|
|
input::-webkit-inner-spin-button {
|
|
-webkit-appearance: none;
|
|
margin: 0;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body onload="onReady()">
|
|
<div>
|
|
<label for="cpu_threads">Online CPUs</label>
|
|
<input type="number" id="cpu_threads" name="cpu_threads" min="1" max="8">
|
|
<button type="button" onclick="incrementCPUs()">/\</button>
|
|
<button type="button" onclick="decrementCPUs()">\/</button>
|
|
<button type="button" onclick="resetCPUs()">Reset</button>
|
|
</div>
|
|
<!-- Toggle switch, roughly copied from https://github.com/SteamDeckHomebrew/ExtraSettingsPlugin/blob/main/main_view.html -->
|
|
<div class="quickaccessmenu_TabGroupPanel_1QO7b Panel Focusable">
|
|
<div class="quickaccesscontrols_PanelSectionRow_26R5w">
|
|
<div class="quickaccesscontrols_PanelSectionRow_26R5w">
|
|
<div class="gamepaddialog_Field_eKmEX gamepaddialog_WithFirstRow_2bDqk gamepaddialog_WithBottomSeparator_3YKpU gamepaddialog_ExtraPaddingOnChildrenBelow_3nLNL gamepaddialog_StandardPadding_xIITX gamepaddialog_HighlightOnFocus_2HFrm Panel Focusable" style="--indent-level:0;">
|
|
<div class="gamepaddialog_FieldLabelRow_2VcTl">
|
|
<div class="gamepaddialog_FieldLabel_3jMlJ">
|
|
CPU Boost
|
|
</div>
|
|
<div class="gamepaddialog_FieldChildren_2rhav">
|
|
<div id="boostToggle" tabindex="0" class="gamepaddialog_Toggle_9Ql-o Focusable" onclick="toggleCPUBoost()">
|
|
<div class="gamepaddialog_ToggleRail_2bl0i"></div>
|
|
<div class="gamepaddialog_ToggleSwitch_1PQpp"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|