From f6f758859a093910069135621ada1e695d3c8fb8 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 30 Oct 2021 13:50:43 -0700 Subject: [PATCH] glfw: make setMouseButtonCallback use Mods bitmask directly Helps hexops/mach#37 Signed-off-by: Stephen Gutekanst --- glfw/src/Window.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/glfw/src/Window.zig b/glfw/src/Window.zig index 333b5ee1..8afe463d 100644 --- a/glfw/src/Window.zig +++ b/glfw/src/Window.zig @@ -51,7 +51,7 @@ pub const InternalUserPointer = struct { setContentScaleCallback: ?fn (window: Window, xscale: f32, yscale: f32) void, setKeyCallback: ?fn (window: Window, key: isize, scancode: isize, action: Action, mods: Mods) void, setCharCallback: ?fn (window: Window, codepoint: u21) void, - setMouseButtonCallback: ?fn (window: Window, button: isize, action: Action, mods: isize) void, + setMouseButtonCallback: ?fn (window: Window, button: isize, action: Action, mods: Mods) void, setCursorPosCallback: ?fn (window: Window, xpos: f64, ypos: f64) void, setCursorEnterCallback: ?fn (window: Window, entered: bool) void, setScrollCallback: ?fn (window: Window, xoffset: f64, yoffset: f64) void, @@ -1617,7 +1617,7 @@ pub inline fn setCharCallback(self: Window, callback: ?fn (window: Window, codep fn setMouseButtonCallbackWrapper(handle: ?*c.GLFWwindow, button: c_int, action: c_int, mods: c_int) callconv(.C) void { const window = from(handle.?) catch unreachable; const internal = window.getInternal(); - internal.setMouseButtonCallback.?(window, @intCast(isize, button), @intToEnum(Action, action), @intCast(isize, mods)); + internal.setMouseButtonCallback.?(window, @intCast(isize, button), @intToEnum(Action, action), Mods.fromInt(mods)); } /// Sets the mouse button callback. @@ -1642,7 +1642,7 @@ fn setMouseButtonCallbackWrapper(handle: ?*c.GLFWwindow, button: c_int, action: /// @thread_safety This function must only be called from the main thread. /// /// see also: input_mouse_button -pub inline fn setMouseButtonCallback(self: Window, callback: ?fn (window: Window, button: isize, action: Action, mods: isize) void) void { +pub inline fn setMouseButtonCallback(self: Window, callback: ?fn (window: Window, button: isize, action: Action, mods: Mods) void) void { var internal = self.getInternal(); internal.setMouseButtonCallback = callback; _ = c.glfwSetMouseButtonCallback(self.handle, if (callback != null) setMouseButtonCallbackWrapper else null); @@ -2742,7 +2742,7 @@ test "setMouseButtonCallback" { defer window.destroy(); window.setMouseButtonCallback((struct { - fn callback(_window: Window, button: isize, action: Action, mods: isize) void { + fn callback(_window: Window, button: isize, action: Action, mods: Mods) void { _ = _window; _ = button; _ = action;