sdl2
Both high- and low-level bindings to the SDL library (version 2.0.6+).
| LTS Haskell 24.16: | 2.5.5.1 |
| Stackage Nightly 2025-10-24: | 2.5.5.1 |
| Latest on Hackage: | 2.5.5.1 |
sdl2-2.5.5.1@sha256:7e2c55ca0ec4b538351fd3cceb71dbc5f99893dd326a7db78efa4adecc43c086,12150This package contains bindings to the SDL 2 library, in both high- and low-level forms:
The SDL namespace contains high-level bindings, where enumerations are split
into sum types, and we perform automatic error-checking.
The SDL.Raw namespace contains an almost 1-1 translation of the C API into
Haskell FFI calls. As such, this does not contain sum types nor error
checking. Thus this namespace is suitable for building your own abstraction
over SDL, but is not recommended for day-to-day programming.
Read SDL for a getting started guide.
Changes
2.5.X.Y
2.5.5.1
- Added
getTicks64 - Added
rendererIntegerScale - Added unboxed Vector instances for Rectangle
- Updated dependency ranges
2.5.5.0
- Added
windowOpacityproperty - Added
renderGeometryandrenderGeometryRaw- Requires SDL 2.0.18
- See
examples/RenderGeometry.hs
- Changed
SDL.Input.GameControllerbindings to be more high-levelControllerAxisEventDatatype changed
2.5.4.0
- Added missing floating point variants of render functions.
- Fixed
createCursormasks. - Adapted
createCursorFromhelper from LambdaHack1. - Added
pkgconfigflag (enabled by default) to make its use optional.
2.5.3.3
- Alignment in hsc files is now provided by hsc2c.
2.5.3.2
- Added high-level binding for
setWindowIcon. - Raised
textupper bound to 2.0. - Fixed and optimized even polling for SDL 2.0.20.
copyExFand related are under a package flag now. Turn onrecent-ishif you have at least 2.0.10.- Removed misleading result type from
updateTexture.
2.5.3.1
- Constructors exported for ModalLocation, SurfacePixelFormat, AudioSpec.
- Added getWindowBordersSize.
- Added SDL.Input.Mouse.createSystemCursor.
2.5.3.0
- Correct the Storable instance for SDL.Raw.Types.Event to correctly convert SDL_CONTROLLERAXISMOTION to a ControllerAxisEvent (it was previously ControllerButtonEvent). See https://github.com/haskell-game/sdl2/pull/218 for more details.
2.5.2.0
- Correct SDL.Raw.Video.vkLoadLibrary to correctly call vkLoadLibraryFFI, rather than setClipboardTextFFI. See https://github.com/haskell-game/sdl2/pull/209.
2.5.1.0
- Support
linear-1.21
2.5.0.0
-
Version 2.0.6 of the SDL2 C library is now required.
-
Added Vulkan support. See
SDL.Video.WindowGraphicsContextdata type andSDL.Video.Vulkanmodule. -
Support
StateVar< 1.3
2.4.1.0
-
More SDL functions no longer allocate. See https://github.com/haskell-game/sdl2/pull/179 and https://github.com/haskell-game/sdl2/issues/178. Thanks to @chrisdone for this work.
-
Fixed an off-by-one bug in
SDL.Input.Mouse.getMouseButtons. See https://github.com/haskell-game/sdl2/pull/177 for more information. Thanks to @Linearity for identifying and fixing this bug.
2.4.0.1
- Raise upper bounds for
exceptionsto <0.11
2.4.0
getRelativeMouseLocationnow returnsVectorinstead ofPoint.getModalMouseLocationreturns either aVectoror aPoint, wrapped in (new)ModalLocation.WindowSizeChangedEventDataincludes the new window size.- Added an invalid state to the
ControllerButtonStateenum, and switched to a more reliable state detection method. - Raise upper bounds for
exceptionsto <0.10
2.3.0
- Windows builds now use
-D_SDL_main_h. See https://github.com/haskell-game/sdl2/issues/139 for more discussion. - Some basic support for game controller events have been added. See
SDL.Input.GameControllerand changes toControllerDeviceEventData. - Support for event watching:
addEventWatchanddelEventWatch. - High-level bindings now distinguish between finger down / motion / up.
See
SDL.Event.TouchFingerEventandSDL.Event.TouchFingerMotionEvent. - Several event payloads now have their
Windowfields modified to useMaybe Window, substitutingNothingfor null pointers. - High-level structure for controller button state:
ControllerButtonState. - High-level structure for controller buttons:
ControllerButton. - High-level structure for controller connection:
ControllerDeviceConnection. - High-level structure for joystick device connection:
JoyDeviceConnection. - High-level structure for joystick button state:
JoyButtonState. - Support for user defined events:
registerEvent,pushRegisteredEvent, andgetRegisteredEvent. - Initial window visibility can be specified in
WindowConfigforcreateWindowfunction. WarpMouseOriginis now fully exported and can warp to global coordinates.- It’s possible to retrieve palette information with
paletteNColors,paletteColorsandpalletColor.
2.2.0
-
Version 2.0.4 of the SDL2 C library is now required:
SDL.Event:- Add
AudioDeviceEventconstructor toEvent - Add
KeymapChangedEventconstructor toEventPayload - Add
mouseWheelEventDirectionfield toMouseWheelEventData
- Add
SDL.Input.Mouse:- Add
MouseScrollDirectionenumeration
- Add
SDL.Raw.Audio:- Add
clearQueuedAudiofunction - Add
getQueuedAudioSizefunction - Add
queueAudiofunction
- Add
SDL.Raw.Enum:- Add
SDL_GL_CONTEXT_RELEASE_BEHAVIORpattern synonym - Add
JoystickPowerLevelpattern synonyms - Add
SDL_MOUSEWHEEL_NORMALandSDL_MOUSEWHEEL_FLIPPEDpattern synonyms - Add
SDL_KEYMAPCHANGED,SDL_AUDIODEVICEADDED,SDL_AUDIODEVICEREMOVED,SDL_RENDER_TARGETS_RESET, andSDL_RENDER_DEVICE_RESETpattern synonyms - Add
SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONEandSDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSHpattern synonyms - Add
SDL_WINDOW_MOUSE_CAPTUREpattern synonym
- Add
SDL.Raw.Event:- Add
captureMousefunction - Add
getGlobalMouseStatefunction - Add
warpMouseGlobalfunction - Add
joystickCurrentPowerLevelfunction - Add
joystickFromInstanceIDfunction - Add
gameControllerFromInstanceIDfunction
- Add
SDL.Raw.Event:- Add
AudioDeviceEventconstructor toEvent - Add
KeymapChangedEventconstructor toEvent - Add
mouseWheelEventDirectionfield toMouseMotionEventconstructor
- Add
-
Add
SDL.Exceptionmodule, exposingSDLException -
Add new function,
createSoftwareRenderer, to render onto a surface -
Add joystick POV hat support
-
Remove deprecated functionality:
InitEverythingenumeration inSDL.InitmapRGBinSDL.Video.RenderersetRelativeMouseModeinSDL.Input.MousegetRelativeMouseModeinSDL.Input.MousegetMouseLocationinSDL.Input.Mouse
-
Remove
ClipboardUpdateEventData -
Merge
isScreenSaverEnabled,enableScreenSaver, anddisableScreenSaverinto ascreenSaverEnabledStateVar. -
Make function
surfaceBlitinSDL.Video.Rendererreturn final blit rectangle post-clipping. -
Make all fields in EventData constructors strict
-
Fix issue with
setWindowModetransitions not working properly between fullscreen and windowed modes.
2.1.3.1
- Raise upper bounds for
vectorto <0.13
2.1.3
- Cabal flag
no-linearremoves dependency onlinear(and thus, transiently,lens). SeeSDL.Vectfor details. - Remove ‘lens’ dependency from all examples.
- Add Cabal flag
opengl-exampleto separate that target fromexamples, because it is now the only example with an extra dependency (OpenGL). - Make
hlinthappy with examples. - Add
updateTexturewrapper for nativeSDL_UpdateTexture. - Expose
glGetDrawableSize(can differ from window size in some environments). - Correct
hintToStringoutput to match SDL hint tokens, rather than the names of the CPP macros defining them. - Removed
ghc-options: -Walluntil we drop support for GHC 7.8. (>1300 warnings!) - Various documentation updates.
2.1.2.1
- Raise upper bounds for
lensto <4.15 (affects examples only)
2.1.2
- Revise some documentation examples to be more idomatic
- Update
.gitignoreto coverstackand other tools - Raise upper bounds for
transformersto <0.6 - Lower required SDL2 version to 2.0.2.
- Fix decoding of
TextEditingEventwhere the Raw bindings failed to stop reading character data past the null terminator.
2.1.1
SDL.Input.Mousenew has a new API for fetching the location of the mouse. This API gives you greater control over finding the mouse position with respect to the various “modes” a mouse can be in. The old API still exists, but will be removed at some point in the future.SDL.Rawnow has a binding toSDL_free.
2.1.0
- Introduce
initializeAlland deprecateInitEverything. To fix this deprecation warning, changeinitialize [InitEverything]toinitializeAll. surfaceColorKey,surfaceFillRectandsurfaceFillRectsnow all operate on on RGBAV4 Word8values. They all implicitly map and unmap (usingSDL_MapRGBAandSDL_GetRGBArespectively).SDL.mapRGBis now deprecated, as this conversion is always done for you. If you still need this routine, useSDL.Raw.mapRGB.- Fix a runtime crash when reading the current BlendMode of a texture. Thanks to @seppeljordan for discovering and fixing this bug.
2.0.0
- Introduce a set of comprehensive high-level bindings to SDL. These bindings
should allow users to work with SDL while writing idiomatic Haskell code. They
take care of pointer manipulation, and wrap up values in much more “natural”
data types. The high-level bindings live in the
SDLnamespace, and have been extensively documented. - Raw bindings have been moved from
Graphics.UI.SDLtoSDL.Raw.
1.3.1
- Correct type signature of
getSurfaceBlendMode
1.3.0
- Use pattern synonyms exclusively
Graphics.UI.SDL.Enum.PatternoverridesGraphics.UI.SDL.Enum
- Generalize all IO functions over MonadIO
- Add convenience wrapper functions for constructing FunPtr callbacks
- Add Typeable instances to all type classes
- Add strictness annotations to all data structure fields
- Add missing
SDLK_AUDIOPREVenumeration - Correct deserialization of
SDL_TEXTINPUTevent- Data beyond the null terminator was returned previously
1.2.0
- Add support for pattern synonyms as an alternative for SDL enumerations
- Only present when compiling with GHC 7.8 or newer
- Add missing enumerations:
keymodShift,keymodCtrl,keymodAlt,keymodGUIkeyPressend,keyReleasedtoucheMouseID
- Specialize init flags over
InitFlag, aWord32 - Generalize
keymod*enumerations overNum- The C API is inconsistent on their types
- Fix foreign imports on
Graphics.UI.SDL.Thread - Correct type signature of
getRenderDrawBlendMode - Correct type signature of
queryTexture - Remove export of
KeycodefromGraphics.UI.SDL.TypesGraphics.UI.SDL.Enumalready exportsKeycode
1.1.3
- Add missing
Keycodeenumerations - Add missing enumerations:
audioAllowFrequencyChange,audioAllowFormatChangeaudioAllowChannelsChange,audioAllowAnyChange
1.1.2
- Add
ClipboardUpdateEventtoEventdata structure - Add
UnknownEventtoEventdata structure
1.1.1
- Add
Graphics.UI.SDL.Platformmodule - Add
Graphics.UI.SDL.Threadmodule and associated types and enumerations - Add
getWindowWMInfo - Add
setError - Add additional logging functions
1.1.0
- Require SDL 2.0.3
- Add
gameControllerAddMappingsFromFile - Add
gameControllerAddMappingsFromRW - Add
glResetAttributes - Add
mouseButtonEventClicksfield toWindowEvent
- Add
- Add missing mouse button enumerations
1.0.2
- Correct type signature of
getNumTouchFingers
1.0.1
- Factor type of
addHintCallbackanddelHintCallbackintoHintCallback - Add
Versiondata structure