HID: mouse RAW data

This commit is contained in:
Petr Kracík 2020-06-07 14:54:55 +02:00
parent beaad49558
commit 42ec2611e3
2 changed files with 22 additions and 0 deletions

View File

@ -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)

View File

@ -87,7 +87,17 @@
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);
};
</script>
</head>