PKx4(hK7K7 SDL/audio.py#!/usr/bin/env python '''Access to the raw audio mixing buffer. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' from ctypes import * import sys import SDL.array import SDL.constants import SDL.dll import SDL.rwops _SDL_AudioSpec_fn = \ CFUNCTYPE(POINTER(c_ubyte), POINTER(c_ubyte), POINTER(c_ubyte), c_int) class SDL_AudioSpec(Structure): '''Audio format structure. The calculated values in this structure are calculated by `SDL_OpenAudio`. :Ivariables: `freq` : int DSP frequency, in samples per second `format` : int Audio data format. One of AUDIO_U8, AUDIO_S8, AUDIO_U16LSB, AUDIO_S16LSB, AUDIO_U16MSB or AUDIO_S16MSB `channels` : int Number of channels; 1 for mono or 2 for stereo. `silence` : int Audio buffer silence value (calculated) `samples` : int Audio buffer size in samples (power of 2) `size` : int Audio buffer size in bytes (calculated) ''' _fields_ = [('freq', c_int), ('format', c_ushort), ('channels', c_ubyte), ('silence', c_ubyte), ('samples', c_ushort), ('_padding', c_ushort), ('size', c_uint), ('_callback', _SDL_AudioSpec_fn), ('_userdata', c_void_p)] _SDL_AudioCVT_p = POINTER('SDL_AudioCVT') _SDL_AudioCVT_filter_fn = \ CFUNCTYPE(POINTER(c_ubyte), _SDL_AudioCVT_p, c_ushort) class SDL_AudioCVT(Structure): '''Set of audio conversion filters and buffers. :Ivariables: `needed` : int 1 if conversion is possible `src_format` : int Source audio format. See `SDL_AudioSpec.format` `dst_format` : int Destination audio format. See `SDL_AudioSpec.format` `rate_incr` : float Rate conversion increment `len` : int Length of original audio buffer `len_cvt` : int Length of converted audio buffer `len_mult` : int Buffer must be len * len_mult big `len_ratio` : float Given len, final size is len * len_ratio `filter_index` : int Current audio conversion function ''' _fields_ = [('needed', c_int), ('src_format', c_ushort), ('dst_format', c_ushort), ('rate_incr', c_double), ('buf', POINTER(c_ubyte)), ('len', c_int), ('len_cvt', c_int), ('len_mult', c_int), ('len_ratio', c_double), ('filters', _SDL_AudioCVT_filter_fn * 10), ('filter_index', c_int)] SetPointerType(_SDL_AudioCVT_p, SDL_AudioCVT) # SDL_AudioInit and SDL_AudioQuit marked private _SDL_AudioDriverName = SDL.dll.private_function('SDL_AudioDriverName', arg_types=[c_char_p, c_int], return_type=c_char_p) def SDL_AudioDriverName(maxlen=1024): ''' Returns the name of the audio driver. Returns None if no driver has been initialised. :Parameters: `maxlen` Maximum length of the returned driver name; defaults to 1024. :rtype: string ''' buf = create_string_buffer(maxlen) if _SDL_AudioDriverName(buf, maxlen): return buf.value return None def _ctype_audio_format(fmt): if fmt == SDL.constants.AUDIO_U8: return c_ubyte elif fmt == SDL.constants.AUDIO_S8: return c_char elif fmt in (SDL.constants.AUDIO_U16LSB, SDL.constants.AUDIO_U16MSB): return c_ushort elif fmt in (SDL.constants.AUDIO_S16LSB, SDL.constants.AUDIO_S16MSB): return c_short else: raise TypeError, 'Unsupported format %r' % fmt _SDL_OpenAudio = SDL.dll.private_function('SDL_OpenAudio', arg_types=[POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec)], return_type=c_int, error_return=-1) def SDL_OpenAudio(desired, obtained): '''Open the audio device with the desired parameters. If successful, the actual hardware parameters will be set in the instance passed into `obtained`. If `obtained` is None, the audio data passed to the callback function will be guaranteed to be in the requested format, and will be automatically converted to the hardware audio format if necessary. An exception will be raised if the audio device couldn't be opened, or the audio thread could not be set up. The fields of `desired` are interpreted as follows: `desired.freq` desired audio frequency in samples per second `desired.format` desired audio format, i.e., one of AUDIO_U8, AUDIO_S8, AUDIO_U16LSB, AUDIO_S16LSB, AUDIO_U16MSB or AUDIO_S16MSB `desired.samples` size of the audio buffer, in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware. Good values seem to range between 512 and 8096 inclusive, depending on the application and CPU speed. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time. A stereo sample consists of both right and left channels in LR ordering. Note that the number of samples is directly related to time by the following formula:: ms = (samples * 1000) / freq `desired.size` size in bytes of the audio buffer; calculated by SDL_OpenAudio. `desired.silence` value used to set the buffer to silence; calculated by SDL_OpenAudio. `desired.callback` a function that will be called when the audio device is ready for more data. The signature of the function should be:: callback(userdata: any, stream: SDL_array) -> None The function is called with the userdata you specify (see below), and an SDL_array of the obtained format which you must fill with audio data. This function usually runs in a separate thread, so you should protect data structures that it accesses by calling `SDL_LockAudio` and `SDL_UnlockAudio` in your code. `desired.userdata` passed as the first parameter to your callback function. The audio device starts out playing silence when it's opened, and should be enabled for playing by calling ``SDL_PauseAudio(False)`` when you are ready for your audio callback function to be called. Since the audio driver may modify the requested size of the audio buffer, you should allocate any local mixing buffers after you open the audio device. :Parameters: - `desired`: `SDL_AudioSpec` - `obtained`: `SDL_AudioSpec` or None ''' if not hasattr(desired, 'callback'): raise TypeError, 'Attribute "callback" not set on "desired"' userdata = getattr(desired, 'userdata', None) callback = desired.callback ctype = [_ctype_audio_format(desired.format)] # List, so mutable def cb(data, stream, len): ar = SDL.array.SDL_array(stream, len/sizeof(ctype[0]), ctype[0]) callback(userdata, ar) desired._callback = _SDL_AudioSpec_fn(cb) _SDL_OpenAudio(desired, obtained) if obtained: obtained.userdata = desired.userdata obtained.callback = desired.callback ctype[0] = _ctype_audio_format(obtained.format) SDL_GetAudioStatus = SDL.dll.function('SDL_GetAudioStatus', '''Get the current audio state. :rtype: int :return: one of SDL_AUDIO_STOPPED, SDL_AUDIO_PLAYING, SDL_AUDIO_PAUSED ''', args=[], arg_types=[], return_type=c_int) SDL_PauseAudio = SDL.dll.function('SDL_PauseAudio', '''Pause and unpause the audio callback processing. It should be called with a parameter of 0 after opening the audio device to start playing sound. This is so you can safely initalize data for your callback function after opening the audio device. Silence will be written to the audio device during the pause. :Parameters: - `pause_on`: int ''', args=['pause_on'], arg_types=[c_int], return_type=None) _SDL_LoadWAV_RW = SDL.dll.private_function('SDL_LoadWAV_RW', arg_types=[POINTER(SDL.rwops.SDL_RWops), c_int, POINTER(SDL_AudioSpec), POINTER(POINTER(c_ubyte)), POINTER(c_uint)], return_type=POINTER(SDL_AudioSpec), require_return=True) def SDL_LoadWAV_RW(src, freesrc): '''Load a WAVE from the data source. The source is automatically freed if `freesrc` is non-zero. For example, to load a WAVE file, you could do:: SDL_LoadWAV_RW(SDL_RWFromFile('sample.wav', 'rb'), 1) You need to free the returned buffer with `SDL_FreeWAV` when you are done with it. :Parameters: - `src`: `SDL_RWops` - `freesrc`: int :rtype: (`SDL_AudioSpec`, `SDL_array`) :return: a tuple (`spec`, `audio_buf`) where `spec` describes the data format and `audio_buf` is the buffer containing audio data. ''' spec = SDL_AudioSpec() audio_buf = POINTER(c_ubyte)() audio_len = c_uint() _SDL_LoadWAV_RW(src, freesrc, spec, byref(audio_buf), byref(audio_len)) ctype = _ctype_audio_format(spec.format) return (spec, SDL.array.SDL_array(audio_buf, audio_len.value/sizeof(ctype), ctype)) def SDL_LoadWAV(file): '''Load a WAVE from a file. :Parameters: - `file`: str :rtype: (`SDL_AudioSpec`, `SDL_array`) :see: `SDL_LoadWAV_RW` ''' return SDL_LoadWAV_RW(SDL.rwops.SDL_RWFromFile(file, 'rb'), 1) _SDL_FreeWAV = SDL.dll.private_function('SDL_FreeWAV', arg_types=[POINTER(c_ubyte)], return_type=None) def SDL_FreeWAV(audio_buf): '''Free a buffer previously allocated with `SDL_LoadWAV_RW` or `SDL_LoadWAV`. :Parameters: - `audio_buf`: `SDL_array` ''' _SDL_FreeWAV(audio_buf.as_bytes().as_ctypes()) _SDL_BuildAudioCVT = SDL.dll.private_function('SDL_BuildAudioCVT', arg_types=[POINTER(SDL_AudioCVT), c_ushort, c_ubyte, c_uint, c_ushort, c_ubyte, c_uint], return_type=c_int, error_return=-1) def SDL_BuildAudioCVT(src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate): '''Take a source format and rate and a destination format and rate, and return a `SDL_AudioCVT` structure. The `SDL_AudioCVT` structure is used by `SDL_ConvertAudio` to convert a buffer of audio data from one format to the other. :Parameters: - `src_format`: int - `src_channels`: int - `src_rate`: int - `dst_format`: int - `dst_channels`: int - `dst_rate`: int :rtype: `SDL_AudioCVT` ''' cvt = SDL_AudioCVT() _SDL_BuildAudioCVT(cvt, src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate) return cvt SDL_ConvertAudio = SDL.dll.function('SDL_ConvertAudio', '''Convert audio data in-place. Once you have initialized the 'cvt' structure using `SDL_BuildAudioCVT`, created an audio buffer ``cvt.buf``, and filled it with ``cvt.len`` bytes of audio data in the source format, this function will convert it in-place to the desired format. The data conversion may expand the size of the audio data, so the buffer ``cvt.buf`` should be allocated after the cvt structure is initialized by `SDL_BuildAudioCVT`, and should be ``cvt->len*cvt->len_mult`` bytes long. Note that you are responsible for allocating the buffer. The recommended way is to construct an `SDL_array` of the correct size, and set ``cvt.buf`` to the result of `SDL_array.as_ctypes`. :Parameters: - `cvt`: `SDL_AudioCVT` :rtype: int :return: undocumented ''', args=['cvt'], arg_types=[POINTER(SDL_AudioCVT)], return_type=c_int) _SDL_MixAudio = SDL.dll.private_function('SDL_MixAudio', arg_types=[POINTER(c_ubyte), POINTER(c_ubyte), c_uint, c_int], return_type=None) def SDL_MixAudio(dst, src, length, volume): '''Mix two audio buffers. This takes two audio buffers of the playing audio format and mixes them, performing addition, volume adjustment, and overflow clipping. The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME for full audio volume. Note this does not change hardware volume. This is provided for convenience -- you can mix your own audio data. :note: SDL-ctypes doesn't know the current play format, so you must always pass in byte buffers (SDL_array or sequence) to this function, rather than of the native data type. :Parameters: - `dst`: `SDL_array` - `src`: `SDL_array` - `length`: int - `volume`: int ''' dstref, dst = SDL.array.to_ctypes(dst, len(dst), c_ubyte) srcref, src = SDL.array.to_ctypes(src, len(src), c_ubyte) if len(dst) < length: raise TypeError, 'Destination buffer too small' elif len(src) < length: raise TypeError, 'Source buffer too small' _SDL_MixAudio(dst, src, length, volume) SDL_LockAudio = SDL.dll.function('SDL_LockAudio', '''Guarantee the callback function is not running. The lock manipulated by these functions protects the callback function. During a LockAudio/UnlockAudio pair, you can be guaranteed that the callback function is not running. Do not call these from the callback function or you will cause deadlock. ''', args=[], arg_types=[], return_type=None) SDL_UnlockAudio = SDL.dll.function('SDL_UnlockAudio', '''Release the audio callback lock. :see: `SDL_LockAudio` ''', args=[], arg_types=[], return_type=None) SDL_CloseAudio = SDL.dll.function('SDL_CloseAudio', '''Shut down audio processing and close the audio device. ''', args=[], arg_types=[], return_type=None) PK)5 SDL/keyboard.pyc; Dc @sdZdZdZdkTdkZdefdYZeii ddd d gd e gd e Z eii d dd ddgd e e gd e Z eii dd ee ee gd eddddfZdZeii dd ee gd eeZdZeii ddd gd gd e Zeii ddd dgd e gd eZeii dd e gd eZdZdS( siKeyboard event handling. You should call `SDL_Init` with `SDL_INIT_VIDEO` before using these functions. srestructuredtexts$Id: $(s*Ns SDL_keysymcBsAtZdZdefdefdefdefgZdZRS(sKeysym structure * The scancode is hardware dependent, and should not be used by general applications. If no hardware scancode is available, it will be 0 * The `unicode` translated character is only available when character translation is enabled by `SDL_EnableUNICODE`. If non-empty, this is unicode string of unit length. :Ivariables: `scancode` : int Hardware specific scancode `sym` : int SDL virtual keysym (SDLK_*) `mod` : int Bitwise OR of current key modifiers `unicode` : string Unicode character represented by keypress, or the empty string if translation is not possible. sscancodessymsmods_unicodecCs(|djot|iSntdS(Nsunicode(snamesunichrsselfs_unicodesAttributeError(sselfsname((s,build/bdist.linux-x86_64/egg/SDL/keyboard.pys __getattr__*s (s__name__s __module__s__doc__sc_ubytesc_intsc_ushorts_fields_s __getattr__(((s,build/bdist.linux-x86_64/egg/SDL/keyboard.pys SDL_keysyms *sSDL_EnableUNICODEsEnable or disable Unicode translation of keyboard input. This translation has some overhead, so translation defaults off. :Parameters: `enable` : int * if 1, translation is enabled * if 0, translation is disabled. * if -1, the translation is not changed. :rtype: int :return: the previous state of keyboard translation sargssenables arg_typess return_typesSDL_EnableKeyRepeatsEnable keyboard repeat. Keyboard repeat defaults to off. :Parameters: `delay` : int the initial delay in milliseconds between the time when a key is pressed, and keyboard repeat begins. If 0, keyboard repeat is disabled. `interval` : int the time in milliseconds between keyboard repeat events. :rtype: int :return: undocumented (FIXME) sdelaysintervalsSDL_GetKeyRepeatssinceiii cCsEttf\}}tt|t||i|ifSdS(sGet the keyboard repeat parameters. :see: `SDL_EnableKeyRepeat` :rtype: (int, int) :return: tuple (delay, interval), as defined in `SDL_EnableKeyRepeat` :since: 1.2.10 N(sc_intsdelaysintervals_SDL_GetKeyRepeatsbyrefsvalue(sdelaysinterval((s,build/bdist.linux-x86_64/egg/SDL/keyboard.pysSDL_GetKeyRepeatZssSDL_GetKeyStatecCsHt}tt|}t|tt|ii }t |SdS(sGet a snapshot of the current state of the keyboard. Example:: keystate = SDL_GetKeyState() if keystate[SDLK_RETURN]: print ' is pressed' :rtype: list :return: a list of integers indexed by the SDLK_* symbols N( sc_intsnumkeyss_SDL_GetKeyStatesbyrefskeystatescastsPOINTERsc_ubytesvaluescontentss keystate_arslist(snumkeysskeystates keystate_ar((s,build/bdist.linux-x86_64/egg/SDL/keyboard.pysSDL_GetKeyStatejs  sSDL_GetModStates9Get the current key modifier state. :rtype: int sSDL_SetModStatesSet the current key modifier state. This does not change the keyboard state, only the key modifier flags. :Parameters: - `modstate`: int smodstatesSDL_GetKeyNamecCst|SdS(scGet the name of an SDL virtual keysym. :Parameters: - `key`: int :rtype: string N(s_SDL_GetKeyNameskey(skey((s,build/bdist.linux-x86_64/egg/SDL/keyboard.pysSDL_GetKeyNames(s__doc__s __docformat__s __version__sctypessSDL.dllsSDLs Structures SDL_keysymsdllsfunctionsc_intsSDL_EnableUNICODEsSDL_EnableKeyRepeatsprivate_functionsPOINTERsNones_SDL_GetKeyRepeatsSDL_GetKeyRepeatsc_ubytes_SDL_GetKeyStatesSDL_GetKeyStatesSDL_GetModStatesSDL_SetModStatesc_char_ps_SDL_GetKeyNamesSDL_GetKeyName(s_SDL_GetKeyNamesSDL_EnableKeyRepeats SDL_keysyms_SDL_GetKeyRepeats __docformat__s_SDL_GetKeyStatesSDL_GetKeyNamesSDL_GetKeyStatesSDL_GetKeyRepeatsSDLsSDL_GetModStates __version__sSDL_EnableUNICODEsSDL_SetModState((s,build/bdist.linux-x86_64/egg/SDL/keyboard.pys?sL                     PK)5h SDL/video.pyc; #Dc@s dZdZdZdkTdkZdkZdkZdkZdk Zde fdYZ de fdYZ e Z d e fd YZd e fd YZd e fdYZdZeeeeee eeee Zde fdYZde fdYZeiiddeegdeZddZeiidddeedeZeiidddeedeZ eiiddd d!d"d#d$gdeeee!gdeZ"eiid%deee!gdeee Z#d&Z$eiid'd(d d!d"d#d$gdeeee!gdeeded)eZ%eiid*deeeee gde&Z'd+Z(eiid,d-d d.d/d0d1d2gdeeeee!e!gde&Z)eiid3d4d d.gdeegded5d6Z*eiid7d8d d9d:d;gde+e+e+gded5d6Z,eiid<dee-ee-ee-gdeZ.d=Z/eiid>dee-ee-ee-gdeZ0d?Z1eiid@deeee eegdeZ2dAZ3eiidBdeeeee eegdeZ4dCZ5eiidDdEd dFdGdHdIgdeee6e6e6gde!Z7eiidJdKd dFdGdHdIdLgdeee6e6e6e6gde!Z8eiidMde!eeee6ee6ee6gde&Z9dNZ:eiidOde!eeee6ee6ee6ee6gde&Z;dPZ<eiidQdRd d$d!d"dSdTdUdVdWgde!eeee!e!e!e!gdeeded)eZ=eiidXdee6eeee!e!e!e!gdeeded)eZ>dYZ?eiidZd[d d\gdeegde&Z@eiid]d^d d\gdeegded5d6ZAeiid_d`d d\gdeegde&ZBeiidadbd dcddgdeeiCiDegdeeded)eZEdeZFeiidfdgd d\dhdigdeeeeiCiDegded5d6ZGdjZHeiidkdld d\dmdngdeee!e!gded5d6ZIeiidodpd d\dmdqgdeee!e!gdeZJeiidrdsd d\dtgdeeee gdeZKeiidudeeee gde&ZLdvZMeiidwdxd dcdyd$gdeeeee!gdeeded)eZNeiidzd{d dcd|dhd}gdeeee eeee gded~dZOeiidzdd dcd|dhd}gdeeee eeee gded~dZPeiiddd dcd|dhd}gdeeee eeee gded~dZQeiiddd dhd}dgdeeee e!gded5d6ZReiiddd d\gdeegdeeded)eZSeiiddd d\gdeegdeeded)eZTeiiddd d!d"dFdgdeee!eegdeeded)eZUeiiddd dgdeegdeZVeiiddd dgdeegde&ZWeiiddd dd}gdeeee gdeZXeiiddd dgdeegde&ZYeiiddd ddgde!egdeZZeiiddeeegdeZ[dZ\eiiddd gdgde&Z]eiiddeegde&Z^dZ_eiiddeeeegde&Z`dZaeiiddeeee6gde&ZbdZceiiddd gdgded~d6Zdeiiddd d\gdeegded~d6Zeeiiddd dgdegdeZfdS(sAccess to the SDL raw framebuffer window. :group YUV overlay functions: SDL_CreateYUVOverlay, SDL_LockYUVOverlay, SDL_UnlockYUVOverlay, SDL_DisplayYUVOverlay, SDL_FreeYUVOverlay :group OpenGL support functions: SDL_GL_SetAttribute, SDL_GL_GetAttribute, SDL_GL_SwapBuffers :group Window manager functions: SDL_WM_SetCaption, SDL_WM_GetCaption, SDL_WM_SetIcon, SDL_WM_IconifyWindow, SDL_WM_ToggleFullScreen, SDL_WM_GrabInput srestructuredtexts$Id: $(s*NsSDL_RectcBshtZdZdefdefdefdefgZdddddZdZdZd Z RS( s<Rectangle structure. Rectangles must be normalised, i.e., with their width and height greater than zero. :Ivariables: `x` : int Top-left x coordinate. `y` : int Top-left y coordinate. `w` : int Width `h` : int Height sxsyswshicCs(||_||_||_||_dS(N(sxsselfsyswsh(sselfsxsyswsh((s)build/bdist.linux-x86_64/egg/SDL/video.pys__init__2s   cCs$d|i|i|i|ifSdS(Ns SDL_Rect(x=%d, y=%d, w=%d, h=%d)(sselfsxsyswsh(sself((s)build/bdist.linux-x86_64/egg/SDL/video.pys__repr__8scCs#t|i|i|i|iSdS(N(sSDL_Rectsselfsxsyswsh(sself((s)build/bdist.linux-x86_64/egg/SDL/video.pys__copy__<scCs#t|i|i|i|iSdS(N(sSDL_Rectsselfsxsyswsh(sselfsmemo((s)build/bdist.linux-x86_64/egg/SDL/video.pys __deepcopy__?s( s__name__s __module__s__doc__sc_shortsc_ushorts_fields_s__init__s__repr__s__copy__s __deepcopy__(((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_Rects *  s SDL_ColorcBshtZdZdefdefdefdefgZdddddZdZdZd ZRS( s+Structure defining a single color. ``SDL_Colour`` is a synonym for ``SDL_Color``. :Ivariables: `r` : int Red component, in range [0,255] `g` : int Green component, in range [0,255] `b` : int Blue component, in range [0,255] srsgsbsunusedicCs||_||_||_dS(N(srsselfsgsb(sselfsrsgsbsunused((s)build/bdist.linux-x86_64/egg/SDL/video.pys__init__Us  cCsd|i|i|ifSdS(NsSDL_Color(r=%d, g=%d, b=%d)(sselfsrsgsb(sself((s)build/bdist.linux-x86_64/egg/SDL/video.pys__repr__ZscCst|i|i|iSdS(N(s SDL_Colorsselfsrsgsb(sself((s)build/bdist.linux-x86_64/egg/SDL/video.pys__copy__^scCst|i|i|iSdS(N(s SDL_Colorsselfsrsgsb(sselfsmemo((s)build/bdist.linux-x86_64/egg/SDL/video.pys __deepcopy__as( s__name__s __module__s__doc__sc_ubytes_fields_s__init__s__repr__s__copy__s __deepcopy__(((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_ColorBs *  s SDL_PalettecBs5tZdZdefdeefgZdZRS(sColor palette array. :Ivariables: `ncolors` : int Number of colors in the palette `colors` : `SDL_array` Array of indexed colors of type `SDL_Color`. sncolorss_colorscCs:|djo tii|i|itSnt|dS(Nscolors( snamesSDLsarrays SDL_arraysselfs_colorssncolorss SDL_ColorsAttributeError(sselfsname((s)build/bdist.linux-x86_64/egg/SDL/video.pys __getattr__ss  (s__name__s __module__s__doc__sc_intsPOINTERs SDL_Colors_fields_s __getattr__(((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_Palettefs sSDL_PixelFormatcBstZdZdeefdefdefdefdefdefdefdefd efd efd efd efd efdefdefdefdefgZdZdZ RS(sJRead-only surface format structure. :Ivariables: `BitsPerPixel` : int Number of bits per pixel `BytesPerPixel` : int Number of bytes per pixel. This is not necessarily 8 * BitsPerPixel. `Rloss` : int Number of bits lost from an 8-bit red component `Gloss` : int Number of bits lost from an 8-bit green component `Bloss` : int Number of bits lost from an 8-bit blue component `Aloss` : int Number of bits lost from an 8-bit alpha component `Rshift` : int Number of bits to shift right red component when packing `Gshift` : int Number of bits to shift right green component when packing `Bshift` : int Number of bits to shift right blue component when packing `Ashift` : int Number of bits to shift right alpha component when packing `Rmask` : int 32-bit mask of red component `Gmask` : int 32-bit mask of green component `Bmask` : int 32-bit mask of blue component `Amask` : int 32-bit mask of alpha component `colorkey` : int Packed transparent color key, if set. `alpha` : int Surface alpha, in range [0, 255] s_palettes BitsPerPixels BytesPerPixelsRlosssGlosssBlosssAlosssRshiftsGshiftsBshiftsAshiftsRmasksGmasksBmasksAmaskscolorkeysalphacCs7|djo |io|iiSntSntdS(Nspalette(snamesselfs_palettescontentssNonesAttributeError(sselfsname((s)build/bdist.linux-x86_64/egg/SDL/video.pys __getattr__s   cCst}|i|_|i|_|i|_|i|_|i|_|i|_|i |_ |i |_ |i |_ |i |_ |i |_ |i|_|i|_|i|_|i|_|i|_|i|_|SdS(N(sSDL_PixelFormatsfsselfs_palettes BitsPerPixels BytesPerPixelsRlosssGlosssBlosssAlosssRshiftsGshiftsBshiftsAshiftsRmasksGmasksBmasksAmaskscolorkeysalpha(sselfsf((s)build/bdist.linux-x86_64/egg/SDL/video.pys__copy__s&                  ( s__name__s __module__s__doc__sPOINTERs SDL_Palettesc_ubytesc_uints_fields_s __getattr__s__copy__(((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_PixelFormatys & s SDL_SurfacecBstZdZdefdeefdefdefdefdeefdefde fd e fd efd efd e fd efdefgZ dZ RS(sRead-only surface structure. :Ivariables: `format` : `SDL_PixelFormat` Pixel format used by this surface `w` : int Width `h` : int Height `pitch` : int Number of bytes between consecutive rows of pixel data. Note that this may be larger than the width. `pixels` : SDL_array Buffer of integers of the type given in the pixel format. Each element of the array corresponds to exactly one pixel when ``format.BitsPerPixel`` is 8, 16 or 32; otherwise each element is exactly one byte. Modifying this array has an immediate effect on the pixel data of the surface. See `SDL_LockSurface`. sflagss_formatswshspitchs_pixelss_offsets_hwdatas clip_rects_unused1s_lockeds_maps_format_versions _refcountcCsN|djo|iiSn'|djo|i otiidn|ii }|i |ii |i }|djo0t}|i d|}||i dd}n||djo t}ne|djo t}nN|djot}|i |i }n'|d jo t}ntiid tii|i||Snt|dS( NsformatspixelssSurface needs lockingiiiiii sUnsupported bytes-per-pixel(snamesselfs_formatscontentss_pixelssSDLserrors SDL_Exceptionsformats BitsPerPixelsbppspitchs BytesPerPixelshscountsc_ubytesszs byte_pitchsc_ushortsc_uintsarrays SDL_arraysAttributeError(sselfsnamescountsszsbpps byte_pitch((s)build/bdist.linux-x86_64/egg/SDL/video.pys __getattr__s.            ( s__name__s __module__s__doc__sc_uintsPOINTERsSDL_PixelFormatsc_intsc_shortsc_ubytesc_void_psSDL_Rects_fields_s __getattr__(((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_Surfaces cCs9|ip+|itiitiiBtiiB@djSdS(sEvaluates to true if the surface needs to be locked before access. :Parameters: - `surface`: SDL_Surface :return: True if the surface needs to be locked before access, otherwise False. iN(ssurfaces_offsetsflagssSDLs constantss SDL_HWSURFACEs SDL_ASYNCBLITs SDL_RLEACCEL(ssurface((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_MUSTLOCKss SDL_VideoInfocBsPtZdZdefdefdeefdefdefgZdZRS(sUseful for determining the video hardware capabilities. :Ivariables: `hw_available` : bool True if hardware surfaces can be created `wm_available` : bool True if a window manager is available `blit_hw` : bool True if hardware to hardware blits are accelerated `blit_hw_CC` : bool True if hardware to hardware color-keyed blits are accelerated `blit_hw_A` : bool True if hardware to hardware alpha-blended blits are accelerated `blit_sw` : bool True if software to hardware blits are accelerated `blit_sw_CC` : bool True if software to hardware color-keyed blits are accelerated `blit_sw_A` : bool True if software to hardware alpha-blended blits are accelerated `blit_fill` : bool True if color fills are accelerated `video_mem` : int Total amount of video memory, in kilobytes (unreliable) `vfmt` : `SDL_PixelFormat` Pixel format of the video surface `current_w` : int Current video width. Available in SDL 1.2.10 and later. `current_h` : int Current video height. Available in SDL 1.2.10 and later. sbitfields video_mems_vfmts _current_ws _current_hcCs|djo|id@djSn>|djo|id@djSn|djo|id@djSn|djo|id @djSn|d jo|id @djSn|d jo|id @djSn|djo|id@djSnr|djo|id@djSnP|djo|id@djSn.|djo |io|iiSntSn|ddfjo1tii|dddft |d|Snt |dS(sRetrieve bitfields as bool. All bets are off about whether this will actually work (ordering of bitfields is compiler dependent.s hw_availableiis wm_availableisblit_hwis blit_hw_CCis blit_hw_Aisblit_swis blit_sw_CCi s blit_sw_Ai@s blit_fillisvfmts current_ws current_hi s_%sN( snamesselfsbitfields_vfmtscontentssNonesSDLsdllsassert_version_compatiblesgetattrsAttributeError(sselfsname((s)build/bdist.linux-x86_64/egg/SDL/video.pys __getattr__Hs6           ( s__name__s __module__s__doc__sc_uintsPOINTERsSDL_PixelFormatsc_ints_fields_s __getattr__(((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_VideoInfo"s 9s SDL_Overlayc BstZdZdefdefdefdefdeefdeeefdefdefd efg Z d Z RS( smThe YUV hardware video overlay. :Ivariables: `format` : int Overlay pixel layout. One of SDL_YV12_OVERLAY, SDL_IYUV_OVERLAY, SDL_YUY2_OVERLAY, SDL_UYVY_OVERLAY, SDL_YVYU_OVERLAY. `w` : int Width of the overlay. `h` : int Height of the overlay. `planes` : int Number of planes of pixel data. `pitches` : list of int List of pitches for each plane. `pixels` : list of `SDL_array` List of pixel buffers, one for each plane. All pixel buffers provided as byte buffers. sformatswshsplanesspitchess_pixelsshwfuncsshwdatasflagscCs|djo|id@djSn|djo|i otiidng}xQt|i D]@}|i ||i }|itii|i||tqcW|SndS(sRetrieve bitfields as bool. All bets are off about whether this will actually work (ordering of bitfields is compiler dependent.s hw_overlayiispixelssOverlay needs lockingN(snamesselfsflagss_pixelssSDLserrors SDL_Exceptionspsrangesplanessispitchesshsszsappendsarrays SDL_arraysc_byte(sselfsnamesszsisp((s)build/bdist.linux-x86_64/egg/SDL/video.pys __getattr__s   *( s__name__s __module__s__doc__sc_uintsc_intsPOINTERsc_shortsc_bytesc_void_ps_fields_s __getattr__(((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_Overlayjs i sSDL_VideoDriverNames arg_typess return_typeicCs/t|}t||o |iSntSdS(s Returns the name of the video driver. :Parameters: `maxlen` Maximum length of the returned driver name; defaults to 1024. :rtype: string N(screate_string_buffersmaxlensbufs_SDL_VideoDriverNamesvaluesNone(smaxlensbuf((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_VideoDriverNames   sSDL_GetVideoSurfacesReturn the current display surface. If SDL is doing format conversion on the display surface, this function returns the publicly visible surface, not the real video surface. :rtype: SDL_Surface sdereference_returnsSDL_GetVideoInfosReturn information about the video hardware. If this is called before `SDL_SetVideoMode`, the ``vfmt`` member of the returned structure will contain the pixel format of the "best" video mode. :rtype: SDL_VideoInfo sSDL_VideoModeOKsCheck to see if a particular video mode is supported. Returns 0 if the requested mode is not supported under any bit depth, or returns the bits-per-pixel of the closest available mode with the given width and height. If this bits-per-pixel is different from the one used when setting the video mode, `SDL_SetVideoMode` will succeed, but will emulate the requested bits-per-pixel with a shadow surface. The arguments to `SDL_VideoModeOK` are the same ones you would pass to `SDL_SetVideoMode`. :Parameters: - `width`: int - `height`: int - `bpp`: int - `flags`: int :rtype: int :return: bits-per-pixel of the closest available mode, or 0 if the mode is not supported. sargsswidthsheightsbppsflagss SDL_ListModescCst||}| ogSnt|idjotSnd}g}x.||o"|i ||i|d7}qLW|SdS(sReturn a list of available screen dimensions for the given format and video flags, sorted largest to smallest. Returns -1 if any size can be used, otherwise a list of `SDL_Rect` (which may be empty). If `format` is ``None``, the mode list will be for the format given by ``SDL_GetVideoInfo().vfmt``. :Parameters: - `format`: `SDL_PixelFormat` - `flags`: int :rtype: list :return: -1 or list of `SDL_Rect` iiiN( s_SDL_ListModessformatsflagssars addressofscontentssSDL_ANY_DIMENSIONsislstsappend(sformatsflagssislstsar((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_ListModess sSDL_SetVideoModes Set up a video mode with the specified width, height and bits-per-pixel. If `bpp` is 0, it is treated as the current display bits-per-pixel. The `flags` can be a bitwise-OR of: `SDL_ANYFORMAT` the SDL library will try to set the requested bits-per-pixel, but will return whatever video pixel format is available. The default is to emulate the requested pixel format if it is not natively available. `SDL_HWSURFACE` the video surface will be placed in video memory, if possible, and you may have to call `SDL_LockSurface` in order to access the raw framebuffer. Otherwise, the video surface will be created in system memory. `SDL_ASYNCBLIT` SDL will try to perform rectangle updates asynchronously, but you must always lock before accessing pixels. SDL will wait for updates to complete before returning from the lock. `SDL_HWPALETTE` the SDL library will guarantee that the colors set by `SDL_SetColors` will be the colors you get. Otherwise, in 8-bit mode, `SDL_SetColors` may not be able to set all of the colors exactly the way they are requested, and you should look at the video surface structure to determine the actual palette. If SDL cannot guarantee that the colors you request can be set, i.e. if the colormap is shared, then the video surface may be created under emulation in system memory, overriding the `SDL_HWSURFACE` flag. `SDL_FULLSCREEN` the SDL library will try to set a fullscreen video mode. The default is to create a windowed mode if the current graphics system has a window manager. If the SDL library is able to set a fullscreen video mode, this flag will be set in the surface that is returned. `SDL_DOUBLEBUF` the SDL library will try to set up two surfaces in video memory and swap between them when you call `SDL_Flip`. This is usually slower than the normal single-buffering scheme, but prevents "tearing" artifacts caused by modifying video memory while the monitor is refreshing. It should only be used by applications that redraw the entire screen on every update. `SDL_RESIZABLE` the SDL library will allow the window manager, if any, to resize the window at runtime. When this occurs, SDL will send a `SDL_VIDEORESIZE` event to you application, and you must respond to the event by re-calling `SDL_SetVideoMode` with the requested size (or another size that suits the application). `SDL_NOFRAME` the SDL library will create a window without any title bar or frame decoration. Fullscreen video modes have this flag set automatically. This function returns the video framebuffer surface, or ``None`` if it fails. If you rely on functionality provided by certain video flags, check the flags of the returned surface to make sure that functionality is available. SDL will fall back to reduced functionality if the exact flags you wanted are not available. :Parameters: - `width`: int - `height`: int - `bpp`: int - `flags`: int :rtype: `SDL_Surface` srequire_returnsSDL_UpdateRectscCs>tii|t|t\}}t|t||dS(sMake sure that the given list of rectangles is updated on the given screen. This function should not be called while `screen` is locked. :Parameters: - `screen`: `SDL_Surface` - `rects`: list of `SDL_Rect` N( sSDLsarrays to_ctypessrectsslensSDL_Rectsrefsars_SDL_UpdateRectssscreen(sscreensrectssarsref((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_UpdateRectsXs $sSDL_UpdateRects`Make sure that the given rectangle is updated on the given screen. If `x`, `y`, `w` and `h` are all 0, `SDL_UpdateRect` will update the entire screen. This function should not be called while `screen` is locked. :Parameters: - `screen`: `SDL_Surface` - `x`: int - `y`: int - `w`: int - `h`: int sscreensxsyswshsSDL_FlipsTFlip the front and back buffers. On hardware that supports double-buffering, this function sets up a flip and returns. The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return. On hardware that doesn not support double-buffering, this is equivalent to calling ``SDL_UpdateRect(screen, 0, 0, 0, 0)``. The `SDL_DOUBLEBUF` flag must have been passed to `SDL_SetVideoMode` when setting the video mode for this function to perform hardware flipping. :param `screen`: `SDL_Surface` ssuccess_returnis SDL_SetGammasNSet the gamma correction for each of the color channels. The gamma values range (approximately) between 0.1 and 10.0 If this function isn't supported directly by the hardware, it will be emulated using gamma ramps, if available. :Parameters: - `red`: float - `green`: float - `blue`: float sredsgreensbluesSDL_SetGammaRampc Cst}}}|o"tii|dt\} }n|o"tii|dt\}}n|o"tii|dt\}}nt|||}|djotiitiindS(sSet the gamma translation table for the red, green and blue channels of the video hardware. Each table is a list of 256 ints in the range [0, 2**16), representing a mapping between the input and output for that channel. The input is the index into the array, and the output is the 16-bit gamma value at that index, scaled to the output color precision. You may pass ``None`` for any of the channels to leave it unchanged. :Parameters: `red` : SDL_array For each channel you may pass either None (to leave the channel unchanged), an SDL_array or ctypes array of length 256, or any other sequence of length 256. `green` : SDL_array As above `blue` : SDL_array As above iiN(sNonesrarsgarsbarsredsSDLsarrays to_ctypessc_ushortsrrefsgreensgrefsbluesbrefs_SDL_SetGammaRampsresultserrors SDL_Exceptions SDL_GetError( sredsgreensbluesbarsbrefsgarsgrefsrarsresultsrref((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_SetGammaRamps""" sSDL_GetGammaRampcCstiitdt}tiitdt}tiitdt}t|i |i |i djo|||fSntttfSdS(sERetrieve the current values of the gamma translation tables. :rtype: (SDL_array, SDL_array, SDL_array) :return: a tuple (``red``, ``green``, ``blue``) where each element is either None (if the display driver doesn't support gamma translation) or an SDL_array of 256 ints in the range [0, 2**16). iiN( sSDLsarrays SDL_arraysNonesc_ushortsrarsgarsbars_SDL_GetGammaRamps as_ctypes(sbarsgarsrar((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_GetGammaRamps+s SDL_SetColorscCsAtii|t|t\}}t|||t|SdS(sSets a portion of the colormap for the given 8-bit surface. If `surface` is not a palettized surface, this function does nothing, returning 0. If all of the colors were set as passed to `SDL_SetColors`, it will return 1. If not all the color entries were set exactly as given, it will return 0, and you should look at the surface palette to determine the actual color palette. When `surface` is the surface associated with the current display, the display colormap will be updated with the requested colors. If `SDL_HWPALETTE` was set in `SDL_SetVideoMode` flags, `SDL_SetColors` will always return 1, and the palette is guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation. :Parameters: - `surface`: `SDL_Surface` - `colors`: sequence or SDL_array of `SDL_Color` - `firstcolor`: int; the first color index to set. :rtype: int :return: 1 if all colors were set as passed, otherwise 0. N( sSDLsarrays to_ctypesscolorsslens SDL_Colorsrefsars_SDL_SetColorsssurfaces firstcolor(ssurfacescolorss firstcolorsarsref((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_SetColorss$sSDL_SetPalettecCsotii|t|t\}}t||||t|}|djoti iti indS(sSets a portion of the colormap for a given 8-bit surface. `flags` is one or both of: `SDL_LOGPAL` set logical palette, which controls how blits are mapped to/from the surface `SDL_PHYSPAL` set physical palette, which controls how pixels look on the screen. Only screens have physical palettes. Separate change of physical/logical palettes is only possible if the screen has `SDL_HWPALETTE` set. `SDL_SetColors` is equivalent to calling this function with ``flags = (SDL_LOGPAL | SDL_PHYSPAL)``. :Parameters: - `surface`: `SDL_Surface` - `flags`: int - `colors`: sequence or SDL_array of `SDL_Color` - `firstcolor`: int; the first color index to set. iN(sSDLsarrays to_ctypesscolorsslens SDL_Colorsrefsars_SDL_SetPalettessurfacesflagss firstcolorsresultserrors SDL_Exceptions SDL_GetError(ssurfacesflagsscolorss firstcolorsarsrefsresult((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_SetPalettes $ s SDL_MapRGBs)Map an RGB triple to an opaque pixel value for a given pixel format. :Parameters: - `format`: `SDL_PixelFormat` - `r`: int in the range [0, 255] - `g`: int in the range [0, 255] - `b`: int in the range [0, 255] :rtype: int :return: the opaque pixel value sformatsrsgsbs SDL_MapRGBAsSMap an RGBA quadruple to an opaque pixel value for a given pixel format. :Parameters: - `format`: `SDL_PixelFormat` - `r`: int in the range [0, 255] - `g`: int in the range [0, 255] - `b`: int in the range [0, 255] - `a`: int in the range [0, 255] :rtype: int :return: the opaque pixel value sas SDL_GetRGBcCsctttf\}}}t||t|t|t||i|i|ifSdS(sMap a pixel value into the RGB components for a given pixel format. :Parameters: - `pixel`: int - `fmt`: `SDL_PixelFormat` :rtype: (int, int, int) :return: tuple (``r``, ``g``, ``b``) where each element is an int in the range [0, 255] N( sc_ubytesrsgsbs _SDL_GetRGBspixelsfmtsbyrefsvalue(spixelsfmtsbsgsr((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_GetRGBCs !(s SDL_GetRGBAcCs{ttttf\}}}}t||t|t|t|t||i |i |i |i fSdS(s Map a pixel value into the RGBA components for a given pixel format. :Parameters: - `pixel`: int - `fmt`: `SDL_PixelFormat` :rtype: (int, int, int, int) :return: tuple (``r``, ``g``, ``b``, ``a``) where each element is an int in the range [0, 255] N( sc_ubytesrsgsbsas _SDL_GetRGBAspixelsfmtsbyrefsvalue(spixelsfmtsasbsgsr((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_GetRGBAYs *1sSDL_CreateRGBSurfaces Allocate an RGB surface. Must be called after `SDL_SetVideoMode`. If the depth is 4 or 8 bits, an empty palette is allocated for the surface. If the depth is greater than 8 bits, the pixel format is set using the flags ``[RGB]mask``. The `flags` tell what kind of surface to create `SDL_SWSURFACE` the surface should be created in system memory. `SDL_HWSURFACE` the surface should be created in video memory, with the same format as the display surface. This is useful for surfaces that will not change much, to take advantage of hardware acceleration when being blitted to the display surface. `SDL_ASYNCBLIT` SDL will try to perform asynchronous blits with this surface, but you must always lock it before accessing the pixels. SDL will wait for current blits to finish before returning from the lock. `SDL_SRCCOLORKEY` the surface will be used for colorkey blits. If the hardware supports acceleration of colorkey blits between two surfaces in video memory, SDL will try to place the surface in video memory. If this isn't possible or if there is no hardware acceleration available, the surface will be placed in system memory. `SDL_SRCALPHA` the surface will be used for alpha blits and if the hardware supports hardware acceleration of alpha blits between two surfaces in video memory, to place the surface in video memory if possible, otherwise it will be placed in system memory. If the surface is created in video memory, blits will be _much_ faster, but the surface format must be identical to the video surface format, and the only way to access the pixels member of the surface is to use the `SDL_LockSurface` and `SDL_UnlockSurface` calls. If the requested surface actually resides in video memory, `SDL_HWSURFACE` will be set in the flags member of the returned surface. If for some reason the surface could not be placed in video memory, it will not have the `SDL_HWSURFACE` flag set, and will be created in system memory instead. :Parameters: - `flags`: int - `width`: int - `height`: int - `depth`: int - `Rmask`: int - `Gmask`: int - `Bmask`: int - `Amask`: int :rtype: `SDL_Surface` sdepthsRmasksGmasksBmasksAmasksSDL_CreateRGBSurfaceFromc Cst|dot|f\} } nt|} t||d||jo|djo(t i i |t|t \} } q<|djo(t i i |t|t\} } q<|djo(t i i |t|t\} } q<nIt|||jo(t i i |t|t \} } n tdtt| tt |||||||| } | | _| SdS(s.Allocate and initialise an RGB surface. Must be called after `SDL_SetVideoMode`. If the depth is 4 or 8 bits, an empty palette is allocated for the surface. If the depth is greater than 8 bits, the pixel format is set using the flags ``[RGB]mask``. `pixels` may be any sequence of integers of size `depth`, or a sequence of bytes, an SDL_array or a numpy array. The type of data passed will be detected based on the values of `width`, `height` and `depth`. If `depth` is less than 8 bits, you must pass the data as bytes. :Parameters: - `pixels`: sequence or SDL_array - `width`: int - `height`: int - `depth`: int - `pitch`: int - `Rmask`: int - `Gmask`: int - `Bmask`: int - `Amask`: int :rtype: `SDL_Surface` scontentsiii s1Length of pixels does not match given dimensions.N(shasattrspixelssNonesrefsarslens len_pixelsspitchsdepthsheightsSDLsarrays to_ctypessc_ubytesc_ushortsc_uints TypeErrors_SDL_CreateRGBSurfaceFromscastsPOINTERswidthsRmasksGmasksBmasksAmaskssurfaces _buffer_ref( spixelsswidthsheightsdepthspitchsRmasksGmasksBmasksAmasksars len_pixelssrefssurface((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_CreateRGBSurfaceFroms$  ( ( ,(  sSDL_FreeSurfacesKFree an RGB Surface. :Parameters: - `surface`: `SDL_Surface` ssurfacesSDL_LockSurfacespSet up a surface for directly accessing the pixels. Between calls to `SDL_LockSurface`/`SDL_UnlockSurface`, you can write to and read from ``surface.pixels``, using the pixel format stored in ``surface.format``. Once you are done accessing the surface, you should use `SDL_UnlockSurface` to release it. Not all surfaces require locking. If `SDL_MUSTLOCK` evaluates to 0, then you can read and write to the surface at any time, and the pixel format of the surface will not change. In particular, if the `SDL_HWSURFACE` flag is not given when calling `SDL_SetVideoMode`, you will not need to lock the display surface before accessing it. No operating system or library calls should be made between lock/unlock pairs, as critical system locks may be held during this time. :Parameters: - `surface`: `SDL_Surface` sSDL_UnlockSurfacesfUnlock a surface locked with `SDL_LockSurface`. :Parameters: - `surface`: `SDL_Surface` sSDL_LoadBMP_RWs?Load a surface from a seekable SDL data source (memory or file). If `freesrc` is non-zero, the source will be closed after being read. The new surface which is returned should be freed with `SDL_FreeSurface`. :Parameters: - `src`: `SDL_RWops` - `freesrc`: int :rtype: `SDL_Surface` ssrcsfreesrccCs ttii|ddSdS(sLoad a surface from a file. Convenience function equivalent to ``SDL_LoadBMP_RW(SDL_RWFromFile(file, 'rb'), 1)``. :Parameters: - `file`: string, the location of the bitmap file. :rtype: `SDL_Surface` srbiN(sSDL_LoadBMP_RWsSDLsrwopssSDL_RWFromFilesfile(sfile((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_LoadBMP(s sSDL_SaveBMP_RWsSave a surface to a seekable SDL data source (memory or file). If `freedst` is non-zero, the destination will be closed after being written. :Parameters: - `surface`: `SDL_Surface` - `dst`: `SDL_RWops` - `freesrc`: int sdstsfreedstcCs#t|tii|ddSdS(sSave a surface to a file. Convenience function equivalent to ``SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, 'wb'), 1)`` :Parameters: - `surface`: `SDL_Surface` - `dst`: `SDL_RWops` swbiN(sSDL_SaveBMP_RWssurfacesSDLsrwopssSDL_RWFromFilesfile(ssurfacesfile((s)build/bdist.linux-x86_64/egg/SDL/video.pys SDL_SaveBMPEs sSDL_SetColorKeysSet the color key (transparent pixel) in a blittable surface. If `flag` is `SDL_SRCCOLORKEY` (optionally OR'd with `SDL_RLEACCEL`), `key` will be the transparent pixel in the source image of a blit. `SDL_RLEACCEL` requests RLE acceleration for the surface if present, and removes RLE acceleration if absent. If `flag` is 0, this function clears any current color key. :Parameters: - `surface`: `SDL_Surface` - `flag`: int - `key`: int, see `SDL_MapRGB` sflagskeys SDL_SetAlphasSet the alpha value for the entire surface, as opposed to using the alpha component of each pixel. This value measures the range of transparency of the surface, 0 being completely transparent to 255 being completely opaque. An `alpha` value of 255 causes blits to be opaque, the source pixels copied to the destination (the default). Note that per-surface alpha can be combined with colorkey transparency. If `flag` is 0, alpha blending is disabled for the surface. If `flag` is `SDL_SRCALPHA`, alpha blending is enabled for the surface. OR'ing the flag with `SDL_RLEACCEL` requests RLE acceleration for the surface; if `SDL_RLEACCEL` is not specified, the RLE accel will be removed. The `alpha` parameter is ignored for surfaces that have an alpha channel. :Parameters: - `surface`: `SDL_Surface` - `flag`: int - `alpha`: int :return: int; undocumented. (FIXME) salphasSDL_SetClipRectsSet the clipping rectangle for the destination surface in a blit. If the clip rectangle is None, clipping will be disabled. If the clip rectangle doesn't intersect the surface, the function will return False and blits will be completely clipped. Otherwise the function returns True and blits to the surface will be clipped to the intersection of the surface area and the clipping rectangle. Note that blits are automatically clipped to the edges of the source and destination surfaces. :Parameters: - `surface`: `SDL_Surface` - `rect`: `SDL_Rect` or None :rtype: int :return: non-zero if blitting will not be entirely clipped, otherwise zero. srectsSDL_GetClipRectcCs$t}t|t||SdS(sGet the clipping rectangle for the destination surface in a blit. :see: `SDL_SetClipRect` :Parameters: - `surface`: `SDL_Surface` :rtype: `SDL_Rect` N(sSDL_Rectsrects_SDL_GetClipRectssurfacesbyref(ssurfacesrect((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_GetClipRects  sSDL_ConvertSurfacesUCreate a new surface of the specified format, then copy and map the given surface to it so the blit of the converted surface will be as fast as possible. The `flags` parameter is passed to `SDL_CreateRGBSurface` and has those semantics. You can also pass `SDL_RLEACCEL` in the flags parameter and SDL will try to RLE accelerate colorkey and alpha blits in the resulting surface. This function is used internally by `SDL_DisplayFormat`. :Parameters: - `src`: `SDL_Surface` - `fmt`: `SDL_PixelFormat` - `flags`: int :rtype: `SDL_Surface` sfmts SDL_UpperBlits Perform a fast blit from the source surface to the destination surface. ``SDL_BlitSurface`` is a synonym for ``SDL_UpperBlit``. This function assumes that the source and destination rectangles are the same size. If either `srcrect` or `dstrect` are None, the entire surface (`src` or `dst`) is copied. The final blit rectangles are saved in `srcrect` and `dstrect` after all clipping is performed. The blit function should not be called on a locked surface. The blit semantics for surfaces with and without alpha and colorkey are defined as follows: RGBA to RGB `SDL_SRCALPHA` set: - alpha-blend (using alpha-channel) - `SDL_SRCCOLORKEY` ignored `SDL_SRCALPHA` not set: - copy RGB - if `SDL_SRCCOLORKEY` set, only copy the pixels matching the RGB value of the source color key, ignoring alpha in the comparison. RGB to RGBA: `SDL_SRCALPHA` set: - alpha-blend (using the source per-surface alpha value) - set destination alpha to opaque `SDL_SRCALPHA` not set: - copy RGB, set destination alpha to source per-surface alpha value. `SDL_SRCCOLORKEY` set: - only copy pixels matching the source color key RGBA to RGBA: `SDL_SRCALPHA` set: - alpha-blend (using the source alpha channel) the RGB values; leave destination alpha untouched. - `SDL_SRCCOLORKEY` ignored. `SDL_SRCALPHA` not set: - copy all of RGBA to the destination - if `SDL_SRCCOLORKEY` set, only copy the pixels matching the RGB value of the source color key, ignoring alpha in the comparison. RGB to RGB: `SDL_SRCHALPHA` set: - alpha-blend (using the source per-surface alpha value) `SDL_SRCALPHA` not set: - copy RGB `SDL_SRCCOLORKEY` set: - only copy the pixels matching the source color key. If either of the surfaces were in video memory, and the blit returns -2, the video memory was lost, so it should be reloaded with artwork and reblitted:: while SDL_BlitSurface(image, imgrect, screen, dstrect) == -2: while SDL_LockSurface(image) < 0: sleep(10) # Write image pixels to image.pixels SDL_UnlockSurface(image) This happens under DirectX 5.0 when the system switches away from your fullscreen application. The lock will also fail until you have access to the video memory again. :Parameters: - `src`: `SDL_Surface` - `srcrect`: `SDL_Rect` - `dst`: `SDL_Surface` - `dstrect`: `SDL_Rect` :rtype: int :return: 0 if successful, or -2 if there was an error and video memory was lost. (any other error will raise an exception) ssrcrectsdstrects error_returnisPerform a fast blit from the source surface to the destination surface. This function is a synonym for `SDL_UpperBlit`. :rtype: int s SDL_LowerBlitsLow-level fast blit. This is a semi-private blit function that does not perform rectangle validation or clipping. See `SDL_UpperBlit` for the public function. :rtype: int s SDL_FillRectsPerform a fast fill of the given rectangle with `color`. The given rectangle is clipped to the destination surface clip area and the final fill rectangle is saved in the passed in rectangle. If `dstrect` is None, the whole surface will be filled with `color` The color should be a pixel of the format used by the surface, and can be generated by the `SDL_MapRGB` function. :Parameters: - `dst`: `SDL_Surface` - `dstrect`: `SDL_Rect` - `color`: int scolorsSDL_DisplayFormatsCopy a surface to the pixel format and colors of the display buffer. This function makes a copy of a surface suitable for fast blitting onto the display surface. It calls `SDL_ConvertSurface`. If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function. :Parameters: - `surface`: `SDL_Surface` :rtype: `SDL_Surface` sSDL_DisplayFormatAlphasCopy a surface to the pixel format and colors of the display buffer. This function makes a copy of a surface suitable for fast alpha blitting onto the display surface. The new surface will always have an alpha channel. If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function. :Parameters: - `surface`: `SDL_Surface` :rtype: `SDL_Surface` sSDL_CreateYUVOverlaysPCreate a video output overlay. Calling the returned surface an overlay is something of a misnomer because the contents of the display surface underneath the area where the ovelay is shown is undefined - it may be overwritten with the converted YUV data. The most common video overlay formats are: `SDL_YV12_OVERLAY` Planar mode: Y + V + U (3 planes) `SDL_IYUV_OVERLAY` Planar mode: Y + U + V (3 planes) `SDL_YUY2_OVERLAY` Packed moed: Y0 + U0 + Y1 + V0 (1 plane) `SDL_UYVY_OVERLAY` Packed moed: U0 + Y0 + V0 + Y1 (1 plane) `SDL_YVYU_OVERLAY` Packed moed: Y0 + V0 + Y1 + U0 (1 plane) For an explanation of these pixel formats, see http://www.webartz.com/fourcc/indexyuv.htm For more information on the relationship between color spaces, see: http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html :Parameters: - `width`: int - `height`: int - `format`: int - `display`: `SDL_Surface` :rtype: `SDL_Overlay` sdisplaysSDL_LockYUVOverlaysLock an overlay for direct access. Unlock the overlay when done with `SDL_UnlockYUVOverlay`. :Parameters: - `overlay`: `SDL_Overlay` :rtype: int :return: undocumented (FIXME) soverlaysSDL_UnlockYUVOverlaystUnlock an overlay after locking it with `SDL_LockYUVOverlay`. :Parameters: - `overlay`: `SDL_Overlay` sSDL_DisplayYUVOverlaysBlit a video overlay to the display surface. The contents of the video surface underneath the blit destination are not defined. The width and height of the destination rectangle may be different from that of the overlay, but currently only 2x scaling is supported. :Parameters: - `overlay`: `SDL_Overlay` - `dstrect`: `SDL_Rect` :rtype: int :return: undocumented (FIXME) sSDL_FreeYUVOverlaysMFree a video overlay. :Parameters: - `overlay`: `SDL_Overlay` sSDL_GL_SetAttributesSet an attribute of the OpenGL subsystem before initialization. :Parameters: - `attr`: int - `value`: int :rtype: int :return: undocumented (FIXME) sattrsvaluesSDL_GL_GetAttributecCs't}t|t||iSdS(s\Get an attribute of the OpenGL subsystem from the windowing interface, such as glX. N(sc_intsvals_SDL_GL_GetAttributesattrsbyrefsvalue(sattrsval((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_GL_GetAttributes sSDL_GL_SwapBufferss?Swap the OpenGL buffers, if double-buffering is supported. sSDL_WM_SetCaptioncCs#t|id|iddS(sSet the title and icon text of the display window. Unicode strings are also accepted since 1.2.10. :Parameters: - `title`: string - `icon`: string sutf-8N(s_SDL_WM_SetCaptionstitlesencodesicon(stitlesicon((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_WM_SetCaptionssSDL_WM_GetCaptioncCsttf\}}tt|t||io|iid}nt}|io|iid}nt}||fSdS(sGet the title and icon text of the display window. :rtype: (string, string) :return: a tuple (title, icon) where each element is a Unicode string sutf-8N(sc_char_pstitlesicons_SDL_WM_GetCaptionsbyrefsvaluesdecodesNone(stitlesicon((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_WM_GetCaptions  sSDL_WM_SetIconcCsL|o4tii||i|iddt\}}nt ||dS(sRSet the icon for the display window. This function must be called before the first call to `SDL_SetVideoMode`. It takes an icon surface, and a mask in MSB format. If `mask` is None, the entire icon surface will be used as the icon. :Parameters: - `icon`: `SDL_Surface` - `mask`: `SDL_array` or sequence iiN( smasksSDLsarrays to_ctypessiconswshsc_ubytesrefs_SDL_WM_SetIcon(siconsmasksref((s)build/bdist.linux-x86_64/egg/SDL/video.pysSDL_WM_SetIcon&s 4sSDL_WM_IconifyWindowsiIconify the window. If the function succeeds, it generates an `SDL_APPACTIVATE` loss event. sSDL_WM_ToggleFullScreensToggle fullscreen mode without changing the contents of the screen. If the display surface does not require locking before accessing the pixel information, then the memory pointers will not change. The next call to `SDL_SetVideoMode` will set the mode fullscreen attribute based on the flags parameter - if `SDL_FULLSCREEN` is not set, then the display will be windowed by default where supported. This is currently only implemented in the X11 video driver. :Parameters: - `surface`: `SDL_Surface` sSDL_WM_GrabInputsSet the grab mode for the mouse and keyboard. Grabbing means that the mouse is confined to the application window, and nearly all keyboard input is passed directly to the application, and not interpreted by a window manager, if any. The behaviour of this function depends on the value of `mode`: `SDL_GRAB_QUERY` Return the current input grab mode. `SDL_GRAB_OFF` Turn off grab mode and return the new input grab mode. `SDL_GRAB_ON` Turn on grab mode and return the new input grab mode. :Parameters: - `mode`: int :rtype: int :return: the new input grab mode. smode(gs__doc__s __docformat__s __version__sctypess SDL.arraysSDLsSDL.dlls SDL.errors SDL.constantss SDL.rwopss StructuresSDL_Rects SDL_Colors SDL_Colours SDL_PalettesSDL_PixelFormats SDL_Surfaces SDL_MUSTLOCKs CFUNCTYPEsc_intsPOINTERsSDL_blits SDL_VideoInfos SDL_Overlaysdllsprivate_functionsc_char_ps_SDL_VideoDriverNamesSDL_VideoDriverNamesfunctionsTruesSDL_GetVideoSurfacesSDL_GetVideoInfosc_uintsSDL_VideoModeOKs_SDL_ListModess SDL_ListModessSDL_SetVideoModesNones_SDL_UpdateRectssSDL_UpdateRectssSDL_UpdateRectsSDL_Flipsc_floats SDL_SetGammasc_ushorts_SDL_SetGammaRampsSDL_SetGammaRamps_SDL_GetGammaRampsSDL_GetGammaRamps_SDL_SetColorss SDL_SetColorss_SDL_SetPalettesSDL_SetPalettesc_ubytes SDL_MapRGBs SDL_MapRGBAs _SDL_GetRGBs SDL_GetRGBs _SDL_GetRGBAs SDL_GetRGBAsSDL_CreateRGBSurfaces_SDL_CreateRGBSurfaceFromsSDL_CreateRGBSurfaceFromsSDL_FreeSurfacesSDL_LockSurfacesSDL_UnlockSurfacesrwopss SDL_RWopssSDL_LoadBMP_RWs SDL_LoadBMPsSDL_SaveBMP_RWs SDL_SaveBMPsSDL_SetColorKeys SDL_SetAlphasSDL_SetClipRects_SDL_GetClipRectsSDL_GetClipRectsSDL_ConvertSurfaces SDL_UpperBlitsSDL_BlitSurfaces SDL_LowerBlits SDL_FillRectsSDL_DisplayFormatsSDL_DisplayFormatAlphasSDL_CreateYUVOverlaysSDL_LockYUVOverlaysSDL_UnlockYUVOverlaysSDL_DisplayYUVOverlaysSDL_FreeYUVOverlaysSDL_GL_SetAttributes_SDL_GL_GetAttributesSDL_GL_GetAttributesSDL_GL_SwapBufferss_SDL_WM_SetCaptionsSDL_WM_SetCaptions_SDL_WM_GetCaptionsSDL_WM_GetCaptions_SDL_WM_SetIconsSDL_WM_SetIconsSDL_WM_IconifyWindowsSDL_WM_ToggleFullScreensSDL_WM_GrabInput(PsSDL_GetVideoSurfaces_SDL_UpdateRectssSDL_WM_IconifyWindows_SDL_WM_SetIcons SDL_SetAlphasSDL_DisplayFormats _SDL_GetRGBsSDL_WM_SetIcons SDL_SetGammasSDL_SetClipRects_SDL_WM_SetCaptionsSDL_SetGammaRampsSDL_CreateYUVOverlays SDL_VideoInfosSDL_SetColorKeys SDL_ColorsSDL_SetPalettes_SDL_CreateRGBSurfaceFroms _SDL_GetRGBAsSDL_UpdateRectss SDL_FillRects_SDL_VideoDriverNames_SDL_SetPalettes SDL_LowerBlitsSDL_VideoDriverNamesSDL_WM_GrabInputs_SDL_GetClipRectsSDL_GL_SwapBufferss SDL_SetColorss_SDL_ListModess SDL_GetRGBs_SDL_GetGammaRampsSDL_GetClipRectsSDL_ConvertSurfaces __docformat__sSDL_CreateRGBSurfaceFromsSDL_GL_GetAttributesSDL_SetVideoModesSDL_LockSurfacesSDL_WM_GetCaptionsSDL_GL_SetAttributes SDL_GetRGBAsSDL_UnlockSurfacesSDL_GetVideoInfosSDL_Flips SDL_SurfacesSDL_UnlockYUVOverlaysSDL_GetGammaRampsSDL_PixelFormatsSDL_blits_SDL_GL_GetAttributes_SDL_SetGammaRamps SDL_OverlaysSDL_WM_SetCaptionsSDL_SaveBMP_RWs SDL_SaveBMPs SDL_PalettesSDL_LoadBMP_RWsSDL_LockYUVOverlays SDL_MapRGBsSDL_WM_ToggleFullScreensSDL_RectsSDL_DisplayYUVOverlays SDL_MUSTLOCKs_SDL_WM_GetCaptionsSDL_DisplayFormatAlphasSDL_VideoModeOKs SDL_MapRGBAs SDL_UpperBlitsSDL_BlitSurfacesSDL_FreeYUVOverlaysSDL_UpdateRects __version__sSDL_CreateRGBSurfaces SDL_ListModess SDL_LoadBMPs_SDL_SetColorss SDL_ColoursSDL_FreeSurfacesSDL((s)build/bdist.linux-x86_64/egg/SDL/video.pys?s2     '"UB H2               I            !  " !      !       -   6   ;   $   4              !               K*  *  *            "                                        PK)5mx SDL/mouse.pyc; 0)Dc @sOdZdZdZdkTdkZdkZdkZdefdYZ ei i dde e e e gd eZd Zei i d de e e e gd eZd Zei id ddddgdeegd eZei i dde ee ee e e e gd e e dedeZdZei iddddgde e gd eZei idddgdgd e e deZei iddddgde e gd eZei iddddgde gd e Zd Zeeii Z!eeii"Z#eeii$Z%dS(!sMouse event handling. srestructuredtexts$Id: $(s*Ns SDL_CursorcBsxtZdZdeiifdefdefdeefdeefdeedfde fgZ d Z RS( sCursor structure. :Ivariables: `area` : `SDL_Rect` Area of the mouse cursor `hot_x` : int X coordinate of the tip of the cursor `hot_y` : int Y coordinate of the tip of the cursor sareashot_xshot_ys_datas_maskssaveis wm_cursorcCs|ii|iif\}}|djo%tii|i||dt Sn3|djo%tii|i ||dt Snt |dS(Nsdataismask( sselfsareaswshsnamesSDLsarrays SDL_arrays_datasc_ubytes_masksAttributeError(sselfsnameshsw((s)build/bdist.linux-x86_64/egg/SDL/mouse.pys __getattr__#s  % %( s__name__s __module__s__doc__sSDLsvideosSDL_Rectsc_shortsPOINTERsc_ubytesc_void_ps_fields_s __getattr__(((s)build/bdist.linux-x86_64/egg/SDL/mouse.pys SDL_Cursors asSDL_GetMouseStates arg_typess return_typecCsJttf\}}tt|t|}||i|ifSdS(szRetrieve the current state of the mouse. Example:: state, x, y = SDL_GetMouseState() if state & SDL_BUTTON_LMASK: print 'Left button pressed.' :rtype: (int, int, int) :return: (state, x, y), where * state is a button bitmask, which can be tested using `SDL_BUTTON` * x and y are the current mouse cursor position. N(sc_intsxsys_SDL_GetMouseStatesbyrefsstatesvalue(sstatesysx((s)build/bdist.linux-x86_64/egg/SDL/mouse.pysSDL_GetMouseState/ssSDL_GetRelativeMouseStatecCsJttf\}}tt|t|}||i|ifSdS(sRetrieve the current state of the mouse. :rtype: (int, int, int) :return: (state, dx, dy), where state is a button bitmask, which can be tested using `SDL_BUTTON`; dx and dy are the mouse deltas since the last call to `SDL_GetRelativeMouseState` N(sc_intsdxsdys_SDL_GetRelativeMouseStatesbyrefsstatesvalue(sstatesdxsdy((s)build/bdist.linux-x86_64/egg/SDL/mouse.pysSDL_GetRelativeMouseStateGs s SDL_WarpMousesSet the position of the mouse cursor. Generates a mouse motion event. :Parameters: - `x`: int - `y`: int sargssxsysSDL_CreateCursorsdereference_returnsrequire_returncCsetii|t|t\}}tii|t|t\}}t ||||||SdS(sCreate a cursor using the specified data and mask. The cursor width must be a multiple of 8 bits. Mask and cursor data may be given as either SDL_array byte buffers or as a sequence of bytes; in either case the data is in MSB order. The cursor is created in black and white according to the following: ==== ==== ========================================= data mask resulting pixel on screen ==== ==== ========================================= 0 1 White 1 1 Black 0 0 Transparent 1 0 Inverted color if possible, black if not. ==== ==== ========================================= Cursors created with this function must be freed with `SDL_FreeCursor`. :Parameters: - `data`: `SDL_array` - `mask`: `SDL_array` - `w`: int - `h`: int - `hot_x`: int - `hot_y`: int :rtype: `SDL_Cursor` N(sSDLsarrays to_ctypessdataslensc_ubytesdatarefsmasksmaskrefs_SDL_CreateCursorswshshot_xshot_y(sdatasmaskswshshot_xshot_ysdatarefsmaskref((s)build/bdist.linux-x86_64/egg/SDL/mouse.pysSDL_CreateCursoris$$s SDL_SetCursorsSet the currently active cursor to the specified one. If the cursor is currently visible, the change will be immediately represented on the display. :Parameters: - `cursor`: `SDL_Cursor` scursors SDL_GetCursorsBReturn the currently active cursor. :rtype: `SDL_Cursor` sSDL_FreeCursorshDeallocate a cursor created with `SDL_CreateCursor` :Parameters: - `cursor`: `SDL_Cursor` sSDL_ShowCursorsToggle whether or not the curosr is shown on the screen. The cursor starts off displayed, but can be turned off. :Parameters: `toggle` : int if 1, shows the cursor; if 0, hides the cursor, if -1, returns the current state of the cursor. :rtype: int :return: 1 if the cursor was being displayed before the call, otherwise 0. stogglecCsd|d>SdS(s.Used to create a mask for a mouse button. iN(sX(sX((s)build/bdist.linux-x86_64/egg/SDL/mouse.pys SDL_BUTTONs(&s__doc__s __docformat__s __version__sctypess SDL.arraysSDLsSDL.dlls SDL.videos Structures SDL_Cursorsdllsprivate_functionsPOINTERsc_intsc_ubytes_SDL_GetMouseStatesSDL_GetMouseStates_SDL_GetRelativeMouseStatesSDL_GetRelativeMouseStatesfunctionsc_ushortsNones SDL_WarpMousesTrues_SDL_CreateCursorsSDL_CreateCursors SDL_SetCursors SDL_GetCursorsSDL_FreeCursorsSDL_ShowCursors SDL_BUTTONs constantssSDL_BUTTON_LEFTsSDL_BUTTON_LMASKsSDL_BUTTON_MIDDLEsSDL_BUTTON_MMASKsSDL_BUTTON_RIGHTsSDL_BUTTON_RMASK(s SDL_CursorsSDL_GetRelativeMouseStates __docformat__s SDL_SetCursorsSDL_BUTTON_MMASKsSDL_GetMouseStatesSDL_ShowCursorsSDL_BUTTON_RMASKs SDL_WarpMouses __version__sSDL_BUTTON_LMASKsSDL_CreateCursors_SDL_GetMouseStates_SDL_CreateCursors SDL_GetCursors_SDL_GetRelativeMouseStatesSDL_FreeCursors SDL_BUTTONsSDL((s)build/bdist.linux-x86_64/egg/SDL/mouse.pys?sf              $   "              PK)5R7m5SDL/joystick.pyc; bҭDc @sEdZdZdZdkTdkZdkZdefdYZe eZ ei i ddd gd gd e Zei i d d d dgd e gd eZei i ddd dgd e gd e deZei i ddd dgd e gd e Zei i ddd dgd e gd e Zei i ddd dgd e gd e Zei i ddd dgd e gd e Zei i ddd dgd e gd e Zei i ddd dgd e gd e Zei i dd d gd gd eZei i d!d"d d#gd e gd e Zei i d$d%d dd&gd e e gd eZei i d'd(d dd)gd e e gd eZei i d*d e e e e e e gd e d+d,Z!d-Z"ei i d.d/d dd0gd e e gd eZ#ei i d1d2d dgd e gd eZ$dS(3sDJoystick event handling. TODO: This module is completely untested. srestructuredtexts$Id: $(s*Ns _SDL_JoystickcBstZdefgZRS(Ns_dummy(s__name__s __module__sc_void_ps_fields_(((s,build/bdist.linux-x86_64/egg/SDL/joystick.pys _SDL_JoystickssSDL_NumJoystickssKCount the number of joysticks attached to the system. :rtype: int sargss arg_typess return_typesSDL_JoystickNamesGet the implementation dependent name of a joystick. This can be called before any joysticks are opened. If no name can be found, this function returns None. :Parameters: - `device_index`: int :rtype: str s device_indexsSDL_JoystickOpensTOpen a joystick for use. The index passed as an argument refers to the N'th joystick on the system. This index is the value which will identify this joystick in future joystick events. This function returns an opaque joystick identifier. :Parameters: - `device_index`: int :rtype: `SDL_Joystick_p` srequire_returnsSDL_JoystickOpenedsDetermine if a joystick has been opened. :Parameters: - `device_index`: int :rtype: `int` :return: 1 if the joystick has been opened, or 0 if it has not. sSDL_JoystickIndexswGet the device index of an opened joystick. :Parameters: - `joystick`: `SDL_Joystick_p` :rtype: int sjoysticksSDL_JoystickNumAxessGet the number of general axis controls on a joystick. :Parameters: - `joystick`: `SDL_Joystick_p` :rtype: int sSDL_JoystickNumBallssGet the number of trackballs on a joystick. Joystick trackballs have only relative motion events associated with them and their state cannot be polled. :Parameters: - `joystick`: `SDL_Joystick_p` :rtype: int sSDL_JoystickNumHatssuGet the number of POV hats on a joystick. :Parameters: - `joystick`: `SDL_Joystick_p` :rtype: int sSDL_JoystickNumButtonsstGet the number of buttons on a joystick. :Parameters: - `joystick`: `SDL_Joystick_p` :rtype: int sSDL_JoystickUpdatesUpdate the current state of the open joysticks. This is called automatically by the event loop if any joystick events are enabled. sSDL_JoystickEventStatesXEnable/disable joystick event polling. If joystick events are disabled, you must call `SDL_JoystickUpdate` yourself and check the state of the joystick when you want joystick information. :Parameters: `state` : int one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. :rtype: int :return: undocumented sstatesSDL_JoystickGetAxissGet the current state of an axis control on a joystick. The axis indices start at index 0. :Parameters: - `joystick`: `SDL_Joystick_p` - `axis`: int :rtype: int :return: a value ranging from -32,768 to 32767. saxissSDL_JoystickGetHatsGet the current state of POV hat on a joystick. The hat indices start at index 0. :Parameters: - `joystick`: `SDL_Joystick_p` - `hat`: int :rtype: int :return: one of `SDL_HAT_CENTERED`, `SDL_HAT_UP`, `SDL_HAT_LEFT`, `SDL_HAT_DOWN`, `SDL_HAT_RIGHT`, `SDL_HAT_RIGHTUP`, `SDL_HAT_RIGHTDOWN`, `SDL_HAT_RIGHTUP`, `SDL_HAT_LEFTUP`, `SDL_HAT_LEFTDOWN`. shatsSDL_JoystickGetBalls error_returnicCsKttf\}}t||tttt|i |i fSdS(sGet the ball axis change since the last poll. The ball indicies start at index 0. :Parameters: - `joystick`: `SDL_Joystick_p` - `ball`: int :rtype: (int, int) :return: a tuple (dx, dy) of the relative motion of the ball. N( sc_intsdxsdys_SDL_JoystickGetBallsjoysticksballsbyrefsxsysvalue(sjoysticksballsdxsdy((s,build/bdist.linux-x86_64/egg/SDL/joystick.pysSDL_JoystickGetBalls sSDL_JoystickGetButtonsGet the current state of a button on a joystick. The button indices start at index 0. :Parameters: - `joystick`: `SDL_Joystick_p` - `button`: int :rtype: int :return: undocumented sbuttonsSDL_JoystickCloseswClose a joystick previously opened with `SDL_JoystickOpen`. :Parameters: - `joystick`: `SDL_Joystick_p` (%s__doc__s __docformat__s __version__sctypess SDL.constantssSDLsSDL.dlls Structures _SDL_JoysticksPOINTERsSDL_Joystick_psdllsfunctionsc_intsSDL_NumJoystickssc_char_psSDL_JoystickNamesTruesSDL_JoystickOpensSDL_JoystickOpenedsSDL_JoystickIndexsSDL_JoystickNumAxessSDL_JoystickNumBallssSDL_JoystickNumHatssSDL_JoystickNumButtonssNonesSDL_JoystickUpdatesSDL_JoystickEventStatesc_shortsSDL_JoystickGetAxissc_ubytesSDL_JoystickGetHatsprivate_functions_SDL_JoystickGetBallsSDL_JoystickGetBallsSDL_JoystickGetButtonsSDL_JoystickClose(sSDL_JoystickGetAxiss_SDL_JoystickGetBallsSDL_JoystickNumHatssSDL_JoystickOpeneds __docformat__sSDL_JoystickGetButtonsSDL_JoystickOpensSDL_JoystickNumBallssSDL_JoystickNumAxessSDL_NumJoystickssSDL_JoystickGetBalls __version__sSDL_Joystick_psSDL_JoystickNumButtonssSDL_JoystickEventStates _SDL_JoysticksSDL_JoystickGetHatsSDL_JoystickClosesSDL_JoystickNamesSDLsSDL_JoystickIndexsSDL_JoystickUpdate((s,build/bdist.linux-x86_64/egg/SDL/joystick.pys?s                                                             PK)5$p(p( SDL/dll.pyc; ,mDc@sdZdZdZdkTdklZdkZdefdYZdZ d Z d Z d fd YZ e d dZ e iZe iZe iZe iZdS(s srestructuredtexts$Id: $(s*(s find_libraryNs _SDL_versioncBs2tZdefdefdefgZdZRS(NsmajorsminorspatchcCsd|i|i|ifSdS(Ns%d.%d.%d(sselfsmajorsminorspatch(sself((s'build/bdist.linux-x86_64/egg/SDL/dll.pys__repr__s(s__name__s __module__sc_ubytes_fields_s__repr__(((s'build/bdist.linux-x86_64/egg/SDL/dll.pys _SDL_versions!cCst|dot|do t|do|i|i|ifSnst|tjo|SnXt|tjo>tgi}|i dD]}|t |q~Snt dS(s`Return a tuple (major, minor, patch) for `v`, which can be an _SDL_version, string or tuple.smajorsminorspatchs.N(shasattrsvsmajorsminorspatchstypestuplesstrsappends_[1]ssplitsisints TypeError(svsis_[1]((s'build/bdist.linux-x86_64/egg/SDL/dll.pys_version_partss0>cCsdt|SdS(Ns%d.%d.%d(s_version_partssv(sv((s'build/bdist.linux-x86_64/egg/SDL/dll.pys_version_string$scCs`tid djo d|Sn9tidjo d|Sntidjo d|Sn|SdS(Nislinuxslib%s.sosdarwins %s.frameworkswindowss%s.dll(ssyssplatformslibrary(slibrary((s'build/bdist.linux-x86_64/egg/SDL/dll.pys_platform_library_name's   sSDL_DLLc BsMtZdZdZdZdZggeeeeeedZRS(NcCs||_t|}| otdt|ntt||_|ofy:t|i|}t t |_ t|i|_Wqtj odddf|_qXndddf|_dS(Ns"Dynamic library "%s" was not foundi(s library_namesselfs find_libraryslibrarys ImportErrors_platform_library_namesgetattrscdlls_dllsversion_function_namesversion_functionsPOINTERs _SDL_versionsrestypes_version_partsscontentss_versionsAttributeError(sselfs library_namesversion_function_nameslibrarysversion_function((s'build/bdist.linux-x86_64/egg/SDL/dll.pys__init__1s  cCsKt|}x4tdD]&}|i|||jotSqqWtSdS(sRReturns True iff `v` is equal to or later than the loaded library version.iN(s_version_partssvsrangesisselfs_versionsFalsesTrue(sselfsvsi((s'build/bdist.linux-x86_64/egg/SDL/dll.pysversion_compatibleDs   cCsJt| o8dk}|iid|t|t|i fndS(s@Raises an exception if `since` is later than the loaded library.Ns6%s requires SDL version %s; currently using version %s( sversion_compatiblessinces SDL.errorsSDLserrorsSDL_NotImplementedErrorsnames_version_stringsselfs_version(sselfsnamessincesSDL((s'build/bdist.linux-x86_64/egg/SDL/dll.pysassert_version_compatibleMs cKs,d||ddk}|iiditti fdS(Ns-%s requires %s %s; currently using version %s( s SDL.errorsSDLserrorsSDL_NotImplementedErrorsnamesselfs library_names_version_stringssinces_version(sargsskwargssSDL(ssincesnamesself(s'build/bdist.linux-x86_64/egg/SDL/dll.pys_fs csF||}|o |iSndk}|ii|ii dS(N( sfuncsargsskwargssresultscontentss SDL.errorsSDLserrors SDL_Exceptions SDL_GetError(sargsskwargssSDLsresult(sfunc(s'build/bdist.linux-x86_64/egg/SDL/dll.pys_fs   cs)||}|o |iSntSdS(N(sfuncsargsskwargssresultscontentssNone(sargsskwargssresult(sfunc(s'build/bdist.linux-x86_64/egg/SDL/dll.pys_fs csI||}|jo%dk}|ii|ii n|SdS(N( sfuncsargsskwargssresultssuccess_returns SDL.errorsSDLserrors SDL_Exceptions SDL_GetError(sargsskwargssresultsSDL(ssuccess_returnsfunc(s'build/bdist.linux-x86_64/egg/SDL/dll.pys_fs   csI||}|jo%dk}|ii|ii n|SdS(N( sfuncsargsskwargssresults error_returns SDL.errorsSDLserrors SDL_Exceptions SDL_GetError(sargsskwargssresultsSDL(s error_returnsfunc(s'build/bdist.linux-x86_64/egg/SDL/dll.pys_fs   csD||}| o%dk}|ii|iin|SdS(N( sfuncsargsskwargssresults SDL.errorsSDLserrors SDL_Exceptions SDL_GetError(sargsskwargssSDLsresult(sfunc(s'build/bdist.linux-x86_64/egg/SDL/dll.pys_fs  cs||SdS(N(sfuncsargsskwargs(sargsskwargs(sfunc(s'build/bdist.linux-x86_64/egg/SDL/dll.pys_fsN(ssincesselfsversion_compatibles_fsargss_argssdocs__doc__snames func_names TypeErrorsgetattrs_dllsfuncs arg_typessargtypess return_typesrestypesdereference_returnsrequire_returnssuccess_returnsNones error_return( sselfsnamesdocsargss arg_typess return_typesdereference_returnsrequire_returnssuccess_returns error_returnssincesfuncs_f((sselfsnamessuccess_returns error_returnssincesfuncs'build/bdist.linux-x86_64/egg/SDL/dll.pysfunction^sB-            ( s__name__s __module__s__init__sversion_compatiblesassert_version_compatiblesprivate_functionsNonesFalsesfunction(((s'build/bdist.linux-x86_64/egg/SDL/dll.pysSDL_DLL0s   sSDLsSDL_Linked_Version(s__doc__s __docformat__s __version__sctypess ctypes.utils find_libraryssyss Structures _SDL_versions_version_partss_version_strings_platform_library_namesSDL_DLLs_dllsversion_compatiblesassert_version_compatiblesprivate_functionsfunction(sfunctions find_librarysassert_version_compatiblesversion_compatibles_version_partssprivate_functions_platform_library_names __docformat__s _SDL_versionssyssSDL_DLLs __version__s_version_strings_dll((s'build/bdist.linux-x86_64/egg/SDL/dll.pys?s       PKAn4D SDL/quit.py#!/usr/bin/env python '''Quit event handling. An `SDL_QUITEVENT` is generated when the user tries to close the application window. If it is ignored or filtered out, the window will remain open. If it is not ignored or filtered, it is queued normally and the window is allowed to close. When the window is closed, screen updates will complete, but have no effect. `SDL_Init` installs signal handlers for SIGINT (keyboard interrupt) and SIGTERM (system termination request), if handlers do not already exist, that generate `SDL_QUITEVENT` events as well. There is no way to determine the cause of an `SDL_QUITEVENT`, but setting a signal handler in your application will override the default generation of quit events for that signal. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' import SDL.events def SDL_QuitRequested(): '''Return True if there is a quit event in the event queue. :rtype: bool ''' SDL.events.SDL_PumpEvents() return SDL.events.SDL_HaveEvents(SDL.events.SDL_QUITMASK) PKAn4@V SDL/error.py#!/usr/bin/env python '''Error detection and error handling functions. ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' from ctypes import * import SDL.dll class SDL_Exception(Exception): '''Exception raised for all SDL errors. The message is as returned by `SDL_GetError`. ''' def __init__(self, message): self.message = message def __str__(self): return self.message class SDL_NotImplementedError(NotImplementedError): '''Exception raised when the available SDL library predates the requested function.''' pass SDL_SetError = SDL.dll.function('SDL_SetError', '''Set the static error string. :Parameters: `fmt` format string; subsequent integer and string arguments are interpreted as in printf(). ''', args=['fmt'], arg_types=[c_char_p], return_type=None) SDL_GetError = SDL.dll.function('SDL_GetError', '''Return the last error string set. :rtype: string ''', args=[], arg_types=[], return_type=c_char_p) SDL_ClearError = SDL.dll.function('SDL_ClearError', '''Clear any error string set. ''', args=[], arg_types=[], return_type=None) # SDL_Error not implemented (marked private in SDL_error.h) PKx4{XdTdT SDL/sound.py#!/usr/bin/env python '''An abstract sound format decoding API. The latest version of SDL_sound can be found at: http://icculus.org/SDL_sound/ The basic gist of SDL_sound is that you use an SDL_RWops to get sound data into this library, and SDL_sound will take that data, in one of several popular formats, and decode it into raw waveform data in the format of your choice. This gives you a nice abstraction for getting sound into your game or application; just feed it to SDL_sound, and it will handle decoding and converting, so you can just pass it to your SDL audio callback (or whatever). Since it gets data from an SDL_RWops, you can get the initial sound data from any number of sources: file, memory buffer, network connection, etc. As the name implies, this library depends on SDL: Simple Directmedia Layer, which is a powerful, free, and cross-platform multimedia library. It can be found at http://www.libsdl.org/ Support is in place or planned for the following sound formats: - .WAV (Microsoft WAVfile RIFF data, internal.) - .VOC (Creative Labs' Voice format, internal.) - .MP3 (MPEG-1 Layer 3 support, via the SMPEG and mpglib libraries.) - .MID (MIDI music converted to Waveform data, internal.) - .MOD (MOD files, via MikMod and ModPlug.) - .OGG (Ogg files, via Ogg Vorbis libraries.) - .SPX (Speex files, via libspeex.) - .SHN (Shorten files, internal.) - .RAW (Raw sound data in any format, internal.) - .AU (Sun's Audio format, internal.) - .AIFF (Audio Interchange format, internal.) - .FLAC (Lossless audio compression, via libFLAC.) ''' __docformat__ = 'restructuredtext' __version__ = '$Id: $' from ctypes import * import SDL.array import SDL.dll import SDL.rwops import SDL.version _dll = SDL.dll.SDL_DLL('SDL_sound', None) class Sound_Version(Structure): '''Version structure. :Ivariables: `major` : int Major version number `minor` : int Minor version number `patch` : int Patch revision number ''' _fields_ = [('major', c_int), ('minor', c_int), ('patch', c_int)] def __repr__(self): return '%d.%d.%d' % (self.major, self.minor, self.patch) _Sound_GetLinkedVersion = _dll.private_function('Sound_GetLinkedVersion', arg_types=[POINTER(Sound_Version)], return_type=None) def Sound_GetLinkedVersion(): '''Get the version of the dynamically linked SDL_sound library :rtype: `Sound_Version` ''' version = Sound_Version() _Sound_GetLinkedVersion(byref(version)) return version # Fill in non-standard linked version now, so "since" declarations can work _dll._version = SDL.dll._version_parts(Sound_GetLinkedVersion()) class Sound_AudioInfo(Structure): '''Information about an existing sample's format. :Ivariables: `format` : int Equivalent to `SDL_AudioSpec.format` `channels` : int Number of sound channels. 1 == mono, 2 == stereo. `rate` : int Sample rate, in samples per second. :see: `Sound_SampleNew` :see: `Sound_SampleNewFromFile` ''' _fields_ = [('format', c_ushort), ('channels', c_ubyte), ('rate', c_uint)] class Sound_DecoderInfo(Structure): '''Information about a sound decoder. Each decoder sets up one of these structures, which can be retrieved via the `Sound_AvailableDecoders` function. Fields in this structure are read-only. :Ivariables: `extensions` : list of str List of file extensions `description` : str Human-readable description of the decoder `author` : str Author and email address `url` : str URL specific to this decoder ''' _fields_ = [('_extensions', POINTER(c_char_p)), ('description', c_char_p), ('author', c_char_p), ('url', c_char_p)] def __getattr__(self, name): if name == 'extensions': extensions = [] ext_p = self._extensions i = 0 while ext_p[i]: extensions.append(ext_p[i]) i += 1 return extensions raise AttributeError, name class Sound_Sample(Structure): '''Represents sound data in the process of being decoded. The `Sound_Sample` structure is the heart of SDL_sound. This holds information about a source of sound data as it is beind decoded. All fields in this structure are read-only. :Ivariables: `decoder` : `Sound_DecoderInfo` Decoder used for this sample `desired` : `Sound_AudioInfo` Desired audio format for conversion `actual` : `Sound_AudioInfo` Actual audio format of the sample `buffer` : `SDL_array` Buffer of decoded data, as bytes `buffer_size` : int Current size of the buffer, in bytes `flags` : int Bitwise combination of SOUND_SAMPLEFLAG_CANSEEK, SOUND_SAMPLEFLAG_EOF, SOUND_SAMPLEFLAG_ERROR, SOUND_SAMPLEFLAG_EGAIN ''' _fields_ = [('opaque', c_void_p), ('_decoder', POINTER(Sound_DecoderInfo)), ('desired', Sound_AudioInfo), ('actual', Sound_AudioInfo), ('_buffer', POINTER(c_ubyte)), ('buffer_size', c_uint), ('flags', c_int)] def __getattr__(self, name): if name == 'decoder': return self._decoder.contents elif name == 'buffer': return SDL.array.SDL_array(self._buffer, self.buffer_size, c_ubyte) raise AttributeError, name Sound_Init = _dll.function('Sound_Init', '''Initialize SDL_sound. This must be called before any other SDL_sound function (except perhaps `Sound_GetLinkedVersion`). You should call `SDL_Init` before calling this. `Sound_Init` will attempt to call ``SDL_Init(SDL_INIT_AUDIO)``, just in case. This is a safe behaviour, but it may not configure SDL to your liking by itself. ''', args=[], arg_types=[], return_type=c_int, error_return=0) Sound_Quit = _dll.function('Sound_Quit', '''Shutdown SDL_sound. This closes any SDL_RWops that were being used as sound sources, and frees any resources in use by SDL_sound. All Sound_Sample structures existing will become invalid. Once successfully deinitialized, `Sound_Init` can be called again to restart the subsystem. All default API states are restored at this point. You should call this before `SDL_Quit`. This will not call `SDL_Quit` for you. ''', args=[], arg_types=[], return_type=c_int, error_return=0) _Sound_AvailableDecoders = _dll.private_function('Sound_AvailableDecoders', arg_types=[], return_type=POINTER(POINTER(Sound_DecoderInfo))) def Sound_AvailableDecoders(): '''Get a list of sound formats supported by this version of SDL_sound. This is for informational purposes only. Note that the extension listed is merely convention: if we list "MP3", you can open an MPEG-1 Layer 3 audio file with an extension of "XYZ", if you like. The file extensions are informational, and only required as a hint to choosing the correct decoder, since the sound data may not be coming from a file at all, thanks to the abstraction that an SDL_RWops provides. :rtype: list of `Sound_DecoderInfo` ''' decoders = [] decoder_p = _Sound_AvailableDecoders() i = 0 while decoder_p[i]: decoders.append(decoder_p[i].contents) i += 1 return decoders Sound_GetError = _dll.function('Sound_GetError', '''Get the last SDL_sound error message. This will be None if there's been no error since the last call to this function. Each thread has a unique error state associated with it, but each time a new error message is set, it will overwrite the previous one associated with that thread. It is safe to call this function at any time, even before `Sound_Init`. :rtype: str ''', args=[], arg_types=[], return_type=c_char_p) Sound_ClearError = _dll.function('Sound_ClearError', '''Clear the current error message. The next call to `Sound_GetError` after `Sound_ClearError` will return None. ''', args=[], arg_types=[], return_type=None) Sound_NewSample = _dll.function('Sound_NewSample', '''Start decoding a new sound sample. The data is read via an SDL_RWops structure, so it may be coming from memory, disk, network stream, etc. The `ext` parameter is merely a hint to determining the correct decoder; if you specify, for example, "mp3" for an extension, and one of the decoders lists that as a handled extension, then that decoder is given first shot at trying to claim the data for decoding. If none of the extensions match (or the extension is None), then every decoder examines the data to determine if it can handle it, until one accepts it. In such a case your SDL_RWops will need to be capable of rewinding to the start of the stream. If no decoders can handle the data, an exception is raised. Optionally, a desired audio format can be specified. If the incoming data is in a different format, SDL_sound will convert it to the desired format on the fly. Note that this can be an expensive operation, so it may be wise to convert data before you need to play it back, if possible, or make sure your data is initially in the format that you need it in. If you don't want to convert the data, you can specify None for a desired format. The incoming format of the data, preconversion, can be found in the `Sound_Sample` structure. Note that the raw sound data "decoder" needs you to specify both the extension "RAW" and a "desired" format, or it will refuse to handle the data. This is to prevent it from catching all formats unsupported by the other decoders. Finally, specify an initial buffer size; this is the number of bytes that will be allocated to store each read from the sound buffer. The more you can safely allocate, the more decoding can be done in one block, but the more resources you have to use up, and the longer each decoding call will take. Note that different data formats require more or less space to store. This buffer can be resized via `Sound_SetBufferSize`. The buffer size specified must be a multiple of the size of a single sample point. So, if you want 16-bit, stereo samples, then your sample point size is (2 channels 16 bits), or 32 bits per sample, which is four bytes. In such a case, you could specify 128 or 132 bytes for a buffer, but not 129, 130, or 131 (although in reality, you'll want to specify a MUCH larger buffer). When you are done with this `Sound_Sample` instance, you can dispose of it via `Sound_FreeSample`. You do not have to keep a reference to `rw` around. If this function suceeds, it stores `rw` internally (and disposes of it during the call to `Sound_FreeSample`). If this function fails, it will dispose of the SDL_RWops for you. :Parameters: `rw` : `SDL_RWops` SDL_RWops with sound data `ext` : str File extension normally associated with a data format. Can usually be None. `desired` : `Sound_AudioInfo` Format to convert sound data into. Can usually be None if you don't need conversion. `bufferSize` : int Size, in bytes, to allocate for the decoding buffer :rtype: `Sound_Sample` ''', args=['rw', 'ext', 'desired', 'bufferSize'], arg_types=[POINTER(SDL.rwops.SDL_RWops), c_char_p, POINTER(Sound_AudioInfo), c_uint], return_type=POINTER(Sound_Sample), dereference_return=True, require_return=True) _Sound_NewSampleFromMem = _dll.private_function('Sound_NewSampleFromMem', arg_types=[POINTER(c_ubyte), c_uint, c_char_p, POINTER(Sound_AudioInfo), c_uint], return_type=POINTER(Sound_Sample), dereference_return=True, require_return=True, since=(9,9,9)) # Appears in header only def Sound_NewSampleFromMem(data, ext, desired, bufferSize): '''Start decoding a new sound sample from a buffer. This is identical to `Sound_NewSample`, but it creates an `SDL_RWops` for you from the buffer. :Parameters: `data` : `SDL_array` or sequence Buffer holding encoded byte sound data `ext` : str File extension normally associated with a data format. Can usually be None. `desired` : `Sound_AudioInfo` Format to convert sound data into. Can usually be None if you don't need conversion. `bufferSize` : int Size, in bytes, to allocate for the decoding buffer :rtype: `Sound_Sample` :since: Not yet released in SDL_sound ''' ref, data = SDL.array.to_ctypes(data, len(data), c_ubyte) return _Sound_NewSampleFromMem(data, len(data), ext, desired, bufferSize) Sound_NewSampleFromFile = _dll.function('Sound_NewSampleFromFile', '''Start decoding a new sound sample from a file on disk. This is identical to `Sound_NewSample`, but it creates an `SDL_RWops for you from the file located at `filename`. ''', args=['filename', 'desired', 'bufferSize'], arg_types=[c_char_p, POINTER(Sound_AudioInfo), c_uint], return_type=POINTER(Sound_Sample), dereference_return=True, require_return=True) Sound_FreeSample = _dll.function('Sound_FreeSample', '''Dispose of a `Sound_Sample`. This will also close/dispose of the `SDL_RWops` that was used at creation time. The `Sound_Sample` structure is invalid after this call. :Parameters: `sample` : `Sound_Sample` The sound sample to delete. ''', args=['sample'], arg_types=[POINTER(Sound_Sample)], return_type=None) Sound_GetDuration = _dll.function('Sound_GetDuration', '''Retrieve the total play time of a sample, in milliseconds. Report total time length of sample, in milliseconds. This is a fast call. Duration is calculated during `Sound_NewSample`, so this is just an accessor into otherwise opaque data. Note that not all formats can determine a total time, some can't be exact without fully decoding the data, and thus will estimate the duration. Many decoders will require the ability to seek in the data stream to calculate this, so even if we can tell you how long an .ogg file will be, the same data set may fail if it's, say, streamed over an HTTP connection. :Parameters: `sample` : `Sound_Sample` Sample from which to retrieve duration information. :rtype: int :return: Sample length in milliseconds, or -1 if duration can't be determined. :since: Not yet released in SDL_sound ''', args=['sample'], arg_types=[POINTER(Sound_Sample)], return_type=c_int, since=(9,9,9)) Sound_SetBufferSize = _dll.function('Sound_SetBufferSize', '''Change the current buffer size for a sample. If the buffer size could be changed, then the ``sample.buffer`` and ``sample.buffer_size`` fields will reflect that. If they could not be changed, then your original sample state is preserved. If the buffer is shrinking, the data at the end of buffer is truncated. If the buffer is growing, the contents of the new space at the end is undefined until you decode more into it or initialize it yourself. The buffer size specified must be a multiple of the size of a single sample point. So, if you want 16-bit, stereo samples, then your sample point size is (2 channels 16 bits), or 32 bits per sample, which is four bytes. In such a case, you could specify 128 or 132 bytes for a buffer, but not 129, 130, or 131 (although in reality, you'll want to specify a MUCH larger buffer). :Parameters: `sample` : `Sound_Sample` Sample to modify `new_size` : int The desired size, in bytes of the new buffer ''', args=['sample', 'new_size'], arg_types=[POINTER(Sound_Sample), c_uint], return_type=c_int, error_return=0) Sound_Decode = _dll.function('Sound_Decode', '''Decode more of the sound data in a `Sound_Sample`. It will decode at most sample->buffer_size bytes into ``sample.buffer`` in the desired format, and return the number of decoded bytes. If ``sample.buffer_size`` bytes could not be decoded, then refer to ``sample.flags`` to determine if this was an end-of-stream or error condition. :Parameters: `sample` : `Sound_Sample` Do more decoding to this sample :rtype: int :return: number of bytes decoded into ``sample.buffer`` ''', args=['sample'], arg_types=[POINTER(Sound_Sample)], return_type=c_uint) Sound_DecodeAll = _dll.function('Sound_DecodeAll', '''Decode the remainder of the sound data in a `Sound_Sample`. This will dynamically allocate memory for the entire remaining sample. ``sample.buffer_size`` and ``sample.buffer`` will be updated to reflect the new buffer. Refer to ``sample.flags`` to determine if the decoding finished due to an End-of-stream or error condition. Be aware that sound data can take a large amount of memory, and that this function may block for quite awhile while processing. Also note that a streaming source (for example, from a SDL_RWops that is getting fed from an Internet radio feed that doesn't end) may fill all available memory before giving up...be sure to use this on finite sound sources only. When decoding the sample in its entirety, the work is done one buffer at a time. That is, sound is decoded in ``sample.buffer_size`` blocks, and appended to a continually-growing buffer until the decoding completes. That means that this function will need enough RAM to hold approximately ``sample.buffer_size`` bytes plus the complete decoded sample at most. The larger your buffer size, the less overhead this function needs, but beware the possibility of paging to disk. Best to make this user-configurable if the sample isn't specific and small. :Parameters: `sample` : `Sound_Sample` Do all decoding for this sample. :rtype: int :return: number of bytes decoded into ``sample.buffer`` ''', args=['sample'], arg_types=[POINTER(Sound_Sample)], return_type=c_uint) Sound_Rewind = _dll.function('Sound_Rewind', '''Rewind a sample to the start. Restart a sample at the start of its waveform data, as if newly created with `Sound_NewSample`. If successful, the next call to `Sound_Decode` will give audio data from the earliest point in the stream. Beware that this function will fail if the SDL_RWops that feeds the decoder can not be rewound via it's seek method, but this can theoretically be avoided by wrapping it in some sort of buffering SDL_RWops. This function will raise an exception if the RWops is not seekable, or SDL_sound is not initialized. If this function fails, the state of the sample is undefined, but it is still safe to call `Sound_FreeSample` to dispose of it. :Parameters: `sample` : `Sound_Sample` The sample to rewind ''', args=['sample'], arg_types=[POINTER(Sound_Sample)], return_type=c_int, error_return=0) Sound_Seek = _dll.function('Sound_Seek', '''Seek to a different point in a sample. Reposition a sample's stream. If successful, the next call to `Sound_Decode` or `Sound_DecodeAll` will give audio data from the offset you specified. The offset is specified in milliseconds from the start of the sample. Beware that this function can fail for several reasons. If the SDL_RWops that feeds the decoder can not seek, this call will almost certainly fail, but this can theoretically be avoided by wrapping it in some sort of buffering SDL_RWops. Some decoders can never seek, others can only seek with certain files. The decoders will set a flag in the sample at creation time to help you determine this. You should check ``sample.flags & SOUND_SAMPLEFLAG_CANSEEK`` before attempting. `Sound_Seek` reports failure immediately if this flag isn't set. This function can still fail for other reasons if the flag is set. This function can be emulated in the application with `Sound_Rewind` and predecoding a specific amount of the sample, but this can be extremely inefficient. `Sound_Seek()` accelerates the seek on a with decoder-specific code. If this function fails, the sample should continue to function as if this call was never made. If there was an unrecoverable error, ``sample.flags & SOUND_SAMPLEFLAG_ERROR`` will be set, which your regular decoding loop can pick up. On success, ERROR, EOF, and EAGAIN are cleared from sample->flags. :Parameters: `sample` : `Sound_Sample` The sample to seek `ms` : int The new position, in milliseconds, from the start of sample ''', args=['sample', 'ms'], arg_types=[POINTER(Sound_Sample), c_uint], return_type=c_int, error_return=0) PK)5Upzz SDL/timer.pyc; Dc @s=dZdZdZdkTdkZeiidddgdgd eZ eiid d dd gdegd e Z e e eZeiid deegd e Ze adZe ee eZeiiddeeegd eZhadZeiidddgdegd e ddZdZdS(sTime management routines. srestructuredtexts$Id: $(s*Ns SDL_GetTickssGet the number of milliseconds since the SDL library initialization. Note that this value wraps if the program runs for more than ~49 days. :rtype: int sargss arg_typess return_types SDL_DelaysWait a specified number of milliseconds before returning. :Parameters: `ms` : int delay in milliseconds smss SDL_SetTimercCsV|ot|an tat|tdjotiitiindS(s|Set a callback to run after the specified number of milliseconds has elapsed. The callback function is passed the current timer interval and returns the next timer interval. If the returned value is the same as the one passed in, the periodic alarm continues, otherwise a new alarm is scheduled. If the callback returns 0, the periodic alarm is cancelled. To cancel a currently running timer, call ``SDL_SetTimer(0, None)``. The timer callback function may run in a different thread than your main code, and so shouldn't call any functions from within itself. The maximum resolution of this timer is 10 ms, which means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system. If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms:: SDL_SetTimer((33/10)*10, flag_update) If you use this function, you need to pass `SDL_INIT_TIMER` to `SDL_Init`. Under UNIX, you should not use raise or use SIGALRM and this function in the same program, as it is implemented using ``setitimer``. You also should not use this function in multi-threaded applications as signals to multi-threaded apps have undefined behavior in some implementations. :Parameters: `interval` : int Interval before callback, in milliseconds. `callback` : function Callback function should accept one argumen