Added mousemove changes

Also modified keyboard data on keyup
This commit is contained in:
Fahad Afroze
2023-11-23 17:46:55 +00:00
parent 0578e84586
commit 0f29052ade
2 changed files with 13 additions and 16 deletions

View File

@@ -94,7 +94,7 @@ HID_VIRTUAL_CABLE = True # Virtual cable enabled
HID_RECONNECT_INITIATE = True # Reconnect initiate enabled
REPORT_DESCRIPTOR_TYPE = 0x22 # 0x22 Type = Report Descriptor
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_REMOTE_WAKE = True # Remote wake enabled
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
async def serve(websocket, _path):
global deviceData
#global mouseData
while True:
try:
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]))
hid_device.send_report_on_interrupt(deviceData.getKeyBoardData())
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())
elif message_type == "mousemove":
# logical min and max values
log_min = -127
log_max = 127
x = parsed['x']
if x > 127:
x = 127
elif x < -127:
x = -127
y = parsed['y']
if y > 127:
y = 127
elif y < -127:
y = -127
# limiting x and y values within logical max and min range
x = max(log_min, min(log_max, x))
y = max(log_min, min(log_max, y))
x_cord = x.to_bytes(signed = True)
y_cord = y.to_bytes(signed = True)
deviceData.setMouseData(bytearray([0x02, 0x00]) + x_cord + y_cord)