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

@@ -149,11 +149,17 @@ def pollEmitter():
elif event.type == pygame.JOYBUTTONDOWN:
_WatchButton(event.joy, 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:
if hasattr(event, "code"):
Events.emit("PYGUSER_{}".format(event.code), {})
else:
print("Unkown pygame event type '{}'".format(event.type))
print("Unkown pygame event type '{}'".format(pygame.event.event_name(event.type)))




Loading…
Cancel
Save