From 66ce1bffea6bf8c37e9d3db1d7ee4ba5601522cf Mon Sep 17 00:00:00 2001 From: dekunukem Date: Sat, 5 Feb 2022 02:05:50 +0000 Subject: [PATCH] updated protocol display name, added exception handling in custom gamepad mapping --- user_program/usb4vc_main.py | 4 ++-- user_program/usb4vc_shared.py | 2 +- user_program/usb4vc_ui.py | 4 ++-- user_program/usb4vc_usb_scan.py | 7 +++++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/user_program/usb4vc_main.py b/user_program/usb4vc_main.py index 664e477..8d650b8 100644 --- a/user_program/usb4vc_main.py +++ b/user_program/usb4vc_main.py @@ -16,10 +16,10 @@ usb4vc_usb_scan.usb_device_scan_thread.start() usb4vc_usb_scan.raw_input_event_parser_thread.start() while 1: + time.sleep(2) ertm_status = subprocess.getoutput("cat /sys/module/bluetooth/parameters/disable_ertm").replace('\n', '').replace('\r', '').strip() if ertm_status != 'Y': print('ertm_status:', ertm_status) print("Disabling ERTM....") subprocess.call('echo 1 > /sys/module/bluetooth/parameters/disable_ertm') - print("DONE") - time.sleep(2) \ No newline at end of file + print("DONE") \ No newline at end of file diff --git a/user_program/usb4vc_shared.py b/user_program/usb4vc_shared.py index 05b4428..beefbc8 100644 --- a/user_program/usb4vc_shared.py +++ b/user_program/usb4vc_shared.py @@ -1,4 +1,4 @@ -RPI_APP_VERSION_TUPLE = (0, 0, 1) +RPI_APP_VERSION_TUPLE = (0, 0, 2) code_name_to_value_lookup = { 'KEY_RESERVED':(0, 'kb_key'), diff --git a/user_program/usb4vc_ui.py b/user_program/usb4vc_ui.py index b29127c..0892971 100644 --- a/user_program/usb4vc_ui.py +++ b/user_program/usb4vc_ui.py @@ -127,9 +127,9 @@ PROTOCOL_AT_PS2_KB = {'pid':1, 'display_name':"AT/PS2"} PROTOCOL_XT_KB = {'pid':2, 'display_name':"PC XT"} PROTOCOL_ADB_KB = {'pid':3, 'display_name':"ADB"} PROTOCOL_PS2_MOUSE = {'pid':4, 'display_name':"PS/2"} -PROTOCOL_MICROSOFT_SERIAL_MOUSE = {'pid':5, 'display_name':"MS Serial"} +PROTOCOL_MICROSOFT_SERIAL_MOUSE = {'pid':5, 'display_name':"Microsft Serial"} PROTOCOL_ADB_MOUSE = {'pid':6, 'display_name':"ADB"} -PROTOCOL_GENERIC_GAMEPORT_GAMEPAD = {'pid':7, 'display_name':"Generic PC", 'mapping':IBM_GGP_DEAULT_MAPPING} +PROTOCOL_GENERIC_GAMEPORT_GAMEPAD = {'pid':7, 'display_name':"Generic 15-Pin", 'mapping':IBM_GGP_DEAULT_MAPPING} PROTOCOL_GAMEPORT_GRAVIS_GAMEPAD = {'pid':8, 'display_name':"Gravis Pro"} PROTOCOL_GAMEPORT_MICROSOFT_SIDEWINDER = {'pid':9, 'display_name':"MS Sidewinder"} PROTOCOL_RAW_KEYBOARD = {'pid':125, 'display_name':"Raw data"} diff --git a/user_program/usb4vc_usb_scan.py b/user_program/usb4vc_usb_scan.py index c01c6c4..d9007dc 100644 --- a/user_program/usb4vc_usb_scan.py +++ b/user_program/usb4vc_usb_scan.py @@ -408,8 +408,11 @@ def make_generic_gamepad_spi_packet(gp_status_dict, gp_id, axes_info, mapping_in def make_gamepad_spi_packet(gp_status_dict, gp_id, axes_info): current_protocol = usb4vc_ui.get_gamepad_protocol() - if current_protocol['pid'] in [PID_GENERIC_GAMEPORT_GAMEPAD, PID_PROTOCOL_OFF]: - return make_generic_gamepad_spi_packet(gp_status_dict, gp_id, axes_info, current_protocol) + try: + if current_protocol['pid'] in [PID_GENERIC_GAMEPORT_GAMEPAD, PID_PROTOCOL_OFF]: + return make_generic_gamepad_spi_packet(gp_status_dict, gp_id, axes_info, current_protocol) + except Exception as e: + print("make_generic_gamepad_spi_packet:", e) return list(nop_spi_msg_template), None, None def change_kb_led(scrolllock, numlock, capslock):