glfw: dont call getError unless we need to
This commit is contained in:
parent
746b0dd1f0
commit
3e79a12f3d
11 changed files with 111 additions and 92 deletions
|
|
@ -243,13 +243,14 @@ pub const Key = enum(c_int) {
|
|||
pub inline fn getScancode(self: Key) error{PlatformError}!i32 {
|
||||
internal_debug.assertInitialized();
|
||||
const scancode = cc.glfwGetKeyScancode(@enumToInt(self));
|
||||
if (scancode != -1) return scancode;
|
||||
getError() catch |err| return switch (err) {
|
||||
Error.NotInitialized => unreachable,
|
||||
Error.InvalidEnum => unreachable,
|
||||
Error.PlatformError => @errSetCast(error{PlatformError}, err),
|
||||
else => unreachable,
|
||||
};
|
||||
return scancode;
|
||||
unreachable;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue