Anonymous avatar Anonymous committed 9b39448

Moved all constants and enums into constants.py

Comments (0)

Files changed (8)

                 ('_callback', _SDL_AudioSpec_fn),
                 ('_userdata', c_void_p)]
 
-if sys.byteorder == 'little':
-    AUDIO_U16SYS = SDL.constants.AUDIO_U16LSB
-    AUDIO_S16SYS = SDL.constants.AUDIO_S16LSB
-else:
-    AUDIO_U16SYS = SDL.constants.AUDIO_U16MSB
-    AUDIO_S16SYS = SDL.constants.AUDIO_S16MSB
-
 _SDL_AudioCVT_p = POINTER('SDL_AudioCVT')
 
 _SDL_AudioCVT_filter_fn = \
         obtained.callback = desired.callback
         ctype[0] = _ctype_audio_format(obtained.format)
 
-# enum SDL_audiostatus
-(SDL_AUDIO_STOPPED,
-    SDL_AUDIO_PLAYING,
-    SDL_AUDIO_PAUSED) = range(3)
-
 SDL_GetAudioStatus = SDL.dll.function('SDL_GetAudioStatus',
     '''Get the current audio state.
 
 import SDL.constants
 import SDL.dll
 
-# enum CDstatus
-(CD_TRAYEMPTY,
-    CD_STOPPED,
-    CD_PLAYING,
-    CD_PAUSED) = range(4)
-CD_ERROR = -1
-# end enum CDstatus
-
 class SDL_CDtrack(Structure):
     '''Structure describing a single CD track.
 
 TIMER_RESOLUTION = 0x0000000a
 #END GENERATED CONSTANTS
 
+# From SDL_audio.h (inserted manually)
+
+# enum SDL_audiostatus
+(SDL_AUDIO_STOPPED,
+    SDL_AUDIO_PLAYING,
+    SDL_AUDIO_PAUSED) = range(3)
+
+if sys.byteorder == 'little':
+    AUDIO_U16SYS = AUDIO_U16LSB
+    AUDIO_S16SYS = AUDIO_S16LSB
+else:
+    AUDIO_U16SYS = AUDIO_U16MSB
+    AUDIO_S16SYS = AUDIO_S16MSB
+AUDIO_U16 = AUDIO_U16LSB
+AUDIO_S16 = AUDIO_S16LSB
+
+# From SDL_cdrom.h (inserted manually)
+# enum CDstatus
+(CD_TRAYEMPTY,
+    CD_STOPPED,
+    CD_PLAYING,
+    CD_PAUSED) = range(4)
+CD_ERROR = -1
+
+# From SDL_events.h (inserted manually)
+# enum SDL_EventType
+(SDL_NOEVENT,
+    SDL_ACTIVEEVENT,
+    SDL_KEYDOWN,
+    SDL_KEYUP,
+    SDL_MOUSEMOTION,
+    SDL_MOUSEBUTTONDOWN,
+    SDL_MOUSEBUTTONUP,
+    SDL_JOYAXISMOTION,
+    SDL_JOYBALLMOTION,
+    SDL_JOYHATMOTION,
+    SDL_JOYBUTTONDOWN,
+    SDL_JOYBUTTONUP,
+    SDL_QUIT,
+    SDL_SYSWMEVENT,
+    SDL_EVENT_RESERVEDA,
+    SDL_EVENT_RESERVEDB,
+    SDL_VIDEORESIZE,
+    SDL_VIDEOEXPOSE,
+    SDL_EVENT_RESERVED2,
+    SDL_EVENT_RESERVED3,
+    SDL_EVENT_RESERVED4,
+    SDL_EVENT_RESERVED5,
+    SDL_EVENT_RESERVED6,
+    SDL_EVENT_RESERVED7) = range(24)
+SDL_USEREVENT = 24
+SDL_NUMEVENTS = 32
+
+def SDL_EVENTMASK(x):
+    '''Used for predefining event masks.'''
+    return 1 << x
+
+# enum SDL_EventMask
+SDL_ACTIVEEVENTMASK     = SDL_EVENTMASK(SDL_ACTIVEEVENT)
+SDL_KEYDOWNMASK         = SDL_EVENTMASK(SDL_KEYDOWN)
+SDL_KEYUPMASK           = SDL_EVENTMASK(SDL_KEYUP)
+SDL_KEYEVENTMASK        = SDL_KEYUPMASK | \
+                          SDL_KEYDOWNMASK
+SDL_MOUSEMOTIONMASK     = SDL_EVENTMASK(SDL_MOUSEMOTION)
+SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)
+SDL_MOUSEBUTTONUPMASK   = SDL_EVENTMASK(SDL_MOUSEBUTTONUP)
+SDL_MOUSEEVENTMASK      = SDL_MOUSEMOTIONMASK | \
+                          SDL_MOUSEBUTTONDOWNMASK | \
+                          SDL_MOUSEBUTTONUPMASK
+SDL_JOYAXISMOTIONMASK   = SDL_EVENTMASK(SDL_JOYAXISMOTION)
+SDL_JOYBALLMOTIONMASK   = SDL_EVENTMASK(SDL_JOYBALLMOTION)
+SDL_JOYHATMOTIONMASK    = SDL_EVENTMASK(SDL_JOYHATMOTION)
+SDL_JOYBUTTONDOWNMASK   = SDL_EVENTMASK(SDL_JOYBUTTONDOWN)
+SDL_JOYBUTTONUPMASK     = SDL_EVENTMASK(SDL_JOYBUTTONUP)
+SDL_JOYEVENTMASK        = SDL_JOYAXISMOTIONMASK | \
+                          SDL_JOYBALLMOTIONMASK | \
+                          SDL_JOYHATMOTIONMASK | \
+                          SDL_JOYBUTTONDOWNMASK | \
+                          SDL_JOYBUTTONUPMASK
+SDL_QUITMASK            = SDL_EVENTMASK(SDL_QUIT)
+SDL_SYSWMEVENTMASK      = SDL_EVENTMASK(SDL_SYSWMEVENT)
+SDL_VIDEORESIZEMASK     = SDL_EVENTMASK(SDL_VIDEORESIZE)
+SDL_VIDEOEXPOSEMASK     = SDL_EVENTMASK(SDL_VIDEOEXPOSE)
+
+# enum SDL_eventaction
+(SDL_ADDEVENT,
+    SDL_PEEKEVENT,
+    SDL_GETEVENT) = range(3)
+
+#From SDL_joystick.h (inserted manually)
+SDL_HAT_RIGHTUP = SDL_HAT_RIGHT | SDL_HAT_UP
+SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT | SDL_HAT_DOWN
+SDL_HAT_LEFTUP = SDL_HAT_LEFT | SDL_HAT_UP
+SDL_HAT_LEFTDOWN = SDL_HAT_LEFT | SDL_HAT_DOWN
+
+# From SDL_video.h (inserted manually)
+# enum SDL_GLattr
+(SDL_GL_RED_SIZE,
+    SDL_GL_GREEN_SIZE,
+    SDL_GL_BLUE_SIZE,
+    SDL_GL_ALPHA_SIZE,
+    SDL_GL_BUFFER_SIZE,
+    SDL_GL_DOUBLEBUFFER,
+    SDL_GL_DEPTH_SIZE,
+    SDL_GL_STENCIL_SIZE,
+    SDL_GL_ACCUM_RED_SIZE,
+    SDL_GL_ACCUM_GREEN_SIZE,
+    SDL_GL_ACCUM_BLUE_SIZE,
+    SDL_GL_ACCUM_ALPHA_SIZE,
+    SDL_GL_STEREO,
+    SDL_GL_MULTISAMPLEBUFFERS,
+    SDL_GL_MULTISAMPLESAMPLES,
+    SDL_GL_ACCELERATED_VISUAL,
+    SDL_GL_SWAP_CONTROL) = range(17)
+
+# enum SDL_GrabMode
+(SDL_GRAB_QUERY,
+    SDL_GRAB_OFF,
+    SDL_GRAB_ON) = range(-1,2)
+
 # From SDL_ttf.h (inserted manually)
 TTF_STYLE_NORMAL    = 0x00
 TTF_STYLE_BOLD      = 0x01
     MIX_DEFAULT_FORMAT  = AUDIO_S16LSB 
 else:
     MIX_DEFAULT_FORMAT  = AUDIO_S16MSB
