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')
|
@socketio.on('mouseEvent')
|
||||||
def handle_my_custom_event(data):
|
def handle_mouseEvent(data):
|
||||||
mouseevent = json.loads(data)
|
mouseevent = json.loads(data)
|
||||||
print(mouseevent)
|
print(mouseevent)
|
||||||
btn = mouseevent['btn']
|
btn = mouseevent['btn']
|
||||||
@ -115,10 +115,10 @@ def handle_my_custom_event(data):
|
|||||||
hid_mouse_writeabs(btn, x, y, wheel)
|
hid_mouse_writeabs(btn, x, y, wheel)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/hid/keyboard", methods=["POST"])
|
@socketio.on('kbdEvent')
|
||||||
def keypress():
|
def handle_kbdEvent(data):
|
||||||
keyevent = json.loads(request.data)
|
keyevent = json.loads(data)
|
||||||
print("Raw data: {}".format(request.data))
|
print("Raw data: {}".format(data))
|
||||||
|
|
||||||
rawkeycode = keyevent['code']
|
rawkeycode = keyevent['code']
|
||||||
hidkeycode, mod = get_hid_by_jscode(rawkeycode)
|
hidkeycode, mod = get_hid_by_jscode(rawkeycode)
|
||||||
@ -134,8 +134,6 @@ def keypress():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error sending HID message", e)
|
print("Error sending HID message", e)
|
||||||
|
|
||||||
return Response("Press {}".format(hidkeycode), mimetype="text/plain")
|
|
||||||
|
|
||||||
|
|
||||||
hid_init()
|
hid_init()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user