optional relative squashing

This commit is contained in:
Devaev Maxim 2020-11-07 05:55:34 +03:00
parent afcd6408bb
commit b83ba7692a
4 changed files with 49 additions and 19 deletions

View File

@ -143,16 +143,30 @@
</div> </div>
</div> </div>
<hr> <hr>
<div class="text"> <div class="text">
<table class="one-line-switch"> <table class="one-line-switch">
<td>Auto-resize stream:</td> <td>Auto-resize stream:</td>
<td align="right"> <td align="right">
<div class="switch-box"> <div class="switch-box">
<input checked type="checkbox" id="stream-auto-resize-checkbox"> <input checked type="checkbox" id="stream-auto-resize-checkbox">
<label for="stream-auto-resize-checkbox"><span class="switch-inner"></span><span class="switch"></span></label> <label for="stream-auto-resize-checkbox"><span class="switch-inner"></span><span class="switch"></span></label>
</div>
</td>
</table>
</div>
<div class="feature-disabled" id="mouse-squash">
<hr>
<div class="text">
<table class="one-line-switch">
<td>Squash mouse moves:</td>
<td align="right">
<div class="switch-box">
<input checked type="checkbox" id="mouse-squash-checkbox">
<label for="mouse-squash-checkbox"><span class="switch-inner"></span><span class="switch"></span></label>
</div>
</td>
</table>
</div> </div>
</td>
</table>
</div> </div>
<hr> <hr>
<div class="buttons"> <div class="buttons">

View File

@ -35,15 +35,10 @@ li(class="right")
div(class="stream-param-box") div(class="stream-param-box")
input(type="range" id="stream-size-slider" class="slider") input(type="range" id="stream-size-slider" class="slider")
hr hr
div(class="text") +menu_switch("stream-auto-resize-checkbox", "Auto-resize stream")
table(class="one-line-switch") div(id="mouse-squash" class="feature-disabled")
td Auto-resize stream: hr
td(align="right") +menu_switch("mouse-squash-checkbox", "Squash mouse moves")
div(class="switch-box")
input(checked type="checkbox" id="stream-auto-resize-checkbox")
label(for="stream-auto-resize-checkbox")
span(class="switch-inner")
span(class="switch")
hr hr
div(class="buttons") div(class="buttons")
button(disabled data-force-hide-menu id="stream-reset-button") &bull; Reset stream button(disabled data-force-hide-menu id="stream-reset-button") &bull; Reset stream

View File

@ -13,6 +13,17 @@ mixin menu_message(icon, short, classes="")
sup(style="line-height:1") sup(style="line-height:1")
block block
mixin menu_switch(id, title)
div(class="text")
table(class="one-line-switch")
td #{title}:
td(align="right")
div(class="switch-box")
input(checked type="checkbox" id=id)
label(for=id)
span(class="switch-inner")
span(class="switch")
ul(id="navbar") ul(id="navbar")
li(class="left") li(class="left")
a(id="logo" href="/") &larr;&nbsp;&nbsp; a(id="logo" href="/") &larr;&nbsp;&nbsp;

View File

@ -88,6 +88,7 @@ export function Mouse(record_callback) {
if (__absolute && !state.absolute) { if (__absolute && !state.absolute) {
__relative_deltas = []; __relative_deltas = [];
} }
tools.featureSetEnabled($("mouse-squash"), !state.absolute);
__absolute = state.absolute; __absolute = state.absolute;
__updateOnlineLeds(); __updateOnlineLeds();
}; };
@ -136,6 +137,10 @@ export function Mouse(record_callback) {
return (document.pointerLockElement === $("stream-box")); return (document.pointerLockElement === $("stream-box"));
}; };
var __isRelativeSquashed = function() {
return $("mouse-squash-checkbox").checked;
};
var __relativeCapturedHandler = function() { var __relativeCapturedHandler = function() {
tools.info("Relative mouse", (__isRelativeCaptured() ? "captured" : "released"), "by pointer lock"); tools.info("Relative mouse", (__isRelativeCaptured() ? "captured" : "released"), "by pointer lock");
__updateOnlineLeds(); __updateOnlineLeds();
@ -183,7 +188,12 @@ export function Mouse(record_callback) {
x: Math.min(Math.max(-127, event.movementX), 127), x: Math.min(Math.max(-127, event.movementX), 127),
y: Math.min(Math.max(-127, event.movementY), 127), y: Math.min(Math.max(-127, event.movementY), 127),
}; };
__relative_deltas.push(delta); if (__isRelativeSquashed()) {
__relative_deltas.push(delta);
} else {
tools.debug("Mouse: relative:", delta);
__sendEvent("mouse_relative", {"delta": delta});
}
} }
}; };