X-Git-Url: https://scm.cri.mines-paristech.fr/git/minwii.git/blobdiff_plain/4986d1d41239a54cd13b490ad72c3dc99793c8e8..90331dd4caff60e9517c862101a37d1ae4ee00d1:/src/app/events.py?ds=sidebyside diff --git a/src/app/events.py b/src/app/events.py index c27e951..a67a416 100755 --- a/src/app/events.py +++ b/src/app/events.py @@ -1,14 +1,44 @@ import pygame -base = pygame.USEREVENT -print 'events base :', pygame.USEREVENT -TIMEOUT = base + 1 -NOTEON = base + 2 -NOTEOFF = base + 3 -NOTEEND = base + 4 -COLDOWN = base + 5 -COLUP = base + 6 -COLOVER = base + 7 - -pygame.USEREVENT = COLOVER -if pygame.USEREVENT > pygame.NUMEVENTS : - pygame.NUMEVENTS = pygame.USEREVENT +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())