Kbd Hid: Replaced chr to bytearray
This commit is contained in:
parent
bd2540cbc0
commit
05b97b0d8c
21
hidinput.py
21
hidinput.py
@ -17,7 +17,6 @@ lock = threading.Lock()
|
||||
# initialize a flask object
|
||||
app = Flask(__name__)
|
||||
|
||||
NULL = chr(0)
|
||||
hiddev = None
|
||||
hidmouse = None
|
||||
|
||||
@ -30,7 +29,7 @@ def hid_write(data):
|
||||
if hiddev is None:
|
||||
return False
|
||||
|
||||
hiddev.write(data.encode())
|
||||
hiddev.write(data)
|
||||
hiddev.flush()
|
||||
|
||||
def hid_mouse_write(btn, x, y, wheel):
|
||||
@ -48,20 +47,22 @@ def hid_mouse_write(btn, x, y, wheel):
|
||||
|
||||
|
||||
def send_key(hidkey, shift, alt, ctlr):
|
||||
modkey = ord(NULL)
|
||||
data = bytearray(8)
|
||||
if shift:
|
||||
modkey += hidkeycodes['KEY_MOD_LSHIFT']
|
||||
data[0] += hidkeycodes['KEY_MOD_LSHIFT']
|
||||
if alt:
|
||||
modkey += hidkeycodes['KEY_MOD_LALT']
|
||||
data[0] += hidkeycodes['KEY_MOD_LALT']
|
||||
if ctlr:
|
||||
modkey += hidkeycodes['KEY_MOD_LCTRL']
|
||||
data[0] += hidkeycodes['KEY_MOD_LCTRL']
|
||||
|
||||
if hidkey == hidkeycodes['KEY_MOD_LMETA'] or hidkey == hidkeycodes['KEY_MOD_RMETA']:
|
||||
modkey += hidkey
|
||||
hidkey=ord(NULL)
|
||||
data[0] += hidkey
|
||||
hidkey=0
|
||||
|
||||
hid_write(chr(modkey)+NULL+chr(hidkey)+NULL*5)
|
||||
hid_write(NULL*8)
|
||||
data[2] = hidkey
|
||||
|
||||
hid_write(data)
|
||||
hid_write(bytearray(8))
|
||||
|
||||
|
||||
def get_hid_by_jscode(rawkeycode):
|
||||
|
Loading…
Reference in New Issue
Block a user