Closed MichaelWoodc closed 1 year ago
Hello, you can create your menu without using menu.mainloop
to test events and manually delegate events to the menu. See https://pygame-menu.readthedocs.io/en/4.3.9/_source/create_menu.html#display-a-menu.
Could you also check out #422. In particular, you can customize the events by creating your own controller object. See https://pygame-menu.readthedocs.io/en/4.3.9/_source/advanced_controller.html
Hello, you can create your menu without using
menu.mainloop
to test events and manually delegate events to the menu. See https://pygame-menu.readthedocs.io/en/4.3.9/_source/create_menu.html#display-a-menu.Could you also check out #422. In particular, you can customize the events by creating your own controller object. See https://pygame-menu.readthedocs.io/en/4.3.9/_source/advanced_controller.html
Thanks for your help! I unfortunately still cannot get it to work. Does it work by default with any specific controller? I'm ready to give up on the vintage USB nintendo controller :(
It does work with controllers right out of the box. However, it might not work for some controllers because of incorrect mapping.
Could you test if the menu responds to any event by cloning and testing the menu event function? Maybe the events do not match the controller you're using:
What happens if you print the event list?
When I print the events using pygame and not pygame menu, ( couldn't quite get the provided code to work, I'm really scratching my head here! I'm still learning programming) I get the following:
pygame 2.2.0 (SDL 2.0.22, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
<Event(1541-JoyDeviceAdded {'device_index': 0, 'guid': '03000000790000001100000000000000'})>
#Now lets press the A button, it gives us 2 events
<Event(1539-JoyButtonDown {'joy': 0, 'instance_id': 0, 'button': 1})>
<Event(1540-JoyButtonUp {'joy': 0, 'instance_id': 0, 'button': 1})>
#Likewise, if we push button b, also two events:
<Event(1539-JoyButtonDown {'joy': 0, 'instance_id': 0, 'button': 2})>
<Event(1540-JoyButtonUp {'joy': 0, 'instance_id': 0, 'button': 2})>
#Start Button:
<Event(1539-JoyButtonDown {'joy': 0, 'instance_id': 0, 'button': 9})>
<Event(1540-JoyButtonUp {'joy': 0, 'instance_id': 0, 'button': 9})>
#Select Button:
<Event(1539-JoyButtonDown {'joy': 0, 'instance_id': 0, 'button': 8})>
<Event(1540-JoyButtonUp {'joy': 0, 'instance_id': 0, 'button': 8})>
#Joystick Up: Please note: for the initial click it always displays the resting axis value first
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 4, 'value': -0.007812738425855281})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 4, 'value': -1.000030518509476})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 4, 'value': -0.007812738425855281})>
#Joystick Down:
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 4, 'value': -0.007812738425855281})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 4, 'value': 1.0})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 4, 'value': -0.007812738425855281})>
#Joystick Left: (note: this usb controller actually considers 4 different axis for left and right
I will only display one axis, axis 0, again, 3 events for first click, two thereafter)
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 0, 'value': -0.007812738425855281})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 0, 'value': -1.000030518509476})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 0, 'value': -0.007812738425855281})>
#Joystick Right: (again, 4 axis change, only showing axis 0)
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 0, 'value': -0.007812738425855281})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 0, 'value': 1.0})>
<Event(1536-JoyAxisMotion {'joy': 0, 'instance_id': 0, 'axis': 0, 'value': -0.007812738425855281})>`
Of note may be the fact that when I test the controller with a different controller test app, using SDL, the A button is button 1, B is button 0, start button6, select button 4.
Hey so I did get it to work, probably not in an ideal fashion, but I just directly edited the controls.py file. Also, for some reason the events from my controller never showed up in any of the examples, although hot plugging the controller itself would show up as an event. May be a controller issue with pygame_menu, but every controller event shows up with no issue is pygame, just not pygame_menu.
Hello, you also can edit default controls (as there are tons of different control mappings out there); check out https://pygame-menu.readthedocs.io/en/4.3.9/_source/advanced_controller.html#configure-controller. For future related issues, the menu cannot guarantee each control mapping. Thus any PR is welcome that addresses this issue.
Is your feature request related to a problem? Please describe. Yes, please see bug #457
Describe the solution you'd like I'd love to see an example of a menu working with any controller, and ideally how I could modify parameters to use my controller
Describe alternatives you've considered I've tried importing my own code but it seems the menu has it's own loop that is only closed when an action is taken to start the main game, so I can't use that to control the menu