summary refs log tree commit diff
path: root/src/Window.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Window.zig')
-rw-r--r--src/Window.zig9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Window.zig b/src/Window.zig
index d15dad3..74433e8 100644
--- a/src/Window.zig
+++ b/src/Window.zig
@@ -18,6 +18,7 @@
 
 usingnamespace @import("cimport.zig");
 const Error = gfz.Error;
+const Key = @import("input.zig").Key;
 const Monitor = @import("Monitor.zig");
 const checkError = gfz.checkError;
 const getError = gfz.getError;
@@ -25,7 +26,7 @@ const gfz = @import("gfz.zig");
 
 const Self = @This();
 const CursorPosFun = fn (window: Self, xpos: f64, ypos: f64) void;
-const KeyFun = fn (window: Self, key: c_int, scancode: c_int,
+const KeyFun = fn (window: Self, key: Key, scancode: c_int,
                    action: c_int, mods: c_int) void;
 const MouseButtonFun = fn (window: Self, button: c_int,
                            action: c_int, mods: c_int) void;
@@ -46,7 +47,7 @@ fn fnCast(comptime DestType: type, comptime fun: anytype) DestType {
             pub fn callback(window: ?*Impl, key: c_int, scancode: c_int,
                             action: c_int, mods: c_int) callconv(.C) void {
                 fun(@fieldParentPtr(Self, "pimpl", &window.?).*,
-                    key, scancode, action, mods);
+                    @intToEnum(Key, key), scancode, action, mods);
             }
         },
         GLFWmousebuttonfun => struct {
@@ -325,8 +326,8 @@ pub fn setMouseButtonCallback(self: Self,
 }
 
 /// Return the last reported state of a keyboard key.
-pub fn getKey(self: Self, key: c_int) Error!State {
-    const state = glfwGetKey(self.pimpl, key);
+pub fn getKey(self: Self, key: Key) Error!State {
+    const state = glfwGetKey(self.pimpl, @enumToInt(key));
     try checkError();
     return @intToEnum(State, state);
 }