+
+# enum Mix_Fading
+(MIX_NO_FADING,
+    MIX_FADING_OUT,
+    MIX_FADING_IN) = range(3)
+
+# enum Mix_MusicType
+(MUS_NONE,
+    MUS_CMD,
+    MUS_WAV,
+    MUS_MOD,
+    MUS_MID,
+    MUS_OGG,
+    MUS_MP3) = range(7)
+
+# From SDL_sound.h (inserted manually):
+# enum Sound_SampleFlags
+SOUND_SAMPLEFLAG_NONE       = 0
+SOUND_SAMPLEFLAG_CANSEEK    = 1
+SOUND_SAMPLEFLAG_EOF        = 1 << 29
+SOUND_SAMPLEFLAG_ERROR      = 1 << 30
+SOUND_SAMPLEFLAG_EGAIN      = 1 << 31
 
 from ctypes import *
 
+import SDL.constants
 import SDL.dll
 import SDL.keyboard
 
-# enum SDL_EventType
-(SDL_NOEVENT,
-    SDL_ACTIVEEVENT,
-    SDL_KEYDOWN,
-    SDL_KEYUP,
-    SDL_MOUSEMOTION,
-    SDL_MOUSEBUTTONDOWN,
-    SDL_MOUSEBUTTONUP,
-    SDL_JOYAXISMOTION,
-    SDL_JOYBALLMOTION,
-    SDL_JOYHATMOTION,
-    SDL_JOYBUTTONDOWN,
-    SDL_JOYBUTTONUP,
-    SDL_QUIT,
-    SDL_SYSWMEVENT,
-    SDL_EVENT_RESERVEDA,
-    SDL_EVENT_RESERVEDB,
-    SDL_VIDEORESIZE,
-    SDL_VIDEOEXPOSE,
-    SDL_EVENT_RESERVED2,
-    SDL_EVENT_RESERVED3,
-    SDL_EVENT_RESERVED4,
-    SDL_EVENT_RESERVED5,
-    SDL_EVENT_RESERVED6,
-    SDL_EVENT_RESERVED7) = range(24)
-SDL_USEREVENT = 24
-SDL_NUMEVENTS = 32
-
-def SDL_EVENTMASK(x):
-    '''Used for predefining event masks.'''
-    return 1 << x
-
-# enum SDL_EventMask
-SDL_ACTIVEEVENTMASK     = SDL_EVENTMASK(SDL_ACTIVEEVENT)
-SDL_KEYDOWNMASK         = SDL_EVENTMASK(SDL_KEYDOWN)
-SDL_KEYUPMASK           = SDL_EVENTMASK(SDL_KEYUP)
-SDL_KEYEVENTMASK        = SDL_KEYUPMASK | \
-                          SDL_KEYDOWNMASK
-SDL_MOUSEMOTIONMASK     = SDL_EVENTMASK(SDL_MOUSEMOTION)
-SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)
-SDL_MOUSEBUTTONUPMASK   = SDL_EVENTMASK(SDL_MOUSEBUTTONUP)
-SDL_MOUSEEVENTMASK      = SDL_MOUSEMOTIONMASK | \
-                          SDL_MOUSEBUTTONDOWNMASK | \
-                          SDL_MOUSEBUTTONUPMASK
-SDL_JOYAXISMOTIONMASK   = SDL_EVENTMASK(SDL_JOYAXISMOTION)
-SDL_JOYBALLMOTIONMASK   = SDL_EVENTMASK(SDL_JOYBALLMOTION)
-SDL_JOYHATMOTIONMASK    = SDL_EVENTMASK(SDL_JOYHATMOTION)
-SDL_JOYBUTTONDOWNMASK   = SDL_EVENTMASK(SDL_JOYBUTTONDOWN)
-SDL_JOYBUTTONUPMASK     = SDL_EVENTMASK(SDL_JOYBUTTONUP)
-SDL_JOYEVENTMASK        = SDL_JOYAXISMOTIONMASK | \
-                          SDL_JOYBALLMOTIONMASK | \
-                          SDL_JOYHATMOTIONMASK | \
-                          SDL_JOYBUTTONDOWNMASK | \
-                          SDL_JOYBUTTONUPMASK
-SDL_QUITMASK            = SDL_EVENTMASK(SDL_QUIT)
-SDL_SYSWMEVENTMASK      = SDL_EVENTMASK(SDL_SYSWMEVENT)
-SDL_VIDEORESIZEMASK     = SDL_EVENTMASK(SDL_VIDEORESIZE)
-SDL_VIDEOEXPOSEMASK     = SDL_EVENTMASK(SDL_VIDEOEXPOSE)
-
-# enum SDL_eventaction
-(SDL_ADDEVENT,
-    SDL_PEEKEVENT,
-    SDL_GETEVENT) = range(3)
-
 class SDL_ActiveEvent(Structure):
     '''Application visibility event structure.
 
                 ('syswm', SDL_SysWMEvent)]
 
     types = {
-        SDL_ACTIVEEVENT: (SDL_ActiveEvent, 'active'),
-        SDL_KEYDOWN: (SDL_KeyboardEvent, 'key'),
-        SDL_KEYUP: (SDL_KeyboardEvent, 'key'),
-        SDL_MOUSEMOTION: (SDL_MouseMotionEvent, 'motion'),
-        SDL_MOUSEBUTTONDOWN: (SDL_MouseButtonEvent, 'button'),
-        SDL_MOUSEBUTTONUP: (SDL_MouseButtonEvent, 'button'),
-        SDL_JOYAXISMOTION: (SDL_JoyAxisEvent, 'jaxis'),
-        SDL_JOYBALLMOTION: (SDL_JoyBallEvent, 'jball'),
-        SDL_JOYHATMOTION: (SDL_JoyHatEvent, 'jhat'),
-        SDL_JOYBUTTONDOWN: (SDL_JoyButtonEvent, 'jbutton'),
-        SDL_JOYBUTTONUP: (SDL_JoyButtonEvent, 'jbutton'),
-        SDL_VIDEORESIZE: (SDL_ResizeEvent, 'resize'),
-        SDL_VIDEOEXPOSE: (SDL_ExposeEvent, 'expose'),
-        SDL_QUIT: (SDL_QuitEvent, 'quit'),
-        SDL_SYSWMEVENT: (SDL_SysWMEvent, 'syswm')
+        SDL.constants.SDL_ACTIVEEVENT: (SDL_ActiveEvent, 'active'),
+        SDL.constants.SDL_KEYDOWN: (SDL_KeyboardEvent, 'key'),
+        SDL.constants.SDL_KEYUP: (SDL_KeyboardEvent, 'key'),
+        SDL.constants.SDL_MOUSEMOTION: (SDL_MouseMotionEvent, 'motion'),
+        SDL.constants.SDL_MOUSEBUTTONDOWN: (SDL_MouseButtonEvent, 'button'),
+        SDL.constants.SDL_MOUSEBUTTONUP: (SDL_MouseButtonEvent, 'button'),
+        SDL.constants.SDL_JOYAXISMOTION: (SDL_JoyAxisEvent, 'jaxis'),
+        SDL.constants.SDL_JOYBALLMOTION: (SDL_JoyBallEvent, 'jball'),
+        SDL.constants.SDL_JOYHATMOTION: (SDL_JoyHatEvent, 'jhat'),
+        SDL.constants.SDL_JOYBUTTONDOWN: (SDL_JoyButtonEvent, 'jbutton'),
+        SDL.constants.SDL_JOYBUTTONUP: (SDL_JoyButtonEvent, 'jbutton'),
+        SDL.constants.SDL_VIDEORESIZE: (SDL_ResizeEvent, 'resize'),
+        SDL.constants.SDL_VIDEOEXPOSE: (SDL_ExposeEvent, 'expose'),
+        SDL.constants.SDL_QUIT: (SDL_QuitEvent, 'quit'),
+        SDL.constants.SDL_SYSWMEVENT: (SDL_SysWMEvent, 'syswm')
     }
 
     def __repr__(self):
         if self.type in self.types:
             return self.types[self.type][0].__repr__(self)
-        elif self.type >= SDL_USEREVENT:    # SDL_MAXEVENTS not defined
+        elif self.type >= SDL.constants.SDL_USEREVENT: 
+            # SDL_MAXEVENTS not defined
             return SDL_UserEvent.__repr__(self)
         return 'SDLEvent(type=%d)' % self.type
 
         '''
         if self.type in self.types:
             return getattr(self, self.types[self.type][1])
