X-Git-Url: https://scm.cri.ensmp.fr/git/minwii.git/blobdiff_plain/0b66243b52ca111e54c2a2d0d18c1cc9bf972b0a..346a9b8e1fcfe30629f0d1ee4675e9e8f89890cf:/src/app/events.py diff --git a/src/app/events.py b/src/app/events.py index 02444b0..a67a416 100755 --- a/src/app/events.py +++ b/src/app/events.py @@ -1,8 +1,44 @@ -from pygame.locals import USEREVENT -TIMEOUT = USEREVENT + 1 -NOTEON = USEREVENT + 2 -NOTEOFF = USEREVENT + 3 -NOTEEND = USEREVENT + 4 -COLDOWN = USEREVENT + 5 -COLUP = USEREVENT + 6 -COLOVER = USEREVENT + 7 \ No newline at end of file +import pygame +from sys import modules + +events = ['NOTEON', + 'NOTEOFF', + 'NOTEEND', + 'COLDOWN', + 'COLUP', + 'COLOVER', + 'COLSTATECHANGE'] + +eventNames = {} +self = modules[__name__] + +for i, name in enumerate(events) : + eventType = pygame.USEREVENT + 1 + i + eventNames[eventType] = name + setattr(self, name, eventType) + +pygame_events = [ + 'NOEVENT', + 'ACTIVEEVENT', + 'KEYDOWN', + 'KEYUP', + 'MOUSEMOTION', + 'MOUSEBUTTONDOWN', + 'MOUSEBUTTONUP', + 'JOYAXISMOTION', + 'JOYBALLMOTION', + 'JOYHATMOTION', + 'JOYBUTTONDOWN', + 'JOYBUTTONUP', + 'VIDEORESIZE', + 'VIDEOEXPOSE', + 'QUIT', + 'SYSWMEVENT', + 'USEREVENT', + 'NUMEVENTS' + ] + +for name in pygame_events : + eventNames[getattr(pygame, name)] = name + +eventCodes = dict([v, k] for k, v in eventNames.items())