HID: mouse over socketio

This commit is contained in:
Petr Kracik 2020-06-05 16:42:23 +02:00
parent 12644f1e39
commit deb2139d96
3 changed files with 7 additions and 6 deletions

View File

@ -21,7 +21,6 @@ hiddev = None
hidmouse = None hidmouse = None
hidmouseabs = None hidmouseabs = None
hid_init()
def hid_init(): def hid_init():
global hiddev, hidmouse, hidmouseabs global hiddev, hidmouse, hidmouseabs
@ -146,8 +145,8 @@ def mouseabs():
@socketio.on('mouseEvent') @socketio.on('mouseEvent')
def handle_my_custom_event(json): def handle_my_custom_event(data):
mouseevent = json.loads(json) mouseevent = json.loads(data)
print(mouseevent) print(mouseevent)
btn = mouseevent['btn'] btn = mouseevent['btn']
x = mouseevent['x'] x = mouseevent['x']
@ -180,6 +179,7 @@ def keypress():
return Response("Press {}".format(hidkeycode), mimetype="text/plain") return Response("Press {}".format(hidkeycode), mimetype="text/plain")
hid_init()
# check to see if this is the main thread of execution # check to see if this is the main thread of execution
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -12,6 +12,8 @@
<div> <div>
</div> </div>
<input type=text />
<br/> <br/>
Server response: <span></span> Server response: <span></span>
@ -78,4 +80,4 @@ $(window).bind('keydown', function(event) {
</script> </script>
</body> </body>
</html> </html>

View File

@ -39,7 +39,6 @@ $(document).ready(function(){
}); });
$("canvas").mousemove(function(event){ $("canvas").mousemove(function(event){
// sendMouse(0, event.originalEvent.movementX, event.originalEvent.movementY);
posX=event.offsetX; posX=event.offsetX;
posY=event.offsetY; posY=event.offsetY;
handleMouse(); handleMouse();
@ -65,7 +64,7 @@ function sendMouse(btn, x, y) {
</script> </script>
<span></span><br/><br/> <span></span><br/><br/>
<canvas width=500 height=500 style="border: 1px solid black" oncontextmenu="return false"></canvas> <canvas width=1920 height=1080 style="border: 1px solid black" oncontextmenu="return false"></canvas>
<!--<img src="placeholder.png" width=1920 height=1080 onmousemove='console.log("aaa");' />--> <!--<img src="placeholder.png" width=1920 height=1080 onmousemove='console.log("aaa");' />-->
</body> </body>
</html> </html>