diff options
author | Maxim Devaev <[email protected]> | 2021-09-27 14:51:54 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2021-09-27 14:51:54 +0300 |
commit | 9f9396a8104e56bc95a66fcef4a45b3938b86e7c (patch) | |
tree | 7e6f963dee80bc3dc5bdc9167152b10309d24fc9 /web | |
parent | 67b67f6cbc820dbc233599d9ccafeded785879ac (diff) |
configurable mouse polling rate
Diffstat (limited to 'web')
-rw-r--r-- | web/kvm/index.html | 7 | ||||
-rw-r--r-- | web/kvm/navbar-system.pug | 4 | ||||
-rw-r--r-- | web/share/js/kvm/mouse.js | 18 |
3 files changed, 28 insertions, 1 deletions
diff --git a/web/kvm/index.html b/web/kvm/index.html index 09ad0f71..9b9a4a9b 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -190,6 +190,13 @@ </table> </div> <table class="kv"> + <tr> + <td>Mouse polling rate:</td> + <td> + <input class="slider" type="range" id="hid-mouse-rate-slider"> + </td> + <td class="value" id="hid-mouse-rate-value" style="min-width: 30px; max-width:30px"></td> + </tr> <tr class="feature-disabled" id="hid-mouse-sens"> <td>Relative mouse sensitivity:</td> <td> diff --git a/web/kvm/navbar-system.pug b/web/kvm/navbar-system.pug index db6ddb3d..20a92c03 100644 --- a/web/kvm/navbar-system.pug +++ b/web/kvm/navbar-system.pug @@ -55,6 +55,10 @@ li(class="right") td Mouse #[a(target="_blank" href="https://github.com/pikvm/pikvm/blob/master/pages/mouse.md") mode]: td #[div(id="hid-outputs-mouse-box" class="radio-box")] table(class="kv") + tr + td Mouse polling rate: + td #[input(type="range" id="hid-mouse-rate-slider" class="slider")] + td(id="hid-mouse-rate-value" class="value" style="min-width: 30px; max-width:30px") tr(id="hid-mouse-sens" class="feature-disabled") td Relative mouse sensitivity: td #[input(disabled type="range" id="hid-mouse-sens-slider" class="slider")] diff --git a/web/share/js/kvm/mouse.js b/web/share/js/kvm/mouse.js index 7a0a50f3..7fc58905 100644 --- a/web/share/js/kvm/mouse.js +++ b/web/share/js/kvm/mouse.js @@ -38,6 +38,7 @@ export function Mouse(__getResolution, __recordWsEvent) { var __keypad = null; + var __timer = null; var __current_pos = {x: 0, y: 0}; var __sent_pos = {x: 0, y: 0}; var __wheel_delta = {x: 0, y: 0}; @@ -62,6 +63,11 @@ export function Mouse(__getResolution, __recordWsEvent) { $("stream-box").onwheel = __streamWheelHandler; $("stream-box").ontouchstart = (event) => __streamTouchMoveHandler(event); + let rate_slider = $("hid-mouse-rate-slider"); + tools.slider.setParams(rate_slider, 10, 100, 10, 100); + rate_slider.oninput = rate_slider.onchange = __updateRate; + rate_slider.value = tools.storage.get("hid.mouse.rate", 100); + let sens_slider = $("hid-mouse-sens-slider"); tools.slider.setParams(sens_slider, 0.1, 1.9, 0.1, 1); sens_slider.oninput = sens_slider.onchange = __updateRelativeSens; @@ -70,7 +76,7 @@ export function Mouse(__getResolution, __recordWsEvent) { tools.storage.bindSimpleSwitch($("hid-mouse-squash-switch"), "hid.mouse.squash", true); - setInterval(__sendMove, 100); + __updateRate(); // set __timer }; /************************************************************************/ @@ -104,6 +110,16 @@ export function Mouse(__getResolution, __recordWsEvent) { __keypad.releaseAll(); }; + var __updateRate = function() { + let rate = parseInt($("hid-mouse-rate-slider").value); + $("hid-mouse-rate-value").innerHTML = rate; + tools.storage.set("hid.mouse.rate", rate); + if (__timer) { + clearInterval(__timer); + } + __timer = setInterval(__sendMove, rate); + }; + var __updateRelativeSens = function() { __relative_sens = parseFloat($("hid-mouse-sens-slider").value); $("hid-mouse-sens-value").innerHTML = __relative_sens.toFixed(1); |