forked from auracaster/bumble_mirror
Added mousemove changes
Also modified keyboard data on keyup
This commit is contained in:
@@ -94,7 +94,7 @@ HID_VIRTUAL_CABLE = True # Virtual cable enabled
|
|||||||
HID_RECONNECT_INITIATE = True # Reconnect initiate enabled
|
HID_RECONNECT_INITIATE = True # Reconnect initiate enabled
|
||||||
REPORT_DESCRIPTOR_TYPE = 0x22 # 0x22 Type = Report Descriptor
|
REPORT_DESCRIPTOR_TYPE = 0x22 # 0x22 Type = Report Descriptor
|
||||||
HID_LANGID_BASE_LANGUAGE = 0x0409 # 0x0409 Language = English (United States)
|
HID_LANGID_BASE_LANGUAGE = 0x0409 # 0x0409 Language = English (United States)
|
||||||
HID_LANGID_BASE_BLUETOOTH_STRING_OFFSET = 0x100 # 0x0100 Bluetooth String Offset
|
HID_LANGID_BASE_BLUETOOTH_STRING_OFFSET = 0x100 # 0x0100 Default
|
||||||
HID_BATTERY_POWER = True # Battery power enabled
|
HID_BATTERY_POWER = True # Battery power enabled
|
||||||
HID_REMOTE_WAKE = True # Remote wake enabled
|
HID_REMOTE_WAKE = True # Remote wake enabled
|
||||||
HID_SUPERVISION_TIMEOUT = 0xC80 # uint16 0xC80 (2s)
|
HID_SUPERVISION_TIMEOUT = 0xC80 # uint16 0xC80 (2s)
|
||||||
@@ -436,7 +436,6 @@ async def keyboard_device(hid_device, command):
|
|||||||
# Start a Websocket server to receive events from a web page
|
# Start a Websocket server to receive events from a web page
|
||||||
async def serve(websocket, _path):
|
async def serve(websocket, _path):
|
||||||
global deviceData
|
global deviceData
|
||||||
#global mouseData
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
message = await websocket.recv()
|
message = await websocket.recv()
|
||||||
@@ -453,19 +452,17 @@ async def keyboard_device(hid_device, command):
|
|||||||
deviceData.setKeyBoardData(bytearray([0x01, 0x00, 0x00, hid_code, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
deviceData.setKeyBoardData(bytearray([0x01, 0x00, 0x00, hid_code, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||||
hid_device.send_report_on_interrupt(deviceData.getKeyBoardData())
|
hid_device.send_report_on_interrupt(deviceData.getKeyBoardData())
|
||||||
elif message_type == 'keyup':
|
elif message_type == 'keyup':
|
||||||
deviceData.setKeyBoardData(bytearray([0x01, 0x00, 0x00, hid_code, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
deviceData.setKeyBoardData(bytearray([0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]))
|
||||||
hid_device.send_report_on_interrupt(deviceData.getKeyBoardData())
|
hid_device.send_report_on_interrupt(deviceData.getKeyBoardData())
|
||||||
elif message_type == "mousemove":
|
elif message_type == "mousemove":
|
||||||
|
# logical min and max values
|
||||||
|
log_min = -127
|
||||||
|
log_max = 127
|
||||||
x = parsed['x']
|
x = parsed['x']
|
||||||
if x > 127:
|
|
||||||
x = 127
|
|
||||||
elif x < -127:
|
|
||||||
x = -127
|
|
||||||
y = parsed['y']
|
y = parsed['y']
|
||||||
if y > 127:
|
# limiting x and y values within logical max and min range
|
||||||
y = 127
|
x = max(log_min, min(log_max, x))
|
||||||
elif y < -127:
|
y = max(log_min, min(log_max, y))
|
||||||
y = -127
|
|
||||||
x_cord = x.to_bytes(signed = True)
|
x_cord = x.to_bytes(signed = True)
|
||||||
y_cord = y.to_bytes(signed = True)
|
y_cord = y.to_bytes(signed = True)
|
||||||
deviceData.setMouseData(bytearray([0x02, 0x00]) + x_cord + y_cord)
|
deviceData.setMouseData(bytearray([0x02, 0x00]) + x_cord + y_cord)
|
||||||
|
|||||||
Reference in New Issue
Block a user