[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Pygame without screen



Hi Winkleink,

Thanks for the hint. Indeed I heard/read somewhere that joysticks events are working. But keyboard events somehow not.
I cut an pasted a bit from your code and came up with the testprogramm below. If you run it, the joystick will trigger events, but the keyboard doesn't
------------------------
import pygame, os, sys
from pygame import locals

os.environ['SDL_VIDEODRIVER'] = 'dummy'
pygame.init()
pygame.joystick.init()

try:
ÂÂ j = pygame.joystick.Joystick(0) # create a joystick instance
ÂÂ j.init() # init instance
ÂÂ print 'Enabled joystick: ' + j.get_name()
except pygame.error:
ÂÂ print 'no joystick found.'

while True:
 for event in pygame.event.get():
ÂÂÂ print 'event detected'
ÂÂÂ if event.type == pygame.QUIT:
ÂÂÂÂÂ sys.exit()
ÂÂÂ if event.type == pygame.KEYDOWN:
ÂÂÂÂÂ print 'key pressed'
ÂÂÂ if event.type == pygame.locals.JOYAXISMOTION: # Read Analog Joystick Axis
ÂÂÂÂÂÂ print 'joystick moved'
---------------------------------------------


On 27/03/16 12:53, Winkleink wrote:
I use dummy in the following project and it worked.
There may be something other than that one line that needs to be sorted.


http://winkleink.blogspot.co.uk/2013/04/raspberry-pi-unipolar-stepper-motors.html
On Sun, 27 Mar 2016 at 08:03, Bert Haverkamp <bert@xxxxxxxxxxxxxxxx> wrote:
Hello all,

Maybe it has been asked before. But I only see older posts on this topic. I'm hoping the situation has changed now.
I'm trying to make a game where there is no screen needed, but physical actuators (motors, steppers, a beeper)

But without a screen defined, I cannot seem to get events to work properly
In particular cannot use the keydown and keyup events. The events don't seem to happen.

I read somewhere that I should use the dummy screen with
os.environ['SDL_VIDEODRIVER'] = 'dummy'

But this also doesn't seem to help.
Is there a way to get the events functioning without a screen? If so, how. If not, would that be an possible addition in a future version?

Regards,

Bert