mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
client-side for mouse wheel
This commit is contained in:
parent
2a6883064d
commit
1f02b77f66
@ -145,9 +145,8 @@ class Server: # pylint: disable=too-many-instance-attributes
|
||||
if key and state in [True, False]:
|
||||
await self.__hid.send_key_event(key, state)
|
||||
continue
|
||||
elif event.get("event_type") in ["mouse_move", "mouse_button"]:
|
||||
elif event.get("event_type") in ["mouse_move", "mouse_button", "mouse_wheel"]:
|
||||
pass
|
||||
# logger.info("Mouse event: %s", event) # TODO
|
||||
else:
|
||||
logger.error("Invalid websocket event: %r", event)
|
||||
await ws.send_str(json.dumps({"msg_type": "echo", "msg": msg.data}))
|
||||
|
||||
@ -47,8 +47,8 @@ function __installHidHandlers(ws) {
|
||||
el_stream_image.onmouseup = (event) => __onMouseButton(ws, event, false);
|
||||
el_stream_image.oncontextmenu = (event) => event.preventDefault();
|
||||
el_stream_image.onmousemove = __onMouseMove;
|
||||
runKvmdSession.mouse_timer_id = setInterval(() => __handleMouseMove(ws), 100);
|
||||
// TODO: https://learn.javascript.ru/mousewheel
|
||||
el_stream_image.onwheel = (event) => __onMouseWheel(ws, event);
|
||||
runKvmdSession.mouse_move_timer = setInterval(() => __handleMouseMove(ws), 100);
|
||||
}
|
||||
|
||||
function __clearHidHandlers() {
|
||||
@ -60,7 +60,8 @@ function __clearHidHandlers() {
|
||||
el_stream_image.onmouseup = null;
|
||||
el_stream_image.oncontextmenu = null;
|
||||
el_stream_image.onmousemove = null;
|
||||
clearInterval(runKvmdSession.mouse_timer_id);
|
||||
el_stream_image.onwheel = null;
|
||||
clearInterval(runKvmdSession.mouse_move_timer);
|
||||
}
|
||||
|
||||
function __onKeyEvent(ws, event, state) {
|
||||
@ -115,6 +116,20 @@ function __handleMouseMove(ws) {
|
||||
}
|
||||
__handleMouseMove.old_pos = {x: 0, y:0};
|
||||
|
||||
function __onMouseWheel(ws, event) {
|
||||
// https://learn.javascript.ru/mousewheel
|
||||
if (event.preventDefault) {
|
||||
event.preventDefault();
|
||||
}
|
||||
ws.send(JSON.stringify({
|
||||
event_type: "mouse_wheel",
|
||||
delta: {
|
||||
x: event.deltaX,
|
||||
y: event.deltaY,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function clickPowerButton() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user