From 42ec2611e3cbe4e4d2cfc7c18036350060d506f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Krac=C3=ADk?= Date: Sun, 7 Jun 2020 14:54:55 +0200 Subject: [PATCH] HID: mouse RAW data --- hidinput.py | 12 ++++++++++++ templates/kvm.html | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/hidinput.py b/hidinput.py index 07e2967..f982c41 100644 --- a/hidinput.py +++ b/hidinput.py @@ -5,6 +5,7 @@ from flask import request from flask_socketio import SocketIO import argparse import json +import struct from hidkeycodes import hidkeycodes from jskeycodes import jscodehidmap @@ -100,6 +101,17 @@ def keyboardIndex(): return render_template("keyboard.html") +@socketio.on('mouseEventRaw') +def handle_mouseEvent(data): + print(data) + + (btn, x, y, wheel) = struct.unpack('BHHb', data) + + print("RAW Btn: {}, X: {}, Y: {}, W: {}".format(btn, x, y, wheel)) + +# hid_mouse_writeabs(btn, x, y, wheel) + + @socketio.on('mouseEvent') def handle_mouseEvent(data): mouseevent = json.loads(data) diff --git a/templates/kvm.html b/templates/kvm.html index 98802a2..126ee91 100644 --- a/templates/kvm.html +++ b/templates/kvm.html @@ -86,8 +86,18 @@ btn: btn, wheel: wheel, } + + var data = new Array(6); + data[0] = btn; + data[1] = x & 255; + data[2] = x >> 8 + data[3] = y & 255; + data[4] = y >> 8 + data[5] = 0; + socket.emit('mouseEvent', JSON.stringify(obj)); + socket.emit('mouseEventRaw', data); };