Print key buffer on key event

This commit is contained in:
Brandon Dyck 2022-01-18 17:38:32 -07:00
parent ee93860c74
commit a264206a67
2 changed files with 16 additions and 1 deletions

@ -1 +1 @@
Subproject commit 8e8a66761cb003b00ecc7a38307e83ddd33ffa27 Subproject commit d173dcc4da9b934a37ac13e7e11431984e25f70c

View File

@ -226,6 +226,21 @@ fn handleKeyboard(win: mfb.Window(State), key: mfb.Key, _: mfb.KeyMod, is_presse
var state = win.getUserData().?; var state = win.getUserData().?;
state.*.paused = !state.*.paused; state.*.paused = !state.*.paused;
} }
const out = std.io.getStdOut().writer();
var has_written = false;
for (win.getKeyBuffer()) |buf_key, i| {
if (buf_key) {
if (!has_written) {
_ = out.write("Keyboard buffer:") catch unreachable;
}
std.fmt.format(out, " {}", .{@intToEnum(mfb.Key, i)}) catch unreachable;
has_written = true;
}
}
if (has_written) {
out.writeByte('\n') catch unreachable;
}
} }
fn handleCharInput(win: mfb.Window(State), char: u32) callconv(.C) void { fn handleCharInput(win: mfb.Window(State), char: u32) callconv(.C) void {