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
|
# initialize a flask object
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
NULL = chr(0)
|
|
||||||
hiddev = None
|
hiddev = None
|
||||||
hidmouse = None
|
hidmouse = None
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ def hid_write(data):
|
|||||||
if hiddev is None:
|
if hiddev is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
hiddev.write(data.encode())
|
hiddev.write(data)
|
||||||
hiddev.flush()
|
hiddev.flush()
|
||||||
|
|
||||||
def hid_mouse_write(btn, x, y, wheel):
|
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):
|
def send_key(hidkey, shift, alt, ctlr):
|
||||||
modkey = ord(NULL)
|
data = bytearray(8)
|
||||||
if shift:
|
if shift:
|
||||||
modkey += hidkeycodes['KEY_MOD_LSHIFT']
|
data[0] += hidkeycodes['KEY_MOD_LSHIFT']
|
||||||
if alt:
|
if alt:
|
||||||
modkey += hidkeycodes['KEY_MOD_LALT']
|
data[0] += hidkeycodes['KEY_MOD_LALT']
|
||||||
if ctlr:
|
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']:
|
if hidkey == hidkeycodes['KEY_MOD_LMETA'] or hidkey == hidkeycodes['KEY_MOD_RMETA']:
|
||||||
modkey += hidkey
|
data[0] += hidkey
|
||||||
hidkey=ord(NULL)
|
hidkey=0
|
||||||
|
|
||||||
hid_write(chr(modkey)+NULL+chr(hidkey)+NULL*5)
|
data[2] = hidkey
|
||||||
hid_write(NULL*8)
|
|
||||||
|
hid_write(data)
|
||||||
|
hid_write(bytearray(8))
|
||||||
|
|
||||||
|
|
||||||
def get_hid_by_jscode(rawkeycode):
|
def get_hid_by_jscode(rawkeycode):
|
||||||
|
Loading…
Reference in New Issue
Block a user