Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upExample pygame_joystick.py does not run headless, use python_evdev instead of pygame #9
Comments
|
I don't believe this is an issue, it's just a limitation of using pygame for this. As you say, using evdev gets around this but has its own limitations. |
|
I have a similar issue where I want to use my sense hat headless but allow the user to control the led screen from the joystick. I tried with pushed as in the examples but it failed because of no display. Could you post your even example somewhere or could someone recommend am alternative approach? Many thanks |
|
rhellyer, easiest is to use
|
|
Many thanks - that sounds like the simplest route! |
|
@tvoverbeek is it acceptable to add another version of the program for evdev? That way users can see the advantages and disadvantages of both ways. |
|
For those interested here is my evdev version of the pygame-joystick example.
|
|
This is just what I needed for my project as I want to use the minijoystick but don't need pygame, many thanks for posting! |
|
I used the evdev solution listed above with my SenseHat and it worked great. I never could get pygames to run headless. |
|
A big thanks for you tvoverbeek!!! |
The pygame_joystick example needs a display otherwise the event loop does not work.
This is a problem when running headless (e.g. RPi with Sense Hat accessed via ssh).
Also the display is initialized with size 640x480 which is not nice to the new Raspberry Pi Display (800x400).
You can get it to work headless with 'hdmi_force_hotplug=1' in /boot/config.txt.
However the ESC key will not be recognized via ssh. You have to terminate with Ctrl-C
The code only needs keyboard events, so a display should not be needed.
I wrote an evdev_joystick.py using the same logic as pygame_joystick.
If you are interested I can generate a pull request with my added evdev_joystick.py.
Of course, instructions will have to be added how to install python_evdev.