Skip to content

Instantly share code, notes, and snippets.

@WinkelCode
Created August 13, 2023 21:23
Show Gist options
  • Save WinkelCode/e4e16dfed3ce6f146b5dcfad2943ff72 to your computer and use it in GitHub Desktop.
Save WinkelCode/e4e16dfed3ce6f146b5dcfad2943ff72 to your computer and use it in GitHub Desktop.
Set certain keyboards into "ISP"/Firmware reading/writing mode
import hid
# Constants
vendor = int(0x05ac)
product = int(0x024f)
request_path = b''
data_path = b''
devices = hid.enumerate(vendor, product)
if not devices:
raise Exception(f'No devices matching VID: {vendor:04x} PID: {product:04x} found')
for device in devices:
if device['interface_number'] != -1 and device['usage'] == 1 and device['usage_page'] == int(0xff00):
if b'&Col05' in device['path']:
if request_path != b'':
raise Exception(
f"Multiple request devices found: {request_path.decode()} and {device['path'].decode()}")
request_path = device['path']
elif b'&Col06' in device['path']:
if data_path != b'':
raise Exception(
f"Multiple data devices found: {data_path.decode()} and {device['path'].decode()}")
data_path = device['path']
if not request_path:
raise Exception('No request device found')
if not data_path:
raise Exception('No data device found')
r = hid.device()
d = hid.device()
r.open_path(request_path)
d.open_path(data_path)
# const COMMAND_LENGTH: usize = 6;
# const REPORT_ID_CMD: u8 = 0x05;
# const CMD_ISP_MODE: u8 = 0x75;
command = [0x05, 0x75, 0x00, 0x00, 0x00, 0x00]
r.send_feature_report(command)
r.close()
d.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment