From b63a0c0c0d227c79ea84d7023f18fbf735be9062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Sat, 11 Sep 2021 16:09:24 +0700 Subject: Wrap some more input handling --- src/Window.zig | 12 ++++++++++++ src/gfz.zig | 8 ++++++++ 2 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/Window.zig b/src/Window.zig index 087171f..307faf8 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -74,6 +74,12 @@ pub fn shouldClose(self: Window) Error!bool { return flag == GLFW_TRUE; } +/// Set the close flag. +pub fn setShouldClose(self: Window, value: bool) Error!void { + glfwSetWindowShouldClose(self.pimpl, if (value) GLFW_TRUE else GLFW_FALSE); + try checkError(); +} + pub fn swapBuffers(self: Window) Error!void { glfwSwapBuffers(self.pimpl); try checkError(); @@ -118,3 +124,9 @@ pub fn setCursorMode(self: Window, value: CursorMode) Error!void { glfwSetInputMode(self.pimpl, GLFW_CURSOR, @enumToInt(value)); try checkError(); } + +/// Set the key callback. +pub fn setKeyCallback(self: Window, callback: GLFWkeyfun) Error!void { + _ = glfwSetKeyCallback(self.pimpl, callback); + try checkError(); +} diff --git a/src/gfz.zig b/src/gfz.zig index 53e4aaa..46bd247 100644 --- a/src/gfz.zig +++ b/src/gfz.zig @@ -98,11 +98,19 @@ pub fn deinit() Error!void { try checkError(); } +/// Process all pending events. pub fn pollEvents() Error!void { glfwPollEvents(); try checkError(); } +/// Return whether raw mouse motion is supported. +pub fn rawMouseMotionSupported() Error!bool { + const result = glfwRawMouseMotionSupported(); + try checkError(); + return result == GLFW_TRUE; +} + pub const Window = @import("Window.zig"); test { -- cgit v1.2.3