sdl2.ext.common - Frequently Used SDL2 Functions¶
This module wraps various common SDL2 functions, including methods for initializing and quitting SDL2 and its various subsystems and for retrieving events from the SDL2 event queue.
-
sdl2.ext.common.
init
(video=True, audio=False, timer=False, joystick=False, controller=False, haptic=False, sensor=False, events=True)[source]¶ Initializes SDL and its optional subsystems.
By default, only the video and events subsystems are initialized. Note that the sensor subsystem requires SDL 2.0.9 or later.
Parameters: - video (bool, optional) – Whether to initialize the SDL video subsystem. If True, the events subsystem will also be initialized. Defaults to True.
- audio (bool, optional) – Whether to initialize the SDL audio subsystem. Defaults to False.
- timer (bool, optional) – Whether to initialize the SDL timer subsystem. Defaults to False.
- joystick (bool, optional) – Whether to initialize the SDL joystick subsystem. If True, the events subsystem will also be initialized. Defaults to False.
- controller (bool, optional) – Whether to initialize the SDL gamecontroller subsystem. If True, the joystick subsystem will also be initialized. Defaults to False.
- haptic (bool, optional) – Whether to initialize the SDL haptic (force feedback) subsystem. Defaults to False.
- sensor (bool, optional) – Whether to initialize the SDL sensor subsystem. Defaults to False.
- events (bool, optional) – Whether to initialize the SDL events subsystem. Will automatically be initialized if the video, joystick, or gamecontroller subsystems are enabled. Defaults to False.
See pygame for a comparison between this function and
pygame.init()
.Raises: SDLError
– If a requested SDL subsystem cannot be initialized.
-
sdl2.ext.common.
quit
()[source]¶ Quits the SDL2 video subysystem.
If no other subsystems are active, this will also call
sdl2.SDL_Quit()
,sdlttf.TTF_Quit()
andsdlimage.IMG_Quit()
.
-
sdl2.ext.common.
get_events
()[source]¶ Gets all SDL events that are currently on the event queue.
Returns: A list of all SDL_Event
objects currently in the event queue.Return type: List