diff --git a/main.py b/main.py index a84f482..5f76716 100644 --- a/main.py +++ b/main.py @@ -35,24 +35,24 @@ def reset_joysticks(): sys.exit() if event.type in [pygame.JOYDEVICEADDED, pygame.JOYDEVICEREMOVED]: joysticks = reset_joysticks() - + window.fill('white') - + for joystick in joysticks: controller = Controller.from_joystick(joystick) js = [joystick.get_guid(), joystick.get_name()] for button in range(joystick.get_numbuttons()): - btn_message = 'Button ' + str(button) + ': ' + str(controller.get_button(button)) + btn_message = f'Button {str(button)}: {str(controller.get_button(button))}' js.append(btn_message) for axis in range(joystick.get_numaxes()): - axis_message = 'Axis ' + str(axis) + ': ' + str(controller.get_axis(axis)) + axis_message = f'Axis {str(axis)}: {str(controller.get_axis(axis))}' js.append(axis_message) for hat in range(joystick.get_numhats()): - hat_message = 'Hat ' + str(hat) + ': ' + str(joystick.get_hat(hat)) + hat_message = f'Hat {str(hat)}: {str(joystick.get_hat(hat))}' js.append(hat_message) - + debug_messages.append(js) - + for js, dbg_messages in enumerate(debug_messages): for i, message in enumerate(dbg_messages): l = 20 if js == 0 else js * 420 diff --git a/main_test_.py b/main_test_.py index 3d48668..2f18d2e 100644 --- a/main_test_.py +++ b/main_test_.py @@ -37,13 +37,13 @@ def reset_joysticks(): for joystick in joysticks: js = [joystick.get_guid(), joystick.get_name()] for button in range(joystick.get_numbuttons()): - btn_message = 'Button ' + str(button) + ': ' + str(joystick.get_button(button)) + btn_message = f'Button {str(button)}: {str(joystick.get_button(button))}' js.append(btn_message) for axis in range(joystick.get_numaxes()): - axis_message = 'Axis ' + str(axis) + ': ' + str(joystick.get_axis(axis)) + axis_message = f'Axis {str(axis)}: {str(joystick.get_axis(axis))}' js.append(axis_message) for hat in range(joystick.get_numhats()): - hat_message = 'Hat ' + str(hat) + ': ' + str(joystick.get_hat(hat)) + hat_message = f'Hat {str(hat)}: {str(joystick.get_hat(hat))}' js.append(hat_message) debug_messages.append(js)