glfw: add glfw.key.getScancode

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2021-10-23 10:35:18 -07:00 committed by Stephen Gutekanst
parent 3e466da662
commit 8df9c19e5b

View file

@ -214,27 +214,23 @@ pub inline fn getName(key: isize, scancode: isize) Error![*c]const u8 {
return name; return name;
} }
// TODO(keyboard scancode) /// Returns the platform-specific scancode of the specified key.
// /// Returns the platform-specific scancode of the specified key. ///
// /// /// This function returns the platform-specific scancode of the specified key.
// /// This function returns the platform-specific scancode of the specified key. ///
// /// /// If the key is `glfw.key.UNKNOWN` or does not exist on the keyboard this method will return `-1`.
// /// If the key is `glfw.key.UNKNOWN` or does not exist on the keyboard this ///
// /// method will return `-1`. /// @param[in] key Any named key (see keys).
// /// /// @return The platform-specific scancode for the key.
// /// @param[in] key Any [named key](@ref keys). ///
// /// @return The platform-specific scancode for the key, or `-1` if an /// Possible errors include glfw.Error.NotInitialized, glfw.Error.InvalidEnum and glfw.Error.PlatformError.
// /// error occurred. ///
// /// /// @thread_safety This function may be called from any thread.
// /// Possible errors include glfw.Error.NotInitialized, glfw.Error.InvalidEnum and glfw.Error.PlatformError. pub inline fn getScancode(key: isize) Error!isize {
// /// const scancode = cc.glfwGetKeyScancode(@intCast(c_int, key));
// /// @thread_safety This function may be called from any thread. try getError();
// /// return scancode;
// /// see also: input_key }
// ///
// ///
// /// @ingroup input
// GLFWAPI int glfwGetKeyScancode(int key);
test "getName" { test "getName" {
const glfw = @import("main.zig"); const glfw = @import("main.zig");
@ -243,3 +239,11 @@ test "getName" {
_ = glfw.key.getName(glfw.key.a, 0) catch |err| std.debug.print("failed to get key name, not supported? error={}\n", .{err}); _ = glfw.key.getName(glfw.key.a, 0) catch |err| std.debug.print("failed to get key name, not supported? error={}\n", .{err});
} }
test "getScancode" {
const glfw = @import("main.zig");
try glfw.init();
defer glfw.terminate();
_ = glfw.key.getScancode(glfw.key.a) catch |err| std.debug.print("failed to get key scancode, not supported? error={}\n", .{err});
}