added support for more gamepad buttons

This commit is contained in:
dekunukem
2022-04-27 13:26:10 +01:00
parent 100a0b191d
commit 955551bef1
3 changed files with 324 additions and 130 deletions

View File

@@ -1,3 +1,44 @@
# "ABS_X",
# "ABS_Y",
# "ABS_Z",
# "ABS_RX",
# "ABS_RY",
# "ABS_RZ",
# "ABS_THROTTLE",
# "ABS_RUDDER",
# "ABS_WHEEL",
# "ABS_GAS",
# "ABS_BRAKE",
# "ABS_HAT0X",
# "ABS_HAT0Y",
# "ABS_HAT1X",
# "ABS_HAT1Y",
# "ABS_HAT2X",
# "ABS_HAT2Y",
# "ABS_HAT3X",
# "ABS_HAT3Y",
# "KEY_MODE"]
# 'BTN_GAMEPAD':(0x130, 'usb_gp_btn'),
# 'BTN_SOUTH':(0x130, 'usb_gp_btn'),
# 'BTN_A':(0x130, 'usb_gp_btn'),
# 'BTN_EAST':(0x131, 'usb_gp_btn'),
# 'BTN_B':(0x131, 'usb_gp_btn'),
# 'BTN_C':(0x132, 'usb_gp_btn'),
# 'BTN_NORTH':(0x133, 'usb_gp_btn'),
# 'BTN_X':(0x133, 'usb_gp_btn'),
# 'BTN_WEST':(0x134, 'usb_gp_btn'),
# 'BTN_Y':(0x134, 'usb_gp_btn'),
# 'BTN_Z':(0x135, 'usb_gp_btn'),
# 'BTN_TL':(0x136, 'usb_gp_btn'),
# 'BTN_TR':(0x137, 'usb_gp_btn'),
# 'BTN_TL2':(0x138, 'usb_gp_btn'),
# 'BTN_TR2':(0x139, 'usb_gp_btn'),
# 'BTN_SELECT':(0x13a, 'usb_gp_btn'),
# 'BTN_START':(0x13b, 'usb_gp_btn'),
# 'BTN_MODE':(0x13c, 'usb_gp_btn'),
# 'BTN_THUMBL':(0x13d, 'usb_gp_btn'),
# 'BTN_THUMBR':(0x13e, 'usb_gp_btn'),
## Manual Software Updates
You should use [the configurator software](https://github.com/dekuNukem/usb4vc-configurator/blob/master/README.md) for updates. But here's how to do it by hand.

View File

@@ -214,26 +214,99 @@ code_name_to_value_lookup = {
'KEY_F23':(193, 'kb_key'),
'KEY_F24':(194, 'kb_key'),
# --------------------
'BTN_GAMEPAD':(0x130, 'usb_gp_btn'),
'BTN_SOUTH':(0x130, 'usb_gp_btn'),
'BTN_A':(0x130, 'usb_gp_btn'),
'BTN_EAST':(0x131, 'usb_gp_btn'),
'BTN_B':(0x131, 'usb_gp_btn'),
'BTN_C':(0x132, 'usb_gp_btn'),
'BTN_NORTH':(0x133, 'usb_gp_btn'),
'BTN_X':(0x133, 'usb_gp_btn'),
'BTN_WEST':(0x134, 'usb_gp_btn'),
'BTN_Y':(0x134, 'usb_gp_btn'),
'BTN_Z':(0x135, 'usb_gp_btn'),
'BTN_TL':(0x136, 'usb_gp_btn'),
'BTN_TR':(0x137, 'usb_gp_btn'),
'BTN_TL2':(0x138, 'usb_gp_btn'),
'BTN_TR2':(0x139, 'usb_gp_btn'),
'BTN_SELECT':(0x13a, 'usb_gp_btn'),
'BTN_START':(0x13b, 'usb_gp_btn'),
'BTN_MODE':(0x13c, 'usb_gp_btn'),
'BTN_THUMBL':(0x13d, 'usb_gp_btn'),
'BTN_THUMBR':(0x13e, 'usb_gp_btn'),
'BTN_MISC': (0x100, 'usb_gp_btn'),
'BTN_0': (0x100, 'usb_gp_btn'),
'BTN_1': (0x101, 'usb_gp_btn'),
'BTN_2': (0x102, 'usb_gp_btn'),
'BTN_3': (0x103, 'usb_gp_btn'),
'BTN_4': (0x104, 'usb_gp_btn'),
'BTN_5': (0x105, 'usb_gp_btn'),
'BTN_6': (0x106, 'usb_gp_btn'),
'BTN_7': (0x107, 'usb_gp_btn'),
'BTN_8': (0x108, 'usb_gp_btn'),
'BTN_9': (0x109, 'usb_gp_btn'),
'BTN_JOYSTICK': (0x120, 'usb_gp_btn'),
'BTN_TRIGGER': (0x120, 'usb_gp_btn'),
'BTN_THUMB': (0x121, 'usb_gp_btn'),
'BTN_THUMB2': (0x122, 'usb_gp_btn'),
'BTN_TOP': (0x123, 'usb_gp_btn'),
'BTN_TOP2': (0x124, 'usb_gp_btn'),
'BTN_PINKIE': (0x125, 'usb_gp_btn'),
'BTN_BASE': (0x126, 'usb_gp_btn'),
'BTN_BASE2': (0x127, 'usb_gp_btn'),
'BTN_BASE3': (0x128, 'usb_gp_btn'),
'BTN_BASE4': (0x129, 'usb_gp_btn'),
'BTN_BASE5': (0x12a, 'usb_gp_btn'),
'BTN_BASE6': (0x12b, 'usb_gp_btn'),
'BTN_DEAD': (0x12f, 'usb_gp_btn'),
'BTN_GAMEPAD': (0x130, 'usb_gp_btn'),
'BTN_SOUTH': (0x130, 'usb_gp_btn'),
'BTN_A': (0x130, 'usb_gp_btn'),
'BTN_EAST': (0x131, 'usb_gp_btn'),
'BTN_B': (0x131, 'usb_gp_btn'),
'BTN_C': (0x132, 'usb_gp_btn'),
'BTN_NORTH': (0x133, 'usb_gp_btn'),
'BTN_X': (0x133, 'usb_gp_btn'),
'BTN_WEST': (0x134, 'usb_gp_btn'),
'BTN_Y': (0x134, 'usb_gp_btn'),
'BTN_Z': (0x135, 'usb_gp_btn'),
'BTN_TL': (0x136, 'usb_gp_btn'),
'BTN_TR': (0x137, 'usb_gp_btn'),
'BTN_TL2': (0x138, 'usb_gp_btn'),
'BTN_TR2': (0x139, 'usb_gp_btn'),
'BTN_SELECT': (0x13a, 'usb_gp_btn'),
'BTN_START': (0x13b, 'usb_gp_btn'),
'BTN_MODE': (0x13c, 'usb_gp_btn'),
'BTN_THUMBL': (0x13d, 'usb_gp_btn'),
'BTN_THUMBR': (0x13e, 'usb_gp_btn'),
'BTN_WHEEL': (0x150, 'usb_gp_btn'),
'BTN_GEAR_DOWN': (0x150, 'usb_gp_btn'),
'BTN_GEAR_UP': (0x151, 'usb_gp_btn'),
'BTN_DPAD_UP': (0x220, 'usb_gp_btn'),
'BTN_DPAD_DOWN': (0x221, 'usb_gp_btn'),
'BTN_DPAD_LEFT': (0x222, 'usb_gp_btn'),
'BTN_DPAD_RIGHT': (0x223, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY': (0x2c0, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY1': (0x2c0, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY2': (0x2c1, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY3': (0x2c2, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY4': (0x2c3, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY5': (0x2c4, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY6': (0x2c5, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY7': (0x2c6, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY8': (0x2c7, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY9': (0x2c8, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY10': (0x2c9, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY11': (0x2ca, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY12': (0x2cb, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY13': (0x2cc, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY14': (0x2cd, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY15': (0x2ce, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY16': (0x2cf, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY17': (0x2d0, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY18': (0x2d1, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY19': (0x2d2, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY20': (0x2d3, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY21': (0x2d4, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY22': (0x2d5, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY23': (0x2d6, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY24': (0x2d7, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY25': (0x2d8, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY26': (0x2d9, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY27': (0x2da, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY28': (0x2db, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY29': (0x2dc, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY30': (0x2dd, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY31': (0x2de, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY32': (0x2df, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY33': (0x2e0, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY34': (0x2e1, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY35': (0x2e2, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY36': (0x2e3, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY37': (0x2e4, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY38': (0x2e5, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY39': (0x2e6, 'usb_gp_btn'),
'BTN_TRIGGER_HAPPY40': (0x2e7, 'usb_gp_btn'),
# --------------------
'ABS_X':(0x00, 'usb_abs_axis'),
'ABS_Y':(0x01, 'usb_abs_axis'),
@@ -297,7 +370,40 @@ code_name_to_value_lookup = {
}
code_value_to_name_lookup = {
0x130:{'BTN_SOUTH', 'BTN_A'},
0x100:{'BTN_MISC', 'BTN_0'},
0x101:{'BTN_1'},
0x102:{'BTN_2'},
0x103:{'BTN_3'},
0x104:{'BTN_4'},
0x105:{'BTN_5'},
0x106:{'BTN_6'},
0x107:{'BTN_7'},
0x108:{'BTN_8'},
0x109:{'BTN_9'},
0x110:{'BTN_MOUSE'},
0x110:{'BTN_LEFT'},
0x111:{'BTN_RIGHT'},
0x112:{'BTN_MIDDLE'},
0x113:{'BTN_SIDE'},
0x114:{'BTN_EXTRA'},
0x115:{'BTN_FORWARD'},
0x116:{'BTN_BACK'},
0x117:{'BTN_TASK'},
0x120:{'BTN_JOYSTICK'},
0x120:{'BTN_TRIGGER'},
0x121:{'BTN_THUMB'},
0x122:{'BTN_THUMB2'},
0x123:{'BTN_TOP'},
0x124:{'BTN_TOP2'},
0x125:{'BTN_PINKIE'},
0x126:{'BTN_BASE'},
0x127:{'BTN_BASE2'},
0x128:{'BTN_BASE3'},
0x129:{'BTN_BASE4'},
0x12a:{'BTN_BASE5'},
0x12b:{'BTN_BASE6'},
0x12f:{'BTN_DEAD'},
0x130:{'BTN_GAMEPAD', 'BTN_SOUTH', 'BTN_A'},
0x131:{'BTN_EAST', 'BTN_B'},
0x132:{'BTN_C'},
0x133:{'BTN_NORTH', 'BTN_X'},
@@ -312,6 +418,52 @@ code_value_to_name_lookup = {
0x13c:{'BTN_MODE'},
0x13d:{'BTN_THUMBL'},
0x13e:{'BTN_THUMBR'},
0x150:{'BTN_WHEEL', 'BTN_GEAR_DOWN'},
0x151:{'BTN_GEAR_UP'},
0x220:{'BTN_DPAD_UP'},
0x221:{'BTN_DPAD_DOWN'},
0x222:{'BTN_DPAD_LEFT'},
0x223:{'BTN_DPAD_RIGHT'},
0x2c0:{'BTN_TRIGGER_HAPPY', 'BTN_TRIGGER_HAPPY1'},
0x2c1:{'BTN_TRIGGER_HAPPY2'},
0x2c2:{'BTN_TRIGGER_HAPPY3'},
0x2c3:{'BTN_TRIGGER_HAPPY4'},
0x2c4:{'BTN_TRIGGER_HAPPY5'},
0x2c5:{'BTN_TRIGGER_HAPPY6'},
0x2c6:{'BTN_TRIGGER_HAPPY7'},
0x2c7:{'BTN_TRIGGER_HAPPY8'},
0x2c8:{'BTN_TRIGGER_HAPPY9'},
0x2c9:{'BTN_TRIGGER_HAPPY10'},
0x2ca:{'BTN_TRIGGER_HAPPY11'},
0x2cb:{'BTN_TRIGGER_HAPPY12'},
0x2cc:{'BTN_TRIGGER_HAPPY13'},
0x2cd:{'BTN_TRIGGER_HAPPY14'},
0x2ce:{'BTN_TRIGGER_HAPPY15'},
0x2cf:{'BTN_TRIGGER_HAPPY16'},
0x2d0:{'BTN_TRIGGER_HAPPY17'},
0x2d1:{'BTN_TRIGGER_HAPPY18'},
0x2d2:{'BTN_TRIGGER_HAPPY19'},
0x2d3:{'BTN_TRIGGER_HAPPY20'},
0x2d4:{'BTN_TRIGGER_HAPPY21'},
0x2d5:{'BTN_TRIGGER_HAPPY22'},
0x2d6:{'BTN_TRIGGER_HAPPY23'},
0x2d7:{'BTN_TRIGGER_HAPPY24'},
0x2d8:{'BTN_TRIGGER_HAPPY25'},
0x2d9:{'BTN_TRIGGER_HAPPY26'},
0x2da:{'BTN_TRIGGER_HAPPY27'},
0x2db:{'BTN_TRIGGER_HAPPY28'},
0x2dc:{'BTN_TRIGGER_HAPPY29'},
0x2dd:{'BTN_TRIGGER_HAPPY30'},
0x2de:{'BTN_TRIGGER_HAPPY31'},
0x2df:{'BTN_TRIGGER_HAPPY32'},
0x2e0:{'BTN_TRIGGER_HAPPY33'},
0x2e1:{'BTN_TRIGGER_HAPPY34'},
0x2e2:{'BTN_TRIGGER_HAPPY35'},
0x2e3:{'BTN_TRIGGER_HAPPY36'},
0x2e4:{'BTN_TRIGGER_HAPPY37'},
0x2e5:{'BTN_TRIGGER_HAPPY38'},
0x2e6:{'BTN_TRIGGER_HAPPY39'},
0x2e7:{'BTN_TRIGGER_HAPPY40'},
0x00:{'ABS_X'},
0x01:{'ABS_Y'},
0x02:{'ABS_Z'},
@@ -357,109 +509,94 @@ protocol_id_lookup = {
}
gamepad_event_code_name_list = [
"BTN_JOYSTICK",
"BTN_TRIGGER",
"BTN_THUMB",
"BTN_THUMB2",
"BTN_TOP",
"BTN_TOP2",
"BTN_PINKIE",
"BTN_BASE",
"BTN_BASE2",
"BTN_BASE3",
"BTN_BASE4",
"BTN_BASE5",
"BTN_BASE6",
"BTN_DEAD",
"BTN_GAMEPAD",
"BTN_SOUTH",
"BTN_A",
"BTN_SOUTH",
"BTN_EAST",
"BTN_B",
"BTN_EAST",
"BTN_C",
"BTN_NORTH",
"BTN_X",
"BTN_NORTH",
"BTN_WEST",
"BTN_Y",
"BTN_WEST",
"BTN_Z",
"BTN_TL",
"BTN_TR",
"BTN_TL2",
"BTN_TR2",
"BTN_SELECT",
"BTN_START",
"BTN_MODE",
"BTN_THUMBL",
"BTN_THUMBR",
"BTN_WHEEL",
"BTN_GEAR_DOWN",
"BTN_GEAR_UP",
"BTN_DPAD_UP",
"BTN_DPAD_DOWN",
"BTN_DPAD_LEFT",
"BTN_DPAD_RIGHT",
"BTN_TRIGGER_HAPPY",
"BTN_TRIGGER_HAPPY1",
"BTN_TRIGGER_HAPPY2",
"BTN_TRIGGER_HAPPY3",
"BTN_TRIGGER_HAPPY4",
"BTN_TRIGGER_HAPPY5",
"BTN_TRIGGER_HAPPY6",
"BTN_TRIGGER_HAPPY7",
"BTN_TRIGGER_HAPPY8",
"BTN_TRIGGER_HAPPY9",
"BTN_TRIGGER_HAPPY10",
"BTN_TRIGGER_HAPPY11",
"BTN_TRIGGER_HAPPY12",
"BTN_TRIGGER_HAPPY13",
"BTN_TRIGGER_HAPPY14",
"BTN_TRIGGER_HAPPY15",
"BTN_TRIGGER_HAPPY16",
"BTN_TRIGGER_HAPPY17",
"BTN_TRIGGER_HAPPY18",
"BTN_TRIGGER_HAPPY19",
"BTN_TRIGGER_HAPPY20",
"BTN_TRIGGER_HAPPY21",
"BTN_TRIGGER_HAPPY22",
"BTN_TRIGGER_HAPPY23",
"BTN_TRIGGER_HAPPY24",
"BTN_TRIGGER_HAPPY25",
"BTN_TRIGGER_HAPPY26",
"BTN_TRIGGER_HAPPY27",
"BTN_TRIGGER_HAPPY28",
"BTN_TRIGGER_HAPPY29",
"BTN_TRIGGER_HAPPY30",
"BTN_TRIGGER_HAPPY31",
"BTN_TRIGGER_HAPPY32",
"BTN_TRIGGER_HAPPY33",
"BTN_TRIGGER_HAPPY34",
"BTN_TRIGGER_HAPPY35",
"BTN_TRIGGER_HAPPY36",
"BTN_TRIGGER_HAPPY37",
"BTN_TRIGGER_HAPPY38",
"BTN_TRIGGER_HAPPY39",
"BTN_TRIGGER_HAPPY40",
"ABS_X",
"ABS_Y",
"ABS_Z",
"ABS_RX",
"ABS_RY",
"ABS_RZ",
"ABS_THROTTLE",
"ABS_RUDDER",
"ABS_WHEEL",
"ABS_GAS",
"ABS_BRAKE",
"ABS_HAT0X",
"ABS_HAT0Y",
"ABS_HAT1X",
"ABS_HAT1Y",
"ABS_HAT2X",
"ABS_HAT2Y",
"ABS_HAT3X",
"ABS_HAT3Y",
"KEY_MODE"]
'BTN_1',
'BTN_2',
'BTN_3',
'BTN_4',
'BTN_5',
'BTN_6',
'BTN_7',
'BTN_8',
'BTN_9',
'BTN_JOYSTICK',
'BTN_TRIGGER',
'BTN_THUMB',
'BTN_THUMB2',
'BTN_TOP',
'BTN_TOP2',
'BTN_PINKIE',
'BTN_BASE',
'BTN_BASE2',
'BTN_BASE3',
'BTN_BASE4',
'BTN_BASE5',
'BTN_BASE6',
'BTN_DEAD',
'BTN_GAMEPAD',
'BTN_SOUTH',
'BTN_A',
'BTN_EAST',
'BTN_B',
'BTN_C',
'BTN_NORTH',
'BTN_X',
'BTN_WEST',
'BTN_Y',
'BTN_Z',
'BTN_TL',
'BTN_TR',
'BTN_TL2',
'BTN_TR2',
'BTN_SELECT',
'BTN_START',
'BTN_MODE',
'BTN_THUMBL',
'BTN_THUMBR',
'BTN_WHEEL',
'BTN_GEAR_DOWN',
'BTN_GEAR_UP',
'BTN_DPAD_UP',
'BTN_DPAD_DOWN',
'BTN_DPAD_LEFT',
'BTN_DPAD_RIGHT',
'BTN_TRIGGER_HAPPY',
'BTN_TRIGGER_HAPPY1',
'BTN_TRIGGER_HAPPY2',
'BTN_TRIGGER_HAPPY3',
'BTN_TRIGGER_HAPPY4',
'BTN_TRIGGER_HAPPY5',
'BTN_TRIGGER_HAPPY6',
'BTN_TRIGGER_HAPPY7',
'BTN_TRIGGER_HAPPY8',
'BTN_TRIGGER_HAPPY9',
'BTN_TRIGGER_HAPPY10',
'BTN_TRIGGER_HAPPY11',
'BTN_TRIGGER_HAPPY12',
'BTN_TRIGGER_HAPPY13',
'BTN_TRIGGER_HAPPY14',
'BTN_TRIGGER_HAPPY15',
'BTN_TRIGGER_HAPPY16',
'BTN_TRIGGER_HAPPY17',
'BTN_TRIGGER_HAPPY18',
'BTN_TRIGGER_HAPPY19',
'BTN_TRIGGER_HAPPY20',
'BTN_TRIGGER_HAPPY21',
'BTN_TRIGGER_HAPPY22',
'BTN_TRIGGER_HAPPY23',
'BTN_TRIGGER_HAPPY24',
'BTN_TRIGGER_HAPPY25',
'BTN_TRIGGER_HAPPY26',
'BTN_TRIGGER_HAPPY27',
'BTN_TRIGGER_HAPPY28',
'BTN_TRIGGER_HAPPY29',
'BTN_TRIGGER_HAPPY30',
'BTN_TRIGGER_HAPPY31',
'BTN_TRIGGER_HAPPY32',
'BTN_TRIGGER_HAPPY33',
'BTN_TRIGGER_HAPPY34',
'BTN_TRIGGER_HAPPY35',
'BTN_TRIGGER_HAPPY36',
'BTN_TRIGGER_HAPPY37',
'BTN_TRIGGER_HAPPY38',
'BTN_TRIGGER_HAPPY39',
'BTN_TRIGGER_HAPPY40',]

View File

@@ -98,6 +98,15 @@ BTN_FORWARD = 0x115
BTN_BACK = 0x116
BTN_TASK = 0x117
def is_gamepad_button(event_code):
name_result = usb4vc_shared.code_value_to_name_lookup.get(event_code)
if name_result is None:
return False
for item in name_result:
if item in usb4vc_shared.gamepad_event_code_name_list:
return True
return False
# some gamepad buttons report as keyboard keys when connected via bluetooth, need to account for those
gamepad_buttons_as_kb_codes = {
373, # KEY_MODE, Xbox logo button, xbox one controller when connected via bluetooth on xpadneo
@@ -232,7 +241,7 @@ def find_keycode_in_mapping(source_code, mapping_dict, usb_gamepad_type):
source_type = None
if ABS_X <= source_code <= ABS_HAT3Y:
source_type = 'usb_abs_axis'
elif BTN_SOUTH <= source_code <= BTN_THUMBR or source_code in gamepad_buttons_as_kb_codes:
elif is_gamepad_button(source_code) or source_code in gamepad_buttons_as_kb_codes:
source_type = 'usb_gp_btn'
if source_type is None:
return None, None
@@ -277,11 +286,14 @@ def make_15pin_gamepad_spi_packet(gp_status_dict, this_device_info, mapping_info
global prev_kb_output
global curr_mouse_output
# print(gp_status_dict)
axes_info = this_device_info['axes_info']
this_gamepad_name = this_device_info.get('name', '').lower().strip()
usb_gamepad_type = this_device_info['gamepad_type']
gp_id = this_device_info['id']
this_gp_dict = gp_status_dict[gp_id]
print(this_gp_dict)
curr_gp_output = {
'IBM_GGP_BTN_1':set([0]),
'IBM_GGP_BTN_2':set([0]),
@@ -756,7 +768,7 @@ def raw_input_event_worker():
last_mouse_button_msg = make_mouse_spi_packet(mouse_status_dict, this_id)
pcard_spi.xfer(list(last_mouse_button_msg))
# Gamepad buttons
elif BTN_SOUTH <= event_code <= BTN_THUMBR or event_code in gamepad_buttons_as_kb_codes:
elif is_gamepad_button(event_code) or event_code in gamepad_buttons_as_kb_codes:
this_btn_status = data[4]
if this_btn_status != 0:
this_btn_status = 1
@@ -802,6 +814,7 @@ def raw_input_event_worker():
this_gp_dict[axes_code] = 127
gamepad_output = make_gamepad_spi_packet(gamepad_status_dict, this_device)
if gamepad_output != last_gamepad_msg:
print(gamepad_output)
gp_to_transfer, kb_to_transfer, mouse_to_transfer = gamepad_output
pcard_spi.xfer(list(gp_to_transfer))
if kb_to_transfer is not None:
@@ -866,6 +879,10 @@ def get_input_devices():
dev_dict['is_mouse'] = True
if 'KEY_ENTER' in cap_str and "KEY_Y" in cap_str:
dev_dict['is_kb'] = True
# print(this_device.name)
# print(this_cap)
# print(check_is_gamepad(this_cap))
# print("!!!!!!!!!!!!!!!!!!!!!!")
if check_is_gamepad(this_cap):
dev_dict['is_gp'] = True
try:
@@ -896,7 +913,6 @@ def usb_device_scan_worker():
time.sleep(0.75)
try:
device_list = get_input_devices()
print(device_list)
except Exception as e:
print('exception get_input_devices:', e)
continue