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 from flask_socketio import SocketIO
import argparse import argparse
import json import json
import struct
from hidkeycodes import hidkeycodes from hidkeycodes import hidkeycodes
from jskeycodes import jscodehidmap from jskeycodes import jscodehidmap
@ -100,6 +101,17 @@ def keyboardIndex():
return render_template("keyboard.html") 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') @socketio.on('mouseEvent')
def handle_mouseEvent(data): def handle_mouseEvent(data):
mouseevent = json.loads(data) mouseevent = json.loads(data)

View File

@ -86,8 +86,18 @@
btn: btn, btn: btn,
wheel: wheel, 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('mouseEvent', JSON.stringify(obj));
socket.emit('mouseEventRaw', data);
}; };
</script> </script>
</head> </head>