remove mouse polling interval
This commit is contained in:
parent
2eb0baaca1
commit
e877947824
3 changed files with 5 additions and 48 deletions
File diff suppressed because one or more lines are too long
11
main.go
11
main.go
|
|
@ -43,7 +43,6 @@ const (
|
||||||
authenticationRateLimit time.Duration = time.Second / 10
|
authenticationRateLimit time.Duration = time.Second / 10
|
||||||
authenticationRateBurst int = 10
|
authenticationRateBurst int = 10
|
||||||
challengeLength int = 8
|
challengeLength int = 8
|
||||||
defaultUpdateInterval int = 50
|
|
||||||
defaultBind string = ":0"
|
defaultBind string = ":0"
|
||||||
version string = "0.0.4"
|
version string = "0.0.4"
|
||||||
)
|
)
|
||||||
|
|
@ -128,15 +127,13 @@ func secureRandBase64(length int) string {
|
||||||
func main() {
|
func main() {
|
||||||
var bind, certFile, keyFile, secret string
|
var bind, certFile, keyFile, secret string
|
||||||
var showVersion, invert bool
|
var showVersion, invert bool
|
||||||
var updateInterval int
|
|
||||||
flag.BoolVar(&showVersion, "version", false, "show program's version number and exit")
|
flag.BoolVar(&showVersion, "version", false, "show program's version number and exit")
|
||||||
flag.StringVar(&bind, "bind", defaultBind, "bind server to [IP]:PORT")
|
flag.StringVar(&bind, "bind", defaultBind, "bind server to [HOSTNAME]:PORT")
|
||||||
flag.StringVar(&secret, "secret", "", "shared secret for client authentication")
|
flag.StringVar(&secret, "secret", "", "shared secret for client authentication")
|
||||||
flag.StringVar(&certFile, "cert", "", "file containing TLS certificate")
|
flag.StringVar(&certFile, "cert", "", "file containing TLS certificate")
|
||||||
flag.StringVar(&keyFile, "key", "", "file containing TLS private key")
|
flag.StringVar(&keyFile, "key", "", "file containing TLS private key")
|
||||||
flag.BoolVar(&invert, "invert", false, "use inverse colors for QR code")
|
flag.BoolVar(&invert, "invert", false, "use inverse colors for QR code")
|
||||||
flag.IntVar(&updateInterval, "interval", defaultUpdateInterval,
|
flag.Int("interval", 0, "obsolete, not used anymore")
|
||||||
"mouse polling interval in milliseconds")
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
if showVersion {
|
if showVersion {
|
||||||
fmt.Println(version)
|
fmt.Println(version)
|
||||||
|
|
@ -152,9 +149,6 @@ func main() {
|
||||||
if secret == "" {
|
if secret == "" {
|
||||||
secret = secureRandBase64(defaultSecretLength)
|
secret = secureRandBase64(defaultSecretLength)
|
||||||
}
|
}
|
||||||
if updateInterval < 0 {
|
|
||||||
log.Fatal("interval must be greater or equal to zero")
|
|
||||||
}
|
|
||||||
var plugin Plugin
|
var plugin Plugin
|
||||||
var pluginName string
|
var pluginName string
|
||||||
platformErrors := ""
|
platformErrors := ""
|
||||||
|
|
@ -208,7 +202,6 @@ func main() {
|
||||||
if !challenge.verify(message) {
|
if !challenge.verify(message) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
websocket.Message.Send(ws, fmt.Sprintf("i%d", updateInterval))
|
|
||||||
for {
|
for {
|
||||||
if err := websocket.Message.Receive(ws, &message); err != nil {
|
if err := websocket.Message.Receive(ws, &message); err != nil {
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,6 @@ const MOVE_MULT = 1;
|
||||||
const SCROLL_MULT = 0.05;
|
const SCROLL_MULT = 0.05;
|
||||||
// [[px/s, mult], ...]
|
// [[px/s, mult], ...]
|
||||||
const POINTER_ACCELERATION = [[0, 0], [87, 1], [173, 1], [553, 2]];
|
const POINTER_ACCELERATION = [[0, 0], [87, 1], [173, 1], [553, 2]];
|
||||||
const MAX_IDLE_UPDATES = 10;
|
|
||||||
|
|
||||||
var ws;
|
var ws;
|
||||||
var pad;
|
var pad;
|
||||||
|
|
@ -41,9 +40,6 @@ var scrollXSum = 0;
|
||||||
var scrollYSum = 0;
|
var scrollYSum = 0;
|
||||||
var dragging = false;
|
var dragging = false;
|
||||||
var draggingTimeout = null;
|
var draggingTimeout = null;
|
||||||
var updateTimer = null;
|
|
||||||
var updateInterval = 0;
|
|
||||||
var idleUpdates = 0;
|
|
||||||
|
|
||||||
function fullscreenEnabled() {
|
function fullscreenEnabled() {
|
||||||
return (document.fullscreenEnabled ||
|
return (document.fullscreenEnabled ||
|
||||||
|
|
@ -145,22 +141,11 @@ function onDraggingTimeout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMoveAndScroll() {
|
function updateMoveAndScroll() {
|
||||||
if (updateTimer == null) {
|
|
||||||
onUpdateTimeout();
|
|
||||||
if (updateInterval > 0 && idleUpdates == 0) {
|
|
||||||
updateTimer = setInterval(onUpdateTimeout, updateInterval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onUpdateTimeout() {
|
|
||||||
idleUpdates += 1;
|
|
||||||
var moveX = Math.trunc(moveXSum);
|
var moveX = Math.trunc(moveXSum);
|
||||||
var moveY = Math.trunc(moveYSum);
|
var moveY = Math.trunc(moveYSum);
|
||||||
if (Math.abs(moveX) >= 1 || Math.abs(moveY) >= 1) {
|
if (Math.abs(moveX) >= 1 || Math.abs(moveY) >= 1) {
|
||||||
moveXSum -= moveX;
|
moveXSum -= moveX;
|
||||||
moveYSum -= moveY;
|
moveYSum -= moveY;
|
||||||
idleUpdates = 0;
|
|
||||||
ws.send("m" + moveX + ";" + moveY);
|
ws.send("m" + moveX + ";" + moveY);
|
||||||
}
|
}
|
||||||
var scrollX = Math.trunc(scrollXSum);
|
var scrollX = Math.trunc(scrollXSum);
|
||||||
|
|
@ -168,13 +153,8 @@ function onUpdateTimeout() {
|
||||||
if (Math.abs(scrollX) >= 1 || Math.abs(scrollY) >= 1) {
|
if (Math.abs(scrollX) >= 1 || Math.abs(scrollY) >= 1) {
|
||||||
scrollXSum -= scrollX;
|
scrollXSum -= scrollX;
|
||||||
scrollYSum -= scrollY;
|
scrollYSum -= scrollY;
|
||||||
idleUpdates = 0;
|
|
||||||
ws.send("s" + scrollX + ";" + scrollY);
|
ws.send("s" + scrollX + ";" + scrollY);
|
||||||
}
|
}
|
||||||
if (idleUpdates >= MAX_IDLE_UPDATES) {
|
|
||||||
clearInterval(updateTimer);
|
|
||||||
updateTimer = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleStart(evt) {
|
function handleStart(evt) {
|
||||||
|
|
@ -298,20 +278,6 @@ function challengeResponse(message) {
|
||||||
return btoa(shaObj.getHMAC("BYTES"));
|
return btoa(shaObj.getHMAC("BYTES"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function processCommand(message) {
|
|
||||||
if (message.charAt(0) == "i") {
|
|
||||||
var x = parseInt(message.substr(1));
|
|
||||||
if (isNaN(x) || x.toString() != message.substr(1) || x < 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
updateInterval = x;
|
|
||||||
clearInterval(updateTimer);
|
|
||||||
updateTimer = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
window.addEventListener("load", function() {
|
window.addEventListener("load", function() {
|
||||||
var authenticated = false;
|
var authenticated = false;
|
||||||
var opening = document.getElementById("opening");
|
var opening = document.getElementById("opening");
|
||||||
|
|
@ -336,9 +302,7 @@ window.addEventListener("load", function() {
|
||||||
|
|
||||||
ws.onmessage = function(event) {
|
ws.onmessage = function(event) {
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
if (!processCommand(event.data)) {
|
ws.close();
|
||||||
ws.close();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
authenticated = true;
|
authenticated = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue