mirror of
https://github.com/dekuNukem/USB4VC.git
synced 2025-10-31 11:26:46 -07:00
updated ps5 and xbox controller default mapping, added default mouse and keyboard mapping
This commit is contained in:
@@ -101,8 +101,20 @@ USBGP_ABS_RZ = 0x05 # right analog trigger
|
|||||||
USBGP_ABS_HAT0X = 0x10 # D-pad X
|
USBGP_ABS_HAT0X = 0x10 # D-pad X
|
||||||
USBGP_ABS_HAT0Y = 0x11 # D-pad Y
|
USBGP_ABS_HAT0Y = 0x11 # D-pad Y
|
||||||
|
|
||||||
|
GENERIC_USB_GAMEPAD_TO_MOUSE_KB_DEAULT_MAPPING = {
|
||||||
|
"MAPPING_TYPE": "DEFAULT_MOUSE_KB",
|
||||||
|
'BTN_TL': {'code': 'BTN_LEFT'},
|
||||||
|
'BTN_TR': {'code': 'BTN_RIGHT'},
|
||||||
|
'BTN_TL2': {'code': 'BTN_LEFT'},
|
||||||
|
'BTN_TR2': {'code': 'BTN_RIGHT'},
|
||||||
|
'ABS_X': {'code': 'REL_X'},
|
||||||
|
'ABS_Y': {'code': 'REL_Y'},
|
||||||
|
'ABS_HAT0X': {'code': 'KEY_RIGHT', 'code_neg': 'KEY_LEFT'},
|
||||||
|
'ABS_HAT0Y': {'code': 'KEY_DOWN', 'code_neg': 'KEY_UP'}
|
||||||
|
}
|
||||||
|
|
||||||
IBM_GENERIC_USB_GAMEPAD_TO_15PIN_GAMEPORT_GAMEPAD_DEAULT_MAPPING = {
|
IBM_GENERIC_USB_GAMEPAD_TO_15PIN_GAMEPORT_GAMEPAD_DEAULT_MAPPING = {
|
||||||
"IS_DEFAULT": True,
|
"MAPPING_TYPE": "DEFAULT_15PIN",
|
||||||
# buttons to buttons
|
# buttons to buttons
|
||||||
'BTN_SOUTH': {'code':'IBM_GGP_BTN_1'},
|
'BTN_SOUTH': {'code':'IBM_GGP_BTN_1'},
|
||||||
'BTN_NORTH': {'code':'IBM_GGP_BTN_2'},
|
'BTN_NORTH': {'code':'IBM_GGP_BTN_2'},
|
||||||
@@ -134,6 +146,7 @@ PROTOCOL_PS2_MOUSE = {'pid':4, 'display_name':"PS/2"}
|
|||||||
PROTOCOL_MICROSOFT_SERIAL_MOUSE = {'pid':5, 'display_name':"Microsft Serial"}
|
PROTOCOL_MICROSOFT_SERIAL_MOUSE = {'pid':5, 'display_name':"Microsft Serial"}
|
||||||
PROTOCOL_ADB_MOUSE = {'pid':6, 'display_name':"ADB"}
|
PROTOCOL_ADB_MOUSE = {'pid':6, 'display_name':"ADB"}
|
||||||
PROTOCOL_15PIN_GAMEPORT_GAMEPAD = {'pid':7, 'display_name':"Generic 15-Pin", 'mapping':IBM_GENERIC_USB_GAMEPAD_TO_15PIN_GAMEPORT_GAMEPAD_DEAULT_MAPPING}
|
PROTOCOL_15PIN_GAMEPORT_GAMEPAD = {'pid':7, 'display_name':"Generic 15-Pin", 'mapping':IBM_GENERIC_USB_GAMEPAD_TO_15PIN_GAMEPORT_GAMEPAD_DEAULT_MAPPING}
|
||||||
|
PROTOCOL_USB_GP_TO_MOUSE_KB = {'pid':0, 'display_name':'Mouse & KB', 'mapping':GENERIC_USB_GAMEPAD_TO_MOUSE_KB_DEAULT_MAPPING}
|
||||||
# PROTOCOL_GAMEPORT_GRAVIS_GAMEPAD = {'pid':8, 'display_name':"Gravis Pro"}
|
# PROTOCOL_GAMEPORT_GRAVIS_GAMEPAD = {'pid':8, 'display_name':"Gravis Pro"}
|
||||||
# PROTOCOL_GAMEPORT_MICROSOFT_SIDEWINDER = {'pid':9, 'display_name':"MS Sidewinder"}
|
# PROTOCOL_GAMEPORT_MICROSOFT_SIDEWINDER = {'pid':9, 'display_name':"MS Sidewinder"}
|
||||||
PROTOCOL_RAW_KEYBOARD = {'pid':125, 'display_name':"Raw data"}
|
PROTOCOL_RAW_KEYBOARD = {'pid':125, 'display_name':"Raw data"}
|
||||||
@@ -345,12 +358,11 @@ def oled_print_centered(text, font, y, this_canvas):
|
|||||||
|
|
||||||
ibmpc_keyboard_protocols = [PROTOCOL_OFF, PROTOCOL_AT_PS2_KB, PROTOCOL_XT_KB]
|
ibmpc_keyboard_protocols = [PROTOCOL_OFF, PROTOCOL_AT_PS2_KB, PROTOCOL_XT_KB]
|
||||||
ibmpc_mouse_protocols = [PROTOCOL_OFF, PROTOCOL_PS2_MOUSE, PROTOCOL_MICROSOFT_SERIAL_MOUSE]
|
ibmpc_mouse_protocols = [PROTOCOL_OFF, PROTOCOL_PS2_MOUSE, PROTOCOL_MICROSOFT_SERIAL_MOUSE]
|
||||||
# ibmpc_gamepad_protocols = [PROTOCOL_OFF, PROTOCOL_15PIN_GAMEPORT_GAMEPAD, PROTOCOL_GAMEPORT_GRAVIS_GAMEPAD, PROTOCOL_GAMEPORT_MICROSOFT_SIDEWINDER]
|
ibmpc_gamepad_protocols = [PROTOCOL_OFF, PROTOCOL_15PIN_GAMEPORT_GAMEPAD, PROTOCOL_USB_GP_TO_MOUSE_KB]
|
||||||
ibmpc_gamepad_protocols = [PROTOCOL_OFF, PROTOCOL_15PIN_GAMEPORT_GAMEPAD]
|
|
||||||
|
|
||||||
adb_keyboard_protocols = [PROTOCOL_OFF, PROTOCOL_ADB_KB]
|
adb_keyboard_protocols = [PROTOCOL_OFF, PROTOCOL_ADB_KB]
|
||||||
adb_mouse_protocols = [PROTOCOL_OFF, PROTOCOL_ADB_MOUSE]
|
adb_mouse_protocols = [PROTOCOL_OFF, PROTOCOL_ADB_MOUSE]
|
||||||
adb_gamepad_protocols = [PROTOCOL_OFF]
|
adb_gamepad_protocols = [PROTOCOL_OFF, PROTOCOL_USB_GP_TO_MOUSE_KB]
|
||||||
|
|
||||||
raw_keyboard_protocols = [PROTOCOL_OFF, PROTOCOL_RAW_KEYBOARD]
|
raw_keyboard_protocols = [PROTOCOL_OFF, PROTOCOL_RAW_KEYBOARD]
|
||||||
raw_mouse_protocols = [PROTOCOL_OFF, PROTOCOL_RAW_MOUSE]
|
raw_mouse_protocols = [PROTOCOL_OFF, PROTOCOL_RAW_MOUSE]
|
||||||
|
|||||||
@@ -235,8 +235,49 @@ def translate_dict(old_mapping_dict, lookup_dict):
|
|||||||
lookup_result = lookup_dict.get(key)
|
lookup_result = lookup_dict.get(key)
|
||||||
if lookup_result is not None:
|
if lookup_result is not None:
|
||||||
translated_map_dict[lookup_result] = old_mapping_dict[key]
|
translated_map_dict[lookup_result] = old_mapping_dict[key]
|
||||||
|
del translated_map_dict[key]
|
||||||
return translated_map_dict
|
return translated_map_dict
|
||||||
|
|
||||||
|
XBOX_DEFAULT_KB_MOUSE_MAPPING = {
|
||||||
|
'XB1_A': {'code': 'BTN_LEFT'},
|
||||||
|
'XB1_B': {'code': 'BTN_RIGHT'},
|
||||||
|
'XB1_LSX': {'code': 'REL_X'},
|
||||||
|
'XB1_LSY': {'code': 'REL_Y'},
|
||||||
|
'XB1_LB': {'code': 'BTN_LEFT'},
|
||||||
|
'XB1_RB': {'code': 'BTN_RIGHT'},
|
||||||
|
'XB1_RSX': {'code': 'KEY_RIGHT', 'code_neg': 'KEY_LEFT'},
|
||||||
|
'XB1_RSY': {'code': 'KEY_DOWN', 'code_neg': 'KEY_UP'},
|
||||||
|
'XB1_DPX': {'code': 'KEY_RIGHT', 'code_neg': 'KEY_LEFT'},
|
||||||
|
'XB1_DPY': {'code': 'KEY_DOWN', 'code_neg': 'KEY_UP'},
|
||||||
|
'XB1_X': {'code': 'BTN_LEFT'},
|
||||||
|
'XB1_Y': {'code': 'BTN_RIGHT'},
|
||||||
|
'XB1_MENU': {'code': 'KEY_ESC'},
|
||||||
|
'XB1_VIEW': {'code': 'KEY_ESC'}
|
||||||
|
}
|
||||||
|
|
||||||
|
PLAYSTATION_DEFAULT_KB_MOUSE_MAPPING = {
|
||||||
|
'PS5_CROSS': {'code': 'BTN_LEFT'},
|
||||||
|
'PS5_SQUARE': {'code': 'BTN_LEFT'},
|
||||||
|
'PS5_L1': {'code': 'BTN_LEFT'},
|
||||||
|
'PS5_L2_BUTTON': {'code': 'BTN_LEFT'},
|
||||||
|
|
||||||
|
'PS5_CIRCLE': {'code': 'BTN_RIGHT'},
|
||||||
|
'PS5_TRIANGLE': {'code': 'BTN_RIGHT'},
|
||||||
|
'PS5_R1': {'code': 'BTN_RIGHT'},
|
||||||
|
'PS5_R2_BUTTON': {'code': 'BTN_RIGHT'},
|
||||||
|
|
||||||
|
'PS5_LSX': {'code': 'REL_X'},
|
||||||
|
'PS5_LSY': {'code': 'REL_Y'},
|
||||||
|
|
||||||
|
'PS5_RSX': {'code': 'KEY_RIGHT', 'code_neg': 'KEY_LEFT'},
|
||||||
|
'PS5_RSY': {'code': 'KEY_DOWN', 'code_neg': 'KEY_UP'},
|
||||||
|
'PS5_DPX': {'code': 'KEY_RIGHT', 'code_neg': 'KEY_LEFT'},
|
||||||
|
'PS5_DPY': {'code': 'KEY_DOWN', 'code_neg': 'KEY_UP'},
|
||||||
|
|
||||||
|
'PS5_CREATE': {'code': 'KEY_ESC'},
|
||||||
|
'PS5_OPTION': {'code': 'KEY_ESC'}
|
||||||
|
}
|
||||||
|
|
||||||
XBOX_DEFAULT_MAPPING = {
|
XBOX_DEFAULT_MAPPING = {
|
||||||
# buttons to buttons
|
# buttons to buttons
|
||||||
'BTN_A': {'code':'IBM_GGP_BTN_1'},
|
'BTN_A': {'code':'IBM_GGP_BTN_1'},
|
||||||
@@ -284,10 +325,14 @@ PLAYSTATION_DEAULT_MAPPING = {
|
|||||||
|
|
||||||
def find_keycode_in_mapping(source_code, mapping_dict, usb_gamepad_type):
|
def find_keycode_in_mapping(source_code, mapping_dict, usb_gamepad_type):
|
||||||
map_dict_copy = dict(mapping_dict)
|
map_dict_copy = dict(mapping_dict)
|
||||||
if usb_gamepad_type == 'PlayStation' and map_dict_copy.get("IS_DEFAULT", False):
|
if usb_gamepad_type == 'PlayStation' and map_dict_copy.get("MAPPING_TYPE") == "DEFAULT_15PIN":
|
||||||
map_dict_copy = PLAYSTATION_DEAULT_MAPPING
|
map_dict_copy = PLAYSTATION_DEAULT_MAPPING
|
||||||
if usb_gamepad_type == 'Xbox' and map_dict_copy.get("IS_DEFAULT", False):
|
elif usb_gamepad_type == 'Xbox' and map_dict_copy.get("MAPPING_TYPE") == "DEFAULT_15PIN":
|
||||||
map_dict_copy = XBOX_DEFAULT_MAPPING
|
map_dict_copy = XBOX_DEFAULT_MAPPING
|
||||||
|
elif usb_gamepad_type == 'PlayStation' and map_dict_copy.get("MAPPING_TYPE") == "DEFAULT_MOUSE_KB":
|
||||||
|
map_dict_copy = PLAYSTATION_DEFAULT_KB_MOUSE_MAPPING
|
||||||
|
elif usb_gamepad_type == 'Xbox' and map_dict_copy.get("MAPPING_TYPE") == "DEFAULT_MOUSE_KB":
|
||||||
|
map_dict_copy = XBOX_DEFAULT_KB_MOUSE_MAPPING
|
||||||
source_name = usb4vc_shared.code_value_to_name_lookup.get(source_code)
|
source_name = usb4vc_shared.code_value_to_name_lookup.get(source_code)
|
||||||
if source_name is None:
|
if source_name is None:
|
||||||
return None, None
|
return None, None
|
||||||
@@ -363,11 +408,13 @@ def make_generic_gamepad_spi_packet(gp_status_dict, gp_id, this_device_info, map
|
|||||||
global prev_kb_output
|
global prev_kb_output
|
||||||
global curr_mouse_output
|
global curr_mouse_output
|
||||||
axes_info = this_device_info['axes_info']
|
axes_info = this_device_info['axes_info']
|
||||||
this_gamepad_name = this_device_info.get('name', '').lower()
|
this_gamepad_name = this_device_info.get('name', '').lower().strip()
|
||||||
usb_gamepad_type = 'Generic USB'
|
usb_gamepad_type = 'Generic USB'
|
||||||
if 'xbox' in this_gamepad_name or 'x-box' in this_gamepad_name:
|
if 'xbox' in this_gamepad_name or 'x-box' in this_gamepad_name:
|
||||||
usb_gamepad_type = 'Xbox'
|
usb_gamepad_type = 'Xbox'
|
||||||
elif 'wireless controller' in this_gamepad_name:
|
elif 'sony' in this_gamepad_name and 'wireless controller' in this_gamepad_name:
|
||||||
|
usb_gamepad_type = 'PlayStation'
|
||||||
|
elif this_gamepad_name == 'wireless controller':
|
||||||
usb_gamepad_type = 'PlayStation'
|
usb_gamepad_type = 'PlayStation'
|
||||||
|
|
||||||
this_gp_dict = gp_status_dict[gp_id]
|
this_gp_dict = gp_status_dict[gp_id]
|
||||||
|
|||||||
Reference in New Issue
Block a user