M sdl2/keyboard.ha => sdl2/keyboard.ha +10 -0
@@ 643,3 643,13 @@ export fn SDL_GetKeyFromName(name: str) (SDL_Keycode | error) = {
};
return sym;
};
+
+@symbol("SDL_GetKeyboardState") fn _SDL_GetKeyboardState(numkeys: *int) *[*]bool;
+
+export fn SDL_GetKeyboardState() []bool = {
+ let numkeys: int = 0;
+ let arr = _SDL_GetKeyboardState(&numkeys);
+ let arr = arr[..numkeys];
+ return arr;
+};
+
M sdl2/pixels.ha => sdl2/pixels.ha +15 -0
@@ 1,4 1,5 @@
// TODO: Flesh me out
+use types::c;
export type SDL_Color = struct {
r: u8,
@@ 38,3 39,17 @@ export type SDL_PixelFormat = struct {
};
export def SDL_PIXELFORMAT_ARGB8888: u32 = 0x16362004;
+
+@symbol("SDL_GetPixelFormatName") fn _SDL_GetPixelFormatName(format: u32)
+ const *c::char;
+
+// Get the human readable name of a pixel format.
+export fn SDL_GetPixelFormatName(format: u32) str = {
+ return c::tostr(_SDL_GetPixelFormatName(format))!;
+};
+
+// Map an RGB triple to an opaque pixel value for a given pixel format.
+export @symbol("SDL_MapRGB") fn SDL_MapRGB(format: *SDL_PixelFormat, r: u8, g: u8, b: u8) u32;
+
+// Map an RGBA quadruple to a pixel value for a given pixel format.
+export @symbol("SDL_MapRGBA") fn SDL_MapRGBA(format: *SDL_PixelFormat, r: u8, g: u8, b: u8, a: u8) u32;
M sdl2/surface.ha => sdl2/surface.ha +9 -0
@@ 35,3 35,12 @@ export fn SDL_CreateRGBSurface(flags: u32,
return wrapptr(_SDL_CreateRGBSurface(flags, width, height, depth, Rmask,
Gmask, Bmask, Amask))?: *SDL_Surface;
};
+
+// NB SDL_BlitSurface is aliased to SDL_UpperBlit via a macro in the SDL header
+@symbol("SDL_UpperBlit") fn _SDL_BlitSurface(src: *SDL_Surface,
+ srcrect: nullable *SDL_Rect, dst: *SDL_Surface, dstrect: nullable *SDL_Rect) int;
+
+// Perform a fast surface copy to a destination surface.
+export fn SDL_BlitSurface(src: *SDL_Surface, srcrect: nullable *SDL_Rect, dst: *SDL_Surface, dstrect: nullable *SDL_Rect) (void | error) = {
+ return wrapvoid(_SDL_BlitSurface(src, srcrect, dst, dstrect));
+};
M sdl2/video.ha => sdl2/video.ha +10 -1
@@ 99,10 99,19 @@ export @symbol("SDL_DestroyWindow") fn SDL_DestroyWindow(window: *SDL_Window) vo
export @symbol("SDL_GetWindowSize") fn SDL_GetWindowSize(window: *SDL_Window,
w: nullable *int, h: nullable *int) void;
-// Get the SDL surface associated with the window.
@symbol("SDL_GetWindowSurface") fn _SDL_GetWindowSurface(window: *SDL_Window)
*SDL_Surface;
+// Get the SDL surface associated with the window.
export fn SDL_GetWindowSurface(window: *SDL_Window) (*SDL_Surface | error) = {
return wrapptr(_SDL_GetWindowSurface(window))?: *SDL_Surface;
};
+
+// Copy the window surface to the screen.
+@symbol("SDL_UpdateWindowSurface") fn _SDL_UpdateWindowSurface(window: *SDL_Window)
+ int;
+
+export fn SDL_UpdateWindowSurface(window: *SDL_Window) (void | error) = {
+ return wrapvoid(_SDL_UpdateWindowSurface(window));
+};
+