Kbd Hid: FIX MOD meta act as 'e' char
This commit is contained in:
parent
05b97b0d8c
commit
bd776abe91
11
hidinput.py
11
hidinput.py
@ -46,7 +46,7 @@ def hid_mouse_write(btn, x, y, wheel):
|
|||||||
hidmouse.flush()
|
hidmouse.flush()
|
||||||
|
|
||||||
|
|
||||||
def send_key(hidkey, shift, alt, ctlr):
|
def send_key(hidkey, shift, alt, ctlr, mod):
|
||||||
data = bytearray(8)
|
data = bytearray(8)
|
||||||
if shift:
|
if shift:
|
||||||
data[0] += hidkeycodes['KEY_MOD_LSHIFT']
|
data[0] += hidkeycodes['KEY_MOD_LSHIFT']
|
||||||
@ -55,7 +55,7 @@ def send_key(hidkey, shift, alt, ctlr):
|
|||||||
if ctlr:
|
if ctlr:
|
||||||
data[0] += hidkeycodes['KEY_MOD_LCTRL']
|
data[0] += hidkeycodes['KEY_MOD_LCTRL']
|
||||||
|
|
||||||
if hidkey == hidkeycodes['KEY_MOD_LMETA'] or hidkey == hidkeycodes['KEY_MOD_RMETA']:
|
if mod and (hidkey == hidkeycodes['KEY_MOD_LMETA'] or hidkey == hidkeycodes['KEY_MOD_RMETA']):
|
||||||
data[0] += hidkey
|
data[0] += hidkey
|
||||||
hidkey=0
|
hidkey=0
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ def get_hid_by_jscode(rawkeycode):
|
|||||||
|
|
||||||
print ("JS key: {} HID key: {}({})".format(rawkeycode, hidkeyname, hidkeycode))
|
print ("JS key: {} HID key: {}({})".format(rawkeycode, hidkeyname, hidkeycode))
|
||||||
|
|
||||||
return hidkeycode
|
return hidkeycode, (hidkeyname is not None and "MOD" in hidkeyname)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def index():
|
def index():
|
||||||
@ -117,7 +117,7 @@ def keypress():
|
|||||||
print ("Raw data: {}".format(request.data))
|
print ("Raw data: {}".format(request.data))
|
||||||
|
|
||||||
rawkeycode = keyevent['code']
|
rawkeycode = keyevent['code']
|
||||||
hidkeycode = get_hid_by_jscode(rawkeycode)
|
hidkeycode, mod = get_hid_by_jscode(rawkeycode)
|
||||||
|
|
||||||
if hidkeycode is not None:
|
if hidkeycode is not None:
|
||||||
try:
|
try:
|
||||||
@ -125,7 +125,8 @@ def keypress():
|
|||||||
hidkeycode,
|
hidkeycode,
|
||||||
keyevent['shiftKey'],
|
keyevent['shiftKey'],
|
||||||
keyevent['altKey'],
|
keyevent['altKey'],
|
||||||
keyevent['ctrlKey'])
|
keyevent['ctrlKey'],
|
||||||
|
mod)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error sending HID message", e)
|
print("Error sending HID message", e)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user