Browse Source

gbe/events now handles pygame.ACTIVEEVENT with two custom events, 'FOCUSLOST' and 'FOCUSGAINED'.

master
Bryan Miller 6 years ago
parent
commit
9c752493dd
1 changed files with 7 additions and 1 deletions
  1. +7
    -1
      game/gbe/events.py

+ 7
- 1
game/gbe/events.py View File

elif event.type == pygame.JOYBUTTONDOWN: elif event.type == pygame.JOYBUTTONDOWN:
_WatchButton(event.joy, event.button) _WatchButton(event.joy, event.button)
Events.emit("JOYBUTTONDOWN", {"joy":event.joy, "button":event.button}) Events.emit("JOYBUTTONDOWN", {"joy":event.joy, "button":event.button})
elif event.type == pygame.ACTIVEEVENT:
if event.state == 1:
if event.gain == 0:
Events.emit("FOCUSLOST", {})
elif event.gain == 1:
Events.emit("FOCUSGAINED", {})
else: else:
if hasattr(event, "code"): if hasattr(event, "code"):
Events.emit("PYGUSER_{}".format(event.code), {}) Events.emit("PYGUSER_{}".format(event.code), {})
else: else:
print("Unkown pygame event type '{}'".format(event.type))
print("Unkown pygame event type '{}'".format(pygame.event.event_name(event.type)))







Loading…
Cancel
Save