Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Comment on lines -38 to +55
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 38-55 refactored with the following changes:

for js, dbg_messages in enumerate(debug_messages):
for i, message in enumerate(dbg_messages):
l = 20 if js == 0 else js * 420
Expand Down
6 changes: 3 additions & 3 deletions main_test_.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))}'
Comment on lines -40 to +46
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 40-46 refactored with the following changes:

js.append(hat_message)

debug_messages.append(js)
Expand Down