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

View File

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

View File

@ -39,7 +39,6 @@ $(document).ready(function(){
});
$("canvas").mousemove(function(event){
// sendMouse(0, event.originalEvent.movementX, event.originalEvent.movementY);
posX=event.offsetX;
posY=event.offsetY;
handleMouse();
@ -65,7 +64,7 @@ function sendMouse(btn, x, y) {
</script>
<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");' />-->
</body>
</html>