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

Re: [pygame] Creating unique userevent ids?



Gary Bishop wrote:
I'm gradually building up a small collection of modules that enhance
pygame with new input devices (wiimote, webcam). The modules generate
new events so I've been doing things like pygame.USEREVENT+1. But this
is guaranteed to get me into trouble when using multiple independent
extensions.

Is there some way to assure I've got a unique id? wxPython has NewId for
this purpose.

I don't think there is any limit to the ID number used for your events. But there is one limitation I know of. There is a way for SDL to filter the events that get generated. This is limited to pygame.MAXEVENTS which happens to be 32. Internally, SDL uses a bitmask to work the filter. But filtering is really never used, maybe even never, so I doubt it would be a problem.