fixed PS5 controller default mapping

This commit is contained in:
dekunukem
2022-05-10 12:36:36 +01:00
parent 63767147d3
commit 4b46ab9ee0
4 changed files with 27 additions and 26 deletions

View File

@@ -1,3 +1,9 @@
def get_stick_axes(this_device):
if 'DualSense' in this_device['gamepad_type']:
return ["ABS_X", "ABS_Y", "ABS_Z", "ABS_RZ"]
return ["ABS_X", "ABS_Y", "ABS_RX", "ABS_RY"]
# "ABS_X",
# "ABS_Y",
# "ABS_Z",

View File

@@ -86,27 +86,25 @@ xbox_one_to_linux_ev_code_dict = {
}
ps5_to_linux_ev_code_dict = {
"PS_CROSS":"BTN_EAST",
"PS_CIRCLE":"BTN_C",
"PS_SQUARE":"BTN_SOUTH",
"PS_CROSS":"BTN_SOUTH",
"PS_CIRCLE":"BTN_EAST",
"PS_SQUARE":"BTN_WEST",
"PS_TRIANGLE":"BTN_NORTH",
"PS_L1":"BTN_WEST",
"PS_R1":"BTN_Z",
"PS_CREATE":"BTN_TL2",
"PS_OPTION":"BTN_TR2",
"PS_L1":"BTN_TL",
"PS_R1":"BTN_TR",
"PS_CREATE":"BTN_SELECT",
"PS_OPTION":"BTN_START",
"PS_LOGO":"BTN_MODE",
"PS_L2_BUTTON":"BTN_TL",
"PS_R2_BUTTON":"BTN_TR",
"PS_MUTE":"BTN_THUMBR",
"PS_TOUCHPAD_BUTTON":"BTN_THUMBL",
"PS_LSB":"BTN_SELECT",
"PS_RSB":"BTN_START",
"PS_L2_BUTTON":"BTN_TL2",
"PS_R2_BUTTON":"BTN_TR2",
"PS_LSB":"BTN_THUMBL",
"PS_RSB":"BTN_THUMBR",
"PS_LSX":"ABS_X",
"PS_LSY":"ABS_Y",
"PS_RSX":"ABS_Z",
"PS_RSY":"ABS_RZ",
"PS_L2_ANALOG":"ABS_RX",
"PS_R2_ANALOG":"ABS_RY",
"PS_RSX":"ABS_RX",
"PS_RSY":"ABS_RY",
"PS_L2_ANALOG":"ABS_Z",
"PS_R2_ANALOG":"ABS_RZ",
"PS_DPX":"ABS_HAT0X",
"PS_DPY":"ABS_HAT0Y",
}

View File

@@ -13,7 +13,7 @@ def ensure_dir(dir_path):
if not os.path.exists(dir_path):
os.makedirs(dir_path)
RPI_APP_VERSION_TUPLE = (0, 1, 3)
RPI_APP_VERSION_TUPLE = (0, 2, 0)
code_name_to_value_lookup = {
'KEY_RESERVED':(0, 'kb_key'),

View File

@@ -724,10 +724,7 @@ def multiply_round_up_0(number, multi):
new_number = -1
return int(new_number)
def get_stick_axes(this_device):
if 'DualSense' in this_device['gamepad_type']:
return ["ABS_X", "ABS_Y", "ABS_Z", "ABS_RZ"]
return ["ABS_X", "ABS_Y", "ABS_RX", "ABS_RY"]
USB_GAMEPAD_STICK_AXES_NAMES = ["ABS_X", "ABS_Y", "ABS_RX", "ABS_RY"]
gamepad_status_dict = {}
gamepad_hold_check_interval = 0.02
@@ -826,11 +823,11 @@ def raw_input_event_worker():
clear_mouse_movement(mouse_status_dict)
last_mouse_msg = list(this_mouse_msg)
if this_device['is_gp']:
for stick_axes_name in get_stick_axes(this_device):
axes_code = usb4vc_shared.code_name_to_value_lookup.get(stick_axes_name)[0]
for axis_name in USB_GAMEPAD_STICK_AXES_NAMES:
axis_code = usb4vc_shared.code_name_to_value_lookup.get(axis_name)[0]
this_gp_dict = gamepad_status_dict[this_device['id']]
if axes_code in this_gp_dict and 127 - 12 <= this_gp_dict[axes_code] <= 127 + 12:
this_gp_dict[axes_code] = 127
if axis_code in this_gp_dict and 127 - 12 <= this_gp_dict[axis_code] <= 127 + 12:
this_gp_dict[axis_code] = 127
gamepad_output = make_gamepad_spi_packet(gamepad_status_dict, this_device)
if gamepad_output != last_gamepad_msg:
# print(gamepad_output)