I am trying to create a python script with pygame to control servos with a gamepad. I want to be able to do this without a display of any kind. I am running the script on a Raspberry Pi 4 Model B with Raspbian OS and to run scripts I am using SSH from bash terminal (I've tried on VS Code terminal and git-bash terminal) on a windows computer with OS Windows 8. I've seen some work arounds for headless pygame code:
https://www.pygame.org/wiki/HeadlessNoWindowsNeeded
https://gist.github.com/illume/f2fcdde9478aa3f1db8f3ee17359cf1c
Pygame display init on headless Raspberry Pi Zero (Raspbian Buster Lite)
Pygame on Pi running through Putty, no screen, no input
Pygame on Pi running through Putty, no screen, no input
However, none have worked and I keep getting these errors:
Traceback (most recent call last):
File "ps4ServoControl.py", line 15, in <module>
pygame.display.init()
pygame.error: Unable to open a console terminal
or
Traceback (most recent call last):
File "ps4ServoControl.py", line 63, in <module>
for event in pygame.event.get():
pygame.error: video system not initialized
I've tried every variation of the following lines:
os.environ["SDL_VIDEODRIVER"] = "dummy"
os.putenv('SDL_VIDEODRIVER', 'fbcon')
os.putenv('DISPLAY', ':0.0')
pygame.display.init()
screen = pygame.display.set_mode((1,1))
Is it just because I'm trying to do this with SSH? I'm not sure how else to test my scripts without doing a remote desktop, but again, I don't want to have to pull up a screen somewhere when I get the script working. Any help is appreciated. Thanks!