-        elif self.type >= SDL_USEREVENT:    # SDL_MAXEVENTS not defined
+        elif self.type >= SDL.constants.SDL_USEREVENT:    
+            # SDL_MAXEVENTS not defined
             return self.user
         return self
 
     :return: list of SDL_Event (or subclass)
     :see: `SDL_PushEvent`, `SDL_HaveEvents`
     '''
-    if action == SDL_ADDEVENT:
+    if action == SDL.constants.SDL_ADDEVENT:
         raise NotImplementedError, 'Use SDL_PushEvent to add events'
     ar = (SDL_Event * numevents)()
     num = _SDL_PeepEvents(ar, numevents, action, mask)
     :return: True if at least one event matches the mask in the event
         queue.
     '''
-    num = _SDL_PeepEvents(None, 1, SDL_PEEKEVENT, mask)
+    num = _SDL_PeepEvents(None, 1, SDL.constants.SDL_PEEKEVENT, mask)
     return num > 0
 
 _SDL_PollEvent = SDL.dll.private_function('SDL_PollEvent',
     arg_types=[SDL_Joystick_p, c_int],
     return_type=c_short)
 
-SDL_HAT_RIGHTUP = SDL.constants.SDL_HAT_RIGHT | SDL.constants.SDL_HAT_UP
-SDL_HAT_RIGHTDOWN = SDL.constants.SDL_HAT_RIGHT | SDL.constants.SDL_HAT_DOWN
-SDL_HAT_LEFTUP = SDL.constants.SDL_HAT_LEFT | SDL.constants.SDL_HAT_UP
-SDL_HAT_LEFTDOWN = SDL.constants.SDL_HAT_LEFT | SDL.constants.SDL_HAT_DOWN
-
 SDL_JoystickGetHat = SDL.dll.function('SDL_JoystickGetHat',
     '''Get the current state of POV hat on a joystick.
 
             return SDL.array.SDL_array(self._abuf, self.alen, c_ubyte)
         raise AttributeException, attr
 
-# begin enum Mix_Fading
-(MIX_NO_FADING,
-    MIX_FADING_OUT,
-    MIX_FADING_IN) = range(3)
-# end enum Mix_Fading
-
-# begin enum Mix_MusicType
-(MUS_NONE,
-    MUS_CMD,
-    MUS_WAV,
-    MUS_MOD,
-    MUS_MID,
-    MUS_OGG,
-    MUS_MP3) = range(7)
-# end enum Mix_MusicType
-
 # opaque type
 _Mix_Music = c_void_p
 
 # Fill in non-standard linked version now, so "since" declarations can work
 _dll._version = SDL.dll._version_parts(Sound_GetLinkedVersion())
 
-# enum Sound_SampleFlags
-SOUND_SAMPLEFLAG_NONE       = 0
-SOUND_SAMPLEFLAG_CANSEEK    = 1
-SOUND_SAMPLEFLAG_EOF        = 1 << 29
-SOUND_SAMPLEFLAG_ERROR      = 1 << 30
-SOUND_SAMPLEFLAG_EGAIN      = 1 << 31
-# end enum Sound_SampleFlags
-
 class Sound_AudioInfo(Structure):
     '''Information about an existing sample's format.
 
             return p
 
 
-# enum SDL_GLattr
-(SDL_GL_RED_SIZE,
-    SDL_GL_GREEN_SIZE,
-    SDL_GL_BLUE_SIZE,
-    SDL_GL_ALPHA_SIZE,
-    SDL_GL_BUFFER_SIZE,
-    SDL_GL_DOUBLEBUFFER,
-    SDL_GL_DEPTH_SIZE,
-    SDL_GL_STENCIL_SIZE,
-    SDL_GL_ACCUM_RED_SIZE,
-    SDL_GL_ACCUM_GREEN_SIZE,
-    SDL_GL_ACCUM_BLUE_SIZE,
-    SDL_GL_ACCUM_ALPHA_SIZE,
-    SDL_GL_STEREO,
-    SDL_GL_MULTISAMPLEBUFFERS,
-    SDL_GL_MULTISAMPLESAMPLES,
-    SDL_GL_ACCELERATED_VISUAL,
-    SDL_GL_SWAP_CONTROL) = range(17)
-# end enum SDL_Glattr
-
 # SDL_VideoInit and SDL_VideoQuit not implemented (internal only, according
 # to SDL_video.h).
 
     return_type=c_int,
     error_return=0)
 
-# enum SDL_GrabMode
-(SDL_GRAB_QUERY,
-    SDL_GRAB_OFF,
-    SDL_GRAB_ON) = range(-1,2)
-# end enum SDL_GrabMode
-
 SDL_WM_GrabInput = SDL.dll.function('SDL_WM_GrabInput',
     '''Set the grab mode for the mouse and keyboard.
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.