diff options
| author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-09-09 22:29:14 +0700 |
|---|---|---|
| committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-09-09 22:29:14 +0700 |
| commit | be76fd8b6e8ce2c4be4a53e0f3e9ced369ad5e66 (patch) | |
| tree | 41e3c30c34f3cd0543de7d900a8a798ed05636fd /src | |
| parent | da9e10dc992d3a389d549e344b17eae4c32d98b0 (diff) | |
| download | gfz-be76fd8b6e8ce2c4be4a53e0f3e9ced369ad5e66.tar.gz | |
Wrap glfw{Get,Set}InputMode
Diffstat (limited to 'src')
| -rw-r--r-- | src/Window.zig | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Window.zig b/src/Window.zig index 748e042..087171f 100644 --- a/src/Window.zig +++ b/src/Window.zig @@ -78,3 +78,43 @@ pub fn swapBuffers(self: Window) Error!void { glfwSwapBuffers(self.pimpl); try checkError(); } + +pub const InputMode = enum(c_int) { + sticky_keys = GLFW_STICKY_KEYS, + sticky_mouse_buttons = GLFW_STICKY_MOUSE_BUTTONS, + lock_key_mods = GLFW_LOCK_KEY_MODS, + raw_mouse_motion = GLFW_RAW_MOUSE_MOTION, +}; + +/// Return the value of an input option. +pub fn getInputMode(self: Window, mode: InputMode) Error!bool { + const value = glfwGetInputMode(self.pimpl, @enumToInt(mode)); + try checkError(); + return value == GLFW_TRUE; +} + +/// Set an input option. +pub fn setInputMode(self: Window, mode: InputMode, flag: bool) Error!void { + const value = if (flag) GLFW_TRUE else GLFW_FALSE; + glfwSetInputMode(self.pimpl, @enumToInt(mode), value); + try checkError(); +} + +pub const CursorMode = enum(c_int) { + normal = GLFW_CURSOR_NORMAL, + hidden = GLFW_CURSOR_HIDDEN, + disabled = GLFW_CURSOR_DISABLED, +}; + +/// Return the cursor mode. +pub fn getCursorMode(self: Window) Error!CursorMode { + const value = glfwGetInputMode(self.pimpl, GLFW_CURSOR); + try checkError(); + return @intToEnum(CursorMode, value); +} + +/// Set the cursor mode. +pub fn setCursorMode(self: Window, value: CursorMode) Error!void { + glfwSetInputMode(self.pimpl, GLFW_CURSOR, @enumToInt(value)); + try checkError(); +} |
