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

Re: [pygame] pygame.event.get() data

Mike Dudley schrieb:
How would one read the data that comes from pygame.event.get() ?
I want to read the data from a joystick directly from the event, without having to use joystick.getaxis().
The event data looks like a dictionary, but I'm not sure how to access it.

<Event(7-JoyAxisMotion {'joy': 0, 'value': -0.0078432569353312793, 'axis': 0})>

Mike D.


some example code:

events = pygame.event.get()

for event in events:
  # check type first
   if event.type == pygame.JOYAXISMOTION:
       # documentation says that this event has following members:
       # JOYAXISMOTION   joy, axis, value
       # so to acces them just use
       print event.joy
       print event.axis
       print event.value