diff --git a/hidinput.py b/hidinput.py index 21835d6..07e2967 100644 --- a/hidinput.py +++ b/hidinput.py @@ -101,7 +101,7 @@ def keyboardIndex(): @socketio.on('mouseEvent') -def handle_my_custom_event(data): +def handle_mouseEvent(data): mouseevent = json.loads(data) print(mouseevent) btn = mouseevent['btn'] @@ -115,10 +115,10 @@ def handle_my_custom_event(data): hid_mouse_writeabs(btn, x, y, wheel) -@app.route("/hid/keyboard", methods=["POST"]) -def keypress(): - keyevent = json.loads(request.data) - print("Raw data: {}".format(request.data)) +@socketio.on('kbdEvent') +def handle_kbdEvent(data): + keyevent = json.loads(data) + print("Raw data: {}".format(data)) rawkeycode = keyevent['code'] hidkeycode, mod = get_hid_by_jscode(rawkeycode) @@ -134,8 +134,6 @@ def keypress(): except Exception as e: print("Error sending HID message", e) - return Response("Press {}".format(hidkeycode), mimetype="text/plain") - hid_init()