Improve slider input
This commit is contained in:
parent
eac9f95ed7
commit
d023f42ac5
1 changed files with 44 additions and 1 deletions
|
@ -141,6 +141,12 @@
|
|||
selectNotch(ROOT_ID, await getCPUs() - 1, 8);
|
||||
}
|
||||
|
||||
async function onSlideCPUNotch(e) {
|
||||
const ROOT_ID = "cpuThreadsNotch";
|
||||
let closest = closestNotch(e, ROOT_ID, 8);
|
||||
await setCPUNotch(closest);
|
||||
}
|
||||
|
||||
const TOGGLE_ON_CLASS = "gamepaddialog_On_3ld7T";
|
||||
|
||||
function setToggleState(toggle, state) {
|
||||
|
@ -185,12 +191,24 @@
|
|||
selectNotch(ROOT_ID, await getMaxBoost(), 3);
|
||||
}
|
||||
|
||||
async function onSlideBoostNotch(e) {
|
||||
const ROOT_ID = "frequencyNotch";
|
||||
let closest = closestNotch(e, ROOT_ID, 8);
|
||||
await setBoostNotch(closest);
|
||||
}
|
||||
|
||||
async function onSetFanNotch(index) {
|
||||
const ROOT_ID = "fanNotch";
|
||||
await setFanTick(index);
|
||||
selectNotch(ROOT_ID, index, 8);
|
||||
}
|
||||
|
||||
async function onSlideFanNotch(e) {
|
||||
const ROOT_ID = "fanNotch";
|
||||
let closest = closestNotch(e, ROOT_ID, 8);
|
||||
await onSetFanNotch(closest);
|
||||
}
|
||||
|
||||
async function onReadyGPU() {
|
||||
let power1_cap = await getGPUPower(1);
|
||||
let power2_cap = await getGPUPower(2);
|
||||
|
@ -228,6 +246,12 @@
|
|||
selectNotch(ROOT_ID, index, 3);
|
||||
}
|
||||
|
||||
async function onSlideSlowPPTNotch(e) {
|
||||
const ROOT_ID = "slowPPTNotch";
|
||||
let closest = closestNotch(e, ROOT_ID, 3);
|
||||
onSetSlowPPTNotch(closest);
|
||||
}
|
||||
|
||||
async function onSetFastPPTNotch(index) {
|
||||
const ROOT_ID = "fastPPTNotch";
|
||||
document.getElementById("fastPPTAutoDefault").innerText = "Default";
|
||||
|
@ -241,6 +265,12 @@
|
|||
selectNotch(ROOT_ID, index, 3);
|
||||
}
|
||||
|
||||
async function onSlideFastPPTNotch(e) {
|
||||
const ROOT_ID = "fastPPTNotch";
|
||||
let closest = closestNotch(e, ROOT_ID, 3);
|
||||
await onSetFastPPTNotch(closest);
|
||||
}
|
||||
|
||||
function selectNotch(rootId, index, elements) {
|
||||
// WARNING: this yeets any style in div of slider
|
||||
const ENABLED_CLASS = "gamepadslider_TickActive_1gnUV";
|
||||
|
@ -257,6 +287,19 @@
|
|||
}
|
||||
}
|
||||
|
||||
function closestNotch(e, rootId, elements) {
|
||||
let root = document.getElementById(rootId);
|
||||
let val = e.x / root.scrollWidth;
|
||||
let closest_notch = Math.round(val * elements);
|
||||
if (closest_notch > elements) {
|
||||
closest_notch = elements;
|
||||
} else if (closest_notch < 0) {
|
||||
closest_notch = 0;
|
||||
}
|
||||
return closest_notch
|
||||
//selectNotch(closest_notch);
|
||||
}
|
||||
|
||||
async function updateBatteryStats() {
|
||||
//console.log("Updating battery stats");
|
||||
let batCapacityNow = document.getElementById("batCapacityNow");
|
||||
|
@ -330,7 +373,7 @@
|
|||
<div class="gamepaddialog_FieldLabelRow_H9WOq">
|
||||
<div class="gamepaddialog_FieldLabel_3b0U-">Threads</div>
|
||||
</div>
|
||||
<div id="cpuThreadsNotch" class="gamepadslider_SliderControlAndNotches_1Cccx Focusable" tabindex="0" style="--normalized-slider-value:0.5;">
|
||||
<div id="cpuThreadsNotch" class="gamepadslider_SliderControlAndNotches_1Cccx Focusable" tabindex="0" style="--normalized-slider-value:0.5;" onmousemove="onSlideCPUNotch(event)">
|
||||
<div class="gamepadslider_SliderControl_3o137">
|
||||
<div class="gamepadslider_SliderTrack_Mq25N gamepadslider_SliderHasNotches_2XiAy "></div>
|
||||
<div class="gamepadslider_SliderHandleContainer_1pQZi">
|
||||
|
|
Loading…
Reference in a new issue