18 lines
419 B
Zig
18 lines
419 B
Zig
const Game = @import("Game.zig");
|
|
const Self = @This();
|
|
|
|
activate: bool = false,
|
|
holding: bool = false,
|
|
code: u8, // SDL Keycode
|
|
callback: *const anyopaque,
|
|
|
|
pub fn init(code: u8, callback: *const anyopaque) Self {
|
|
return Self{
|
|
.code = code,
|
|
.callback = callback,
|
|
};
|
|
}
|
|
pub fn call(self: Self, state: anytype) void {
|
|
@call(.{}, @ptrCast(fn (@TypeOf(state)) void, self.callback), .{state});
|
|
}
|