Beispiel #1
0
SDL_Delay = dll.function('SDL_Delay',
    '''Wait a specified number of milliseconds before returning.

    :Parameters:
        `ms` : int
            delay in milliseconds

    ''',
    args=['ms'],
    arg_types=[c_uint],
    return_type=None)

_SDL_TimerCallback = CFUNCTYPE(c_int, c_uint)
_SDL_SetTimer = dll.private_function('SDL_SetTimer',
    arg_types=[c_uint, _SDL_TimerCallback],
    return_type=c_int)

_timercallback_ref = None   # Keep global to avoid possible GC

def SDL_SetTimer(interval, callback):
    '''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)``.
Beispiel #2
0
        ("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 = 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):
Beispiel #3
0
import ctypes
import sys

import dll as SDL_dll
from audio import *
from constants import *
from endian import *
from error import *
from rwops import *
from timer import *

# SDL.h

_SDL_Init = SDL_dll.private_function('SDL_Init',
                                     arg_types=[ctypes.c_uint],
                                     return_type=ctypes.c_int)


def SDL_Init(flags):
    '''Initialise the SDL library.

    This function loads the SDL dynamically linked library and initializes 
    the subsystems specified by `flags` (and those satisfying dependencies)
    Unless the `SDL_INIT_NOPARACHUTE` flag is set, it will install cleanup
    signal handlers for some commonly ignored fatal signals (like SIGSEGV).

    The following flags are recognised:

        - `SDL_INIT_TIMER`
        - `SDL_INIT_AUDIO`
Beispiel #4
0
    '''
    _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 = 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)
Beispiel #5
0
import ctypes
import sys

import dll as SDL_dll
from audio import *
from constants import *
from endian import *
from error import *
from rwops import *
from timer import *

# SDL.h

_SDL_Init = SDL_dll.private_function('SDL_Init',
    arg_types=[ctypes.c_uint],
    return_type=ctypes.c_int)

def SDL_Init(flags):
    '''Initialise the SDL library.

    This function loads the SDL dynamically linked library and initializes 
    the subsystems specified by `flags` (and those satisfying dependencies)
    Unless the `SDL_INIT_NOPARACHUTE` flag is set, it will install cleanup
    signal handlers for some commonly ignored fatal signals (like SIGSEGV).

    The following flags are recognised:

        - `SDL_INIT_TIMER`
        - `SDL_INIT_AUDIO`
        - `SDL_INIT_VIDEO`
Beispiel #6
0
SDL_Delay = dll.function(
    'SDL_Delay',
    '''Wait a specified number of milliseconds before returning.

    :Parameters:
        `ms` : int
            delay in milliseconds

    ''',
    args=['ms'],
    arg_types=[c_uint],
    return_type=None)

_SDL_TimerCallback = CFUNCTYPE(c_int, c_uint)
_SDL_SetTimer = dll.private_function('SDL_SetTimer',
                                     arg_types=[c_uint, _SDL_TimerCallback],
                                     return_type=c_int)

_timercallback_ref = None  # Keep global to avoid possible GC


def SDL_SetTimer(interval, callback):
    '''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.