Skip to content

Commit e52825e

Browse files
committed
added ps5 custom map codes
1 parent ee788bd commit e52825e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Diff for: user_program/usb4vc_usb_scan.py

+28
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,32 @@ def scale_to_8bit(value, axes_dict, axis_key):
203203
"XB1_DPY":"ABS_HAT0Y",
204204
}
205205

206+
ps5_to_linux_ev_code_dict = {
207+
"PS5_CROSS":"BTN_EAST",
208+
"PS5_CIRCLE":"BTN_C",
209+
"PS5_SQUARE":"BTN_SOUTH",
210+
"PS5_TRIANGLE":"BTN_NORTH",
211+
"PS5_L1":"BTN_WEST",
212+
"PS5_R1":"BTN_Z",
213+
"PS5_CREATE":"BTN_TL2",
214+
"PS5_OPTION":"BTN_TR2",
215+
"PS5_LOGO":"BTN_MODE",
216+
"PS5_L2_BUTTON":"BTN_TL",
217+
"PS5_R2_BUTTON":"BTN_TR",
218+
"PS5_MUTE":"BTN_THUMBR",
219+
"PS5_TOUCHPAD_BUTTON":"BTN_THUMBL",
220+
"PS5_LSB":"BTN_SELECT",
221+
"PS5_RSB":"BTN_START",
222+
"PS5_LSX":"ABS_X",
223+
"PS5_LSY":"ABS_Y",
224+
"PS5_RSX":"ABS_Z",
225+
"PS5_RSY":"ABS_RZ",
226+
"PS5_L2_ANALOG":"ABS_RX",
227+
"PS5_R2_ANALOG":"ABS_RY",
228+
"PS5_DPX":"ABS_HAT0X",
229+
"PS5_DPY":"ABS_HAT0Y",
230+
}
231+
206232
def translate_dict(old_mapping_dict, lookup_dict):
207233
translated_map_dict = dict(old_mapping_dict)
208234
for key in old_mapping_dict:
@@ -267,6 +293,8 @@ def find_keycode_in_mapping(source_code, mapping_dict, usb_gamepad_type):
267293
return None, None
268294
if usb_gamepad_type == "Xbox":
269295
map_dict_copy = translate_dict(map_dict_copy, xbox_one_to_linux_ev_code_dict)
296+
if usb_gamepad_type == "PlayStation":
297+
map_dict_copy = translate_dict(map_dict_copy, ps5_to_linux_ev_code_dict)
270298
target_info = None
271299
for item in source_name:
272300
if item in map_dict_copy:

0 commit comments

Comments
 (0)