HID: change POST to socketio
This commit is contained in:
parent
44d01c0127
commit
beaad49558
12
hidinput.py
12
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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user