summary refs log tree commit diff
path: root/src/input.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/input.zig')
-rw-r--r--src/input.zig38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/input.zig b/src/input.zig
index ef99038..97ad9b3 100644
--- a/src/input.zig
+++ b/src/input.zig
@@ -17,8 +17,7 @@
 // along with gfz.  If not, see <https://www.gnu.org/licenses/>.
 
 const Int = std.meta.Int;
-const EnumField = TypeInfo.EnumField;
-const TypeInfo = std.builtin.TypeInfo;
+const EnumField = std.builtin.TypeInfo.EnumField;
 const endian = @import("builtin").target.cpu.arch.endian();
 const glfw = @import("cimport.zig");
 const std = @import("std");
@@ -46,7 +45,7 @@ const keys = [_][]const u8{
 };
 
 /// Keyboard key enumeration: https://www.glfw.org/docs/latest/group__keys.html
-pub const Key = @Type(TypeInfo{
+pub const Key = @Type(.{
     .Enum = .{
         .layout = .Auto,
         .tag_type = c_int,
@@ -104,3 +103,36 @@ pub const Mods = packed struct {
         });
     }
 };
+
+usingnamespace glfw;
+
+/// Key action: https://www.glfw.org/docs/latest/input_guide.html#input_key
+// TODO: move inside Key: https://github.com/ziglang/zig/issues/6709
+pub const KeyAction = enum(c_int) {
+    press = GLFW_PRESS,
+    release = GLFW_RELEASE,
+    repeat = GLFW_REPEAT,
+};
+
+/// Mouse buttons: https://www.glfw.org/docs/latest/group__buttons.html
+pub const MouseButton = enum(c_int) {
+    @"1" = GLFW_MOUSE_BUTTON_1,
+    @"2" = GLFW_MOUSE_BUTTON_2,
+    @"3" = GLFW_MOUSE_BUTTON_3,
+    @"4" = GLFW_MOUSE_BUTTON_4,
+    @"5" = GLFW_MOUSE_BUTTON_5,
+    @"6" = GLFW_MOUSE_BUTTON_6,
+    @"7" = GLFW_MOUSE_BUTTON_7,
+    @"8" = GLFW_MOUSE_BUTTON_8,
+
+    pub const left = @intToEnum(MouseButton, GLFW_MOUSE_BUTTON_LEFT);
+    pub const right = @intToEnum(MouseButton, GLFW_MOUSE_BUTTON_RIGHT);
+    pub const middle = @intToEnum(MouseButton, GLFW_MOUSE_BUTTON_MIDDLE);
+
+    /// Mouse button input action:
+    /// https://www.glfw.org/docs/latest/input_guide.html#input_mouse_button
+    pub const Action = enum(c_int) {
+        press = GLFW_PRESS,
+        release = GLFW_RELEASE,
+    };
+};