overlay send events over WS if not connected.

This commit is contained in:
Miroslav Šedivý 2022-07-23 14:05:29 +02:00
parent 4b2c03b88d
commit 84708c77d2

View File

@ -150,7 +150,12 @@
const isCtrlKey = key == KeyTable.XK_Control_L || key == KeyTable.XK_Control_R
if (isCtrlKey) ctrlKey = key
if (this.webrtc.connected) {
this.webrtc.send('keydown', { key })
} else {
this.control.keyDown(key)
}
return isCtrlKey
}
this.keyboard.onkeyup = (key: number) => {
@ -164,7 +169,11 @@
const isCtrlKey = key == KeyTable.XK_Control_L || key == KeyTable.XK_Control_R
if (isCtrlKey) ctrlKey = 0
if (this.webrtc.connected) {
this.webrtc.send('keyup', { key })
} else {
this.control.keyUp(key)
}
}
this.keyboard.listenTo(this._textarea)
@ -244,8 +253,6 @@
return
}
this.sendMousePos(e)
const now = Date.now()
const firstScroll = now - this.wheelDate > 250
@ -292,8 +299,14 @@
}
}
if (x != 0 || y != 0) {
// skip if not scrolled
if (x == 0 && y == 0) return
if (this.webrtc.connected) {
this.sendMousePos(e)
this.webrtc.send('wheel', { x, y })
} else {
this.control.scroll(x, y)
}
}
@ -313,8 +326,14 @@
return
}
const key = e.button + 1
if (this.webrtc.connected) {
this.sendMousePos(e)
this.webrtc.send('mousedown', { key: e.button + 1 })
this.webrtc.send('mousedown', { key })
} else {
const { x, y } = this.getMousePos(e.clientX, e.clientY)
this.control.buttonDown(key, x, y)
}
}
onMouseUp(e: MouseEvent) {
@ -323,8 +342,14 @@
return
}
const key = e.button + 1
if (this.webrtc.connected) {
this.sendMousePos(e)
this.webrtc.send('mouseup', { key: e.button + 1 })
this.webrtc.send('mouseup', { key })
} else {
const { x, y } = this.getMousePos(e.clientX, e.clientY)
this.control.buttonUp(key, x, y)
}
}
onMouseEnter(e: MouseEvent) {