glfw: add [set|get]InputModeRawMouseMotion variants
Helps hexops/mach#37 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
9d642c199f
commit
bec6f7a85b
1 changed files with 50 additions and 6 deletions
|
|
@ -1577,11 +1577,26 @@ pub inline fn setInputModeLockKeyMods(self: Window, enabled: bool) Error!void {
|
||||||
return self.setInputMode(InputMode.lock_key_mods, enabled);
|
return self.setInputMode(InputMode.lock_key_mods, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Tells if the the locking key modifiers input mode is enabled.
|
/// Tells if the locking key modifiers input mode is enabled.
|
||||||
pub inline fn getInputModeLockKeyMods(self: Window) bool {
|
pub inline fn getInputModeLockKeyMods(self: Window) bool {
|
||||||
return self.getInputMode(InputMode.lock_key_mods) == 1;
|
return self.getInputMode(InputMode.lock_key_mods) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets whether the raw mouse motion input mode is enabled, if enabled unscaled and unaccelerated
|
||||||
|
/// mouse motion events will be sent, otherwise standard mouse motion events respecting the user's
|
||||||
|
/// OS settings will be sent.
|
||||||
|
///
|
||||||
|
/// If raw motion is not supported, attempting to set this will emit glfw.Error.PlatformError. Call
|
||||||
|
/// glfw.rawMouseMotionSupported to check for support.
|
||||||
|
pub inline fn setInputModeRawMouseMotion(self: Window, enabled: bool) Error!void {
|
||||||
|
return self.setInputMode(InputMode.raw_mouse_motion, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Tells if the raw mouse motion input mode is enabled.
|
||||||
|
pub inline fn getInputModeRawMouseMotion(self: Window) bool {
|
||||||
|
return self.getInputMode(InputMode.raw_mouse_motion) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the value of an input option for the specified window.
|
/// Returns the value of an input option for the specified window.
|
||||||
///
|
///
|
||||||
/// Consider using one of the following variants instead, if applicable, as they'll give you a
|
/// Consider using one of the following variants instead, if applicable, as they'll give you a
|
||||||
|
|
@ -1591,6 +1606,7 @@ pub inline fn getInputModeLockKeyMods(self: Window) bool {
|
||||||
/// * `glfw.Window.getInputModeStickyKeys`
|
/// * `glfw.Window.getInputModeStickyKeys`
|
||||||
/// * `glfw.Window.getInputModeStickyMouseButtons`
|
/// * `glfw.Window.getInputModeStickyMouseButtons`
|
||||||
/// * `glfw.Window.getInputModeLockKeyMods`
|
/// * `glfw.Window.getInputModeLockKeyMods`
|
||||||
|
/// * `glfw.Window.getInputModeRawMouseMotion`
|
||||||
///
|
///
|
||||||
/// This function returns the value of an input option for the specified window. The mode must be
|
/// This function returns the value of an input option for the specified window. The mode must be
|
||||||
/// one of the `glfw.Window.InputMode` enumerations.
|
/// one of the `glfw.Window.InputMode` enumerations.
|
||||||
|
|
@ -1619,11 +1635,7 @@ pub inline fn getInputMode(self: Window, mode: InputMode) isize {
|
||||||
/// * `glfw.Window.setInputModeStickyKeys`
|
/// * `glfw.Window.setInputModeStickyKeys`
|
||||||
/// * `glfw.Window.setInputModeStickyMouseButtons`
|
/// * `glfw.Window.setInputModeStickyMouseButtons`
|
||||||
/// * `glfw.Window.setInputModeLockKeyMods`
|
/// * `glfw.Window.setInputModeLockKeyMods`
|
||||||
///
|
/// * `glfw.Window.setInputModeRawMouseMotion`
|
||||||
/// If the mode is `glfw.raw_mouse_motion`, the value must be either `true` to enable raw (unscaled
|
|
||||||
/// and unaccelerated) mouse motion when the cursor is disabled, or `false` to disable it. If raw
|
|
||||||
/// motion is not supported, attempting to set this will emit glfw.Error.PlatformError. Call
|
|
||||||
/// glfw.rawMouseMotionSupported to check for support.
|
|
||||||
///
|
///
|
||||||
/// @param[in] mode One of the `glfw.Window.InputMode` enumerations.
|
/// @param[in] mode One of the `glfw.Window.InputMode` enumerations.
|
||||||
/// @param[in] value The new value of the specified input mode.
|
/// @param[in] value The new value of the specified input mode.
|
||||||
|
|
@ -2951,6 +2963,38 @@ test "setInputModeLockKeyMods" {
|
||||||
window.setInputModeLockKeyMods(false) catch |err| std.debug.print("failed to set input mode, not supported? error={}\n", .{err});
|
window.setInputModeLockKeyMods(false) catch |err| std.debug.print("failed to set input mode, not supported? error={}\n", .{err});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "getInputModeRawMouseMotion" {
|
||||||
|
const glfw = @import("main.zig");
|
||||||
|
try glfw.init();
|
||||||
|
defer glfw.terminate();
|
||||||
|
|
||||||
|
const window = glfw.Window.create(640, 480, "Hello, Zig!", null, null) catch |err| {
|
||||||
|
// return without fail, because most of our CI environments are headless / we cannot open
|
||||||
|
// windows on them.
|
||||||
|
std.debug.print("note: failed to create window: {}\n", .{err});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
defer window.destroy();
|
||||||
|
|
||||||
|
_ = window.getInputModeRawMouseMotion();
|
||||||
|
}
|
||||||
|
|
||||||
|
test "setInputModeRawMouseMotion" {
|
||||||
|
const glfw = @import("main.zig");
|
||||||
|
try glfw.init();
|
||||||
|
defer glfw.terminate();
|
||||||
|
|
||||||
|
const window = glfw.Window.create(640, 480, "Hello, Zig!", null, null) catch |err| {
|
||||||
|
// return without fail, because most of our CI environments are headless / we cannot open
|
||||||
|
// windows on them.
|
||||||
|
std.debug.print("note: failed to create window: {}\n", .{err});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
defer window.destroy();
|
||||||
|
|
||||||
|
window.setInputModeRawMouseMotion(false) catch |err| std.debug.print("failed to set input mode, not supported? error={}\n", .{err});
|
||||||
|
}
|
||||||
|
|
||||||
test "getInputMode" {
|
test "getInputMode" {
|
||||||
const glfw = @import("main.zig");
|
const glfw = @import("main.zig");
|
||||||
try glfw.init();
|
try glfw.init();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue