PS Sixaxis strange problem

I run Diddy headless using VNC and with the WiFi set up as a wireless access point. My sixaxis appears to be working correctly but I am getting strange behaviour. When my Python script is run from Idle (Python 2.7) everything works well. However, if I run the script from a terminal window on the VNC desktop the window is swamped with messages from the controller, such as the following:

"SDL_JoystickGetButton value:0:" and
"SDL_JoystickGetaxis value:0:"

Any print statements from my script scroll off the screen too quickly to read!
I checked /etc/default/sixad and both Debug and Legacy are set to zero. Would you have any idea on how to stop this behaviour?
Thanks
Il Diavolo

piborg's picture

Unfortunately this problem seems to be related to how pygame is getting the joystick input.
We actually had the same problem with our own scripts, so we have seen this as well.
While I do not have a proper fix for the problem, I can give you a reliable work-around.

First we need to suppress the messages that we do not want.
We can do this by redirecting the console output to a special device, /dev/null.
For example if your script is ./myscript.py we run this instead:
./myscript.py > /dev/null
The /dev/null device will then simply discard the output.
In our examples the various runDiddy*.sh scripts do this redirecting.

The second step is to make the print calls in the Python script work again.
We do this by changing the script to use stderr for all of the output.
This is normally used for error messages and it will bypass the redirection from the first step.
Simply add these lines towards the top of your script, before calling print:

# Re-direct our output to standard error
# We need to ignore standard out to hide some nasty print statements from pygame
import sys
sys.stdout = sys.stderr

With both changes the script should still print messages to the terminal as intended, but the SDL_ messages generated by pygame should be hidden.

Thanks piborg, both Diddy and I understood your very clear explanation. He is now trundling around the room identifying left turn and right turn symbols to his heart's content. Sometimes he even gets them right!

Il Diavolo

Subscribe to Comments for "PS Sixaxis strange problem"