examples: use engine.core.setKeyCallback() instead of accessing glfw directly

This commit is contained in:
iddev5 2022-05-09 12:55:45 +05:30 committed by Stephen Gutekanst
parent 5396769227
commit 1f95bd48df
6 changed files with 18 additions and 32 deletions

View file

@ -38,7 +38,7 @@ const FrameParams = struct {
};
pub fn init(app: *App, engine: *mach.Engine) !void {
engine.core.internal.window.setKeyCallback(keyCallback);
engine.core.setKeyCallback(keyCallback);
// todo
// engine.core.internal.window.setKeyCallback(struct {
// fn callback(window: glfw.Window, key: glfw.Key, scancode: i32, action: glfw.Action, mods: glfw.Mods) void {
@ -879,14 +879,10 @@ const Instance = struct {
}
};
fn keyCallback(window: glfw.Window, key: glfw.Key, scancode: i32, action: glfw.Action, mods: glfw.Mods) void {
_ = window;
_ = scancode;
_ = mods;
fn keyCallback(_: *App, engine: *mach.Engine, key: mach.Key, action: mach.Action) void {
if (action == .press) {
switch (key) {
.q, .escape, .space => window.setShouldClose(true),
.q, .escape, .space => engine.core.internal.window.setShouldClose(true),
.w, .up => {
global_params.keys |= FrameParams.up;
},