usg/src/Action.zig

18 lines
496 B
Zig

const Self = @This();
const SDL = @import("sdl2");
activate: bool = false,
holding: bool = false,
scancode: SDL.Scancode, // SDL Keycode
callback: *const anyopaque, // MUST be a function with void return
pub fn init(scancode: SDL.Scancode, callback: *const anyopaque) Self {
return Self{
.scancode = scancode,
.callback = callback,
};
}
pub fn call(self: Self, state: anytype) void {
@call(.{}, @ptrCast(*const fn (@TypeOf(state)) void, self.callback), .{state});
}