glfw: glfw.mod.Mods -> glfw.Mods, etc. & fix test compilation
Helps hexops/mach#37 Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
32fa90eca9
commit
ab01edee1c
3 changed files with 37 additions and 37 deletions
|
|
@ -20,7 +20,7 @@ pub const Hat = packed struct {
|
|||
}
|
||||
}
|
||||
|
||||
pub inline fn toInt(comptime IntType: type, self: Hat) IntType {
|
||||
pub inline fn toInt(self: Hat, comptime IntType: type) IntType {
|
||||
verifyIntType(IntType);
|
||||
return @bitCast(IntType, self);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,8 @@ pub const Action = @import("action.zig").Action;
|
|||
pub const GamepadAxis = @import("gamepad_axis.zig").GamepadAxis;
|
||||
pub const GamepadButton = @import("gamepad_button.zig").GamepadButton;
|
||||
pub const GammaRamp = @import("GammaRamp.zig");
|
||||
pub const hat = @import("hat.zig");
|
||||
pub const Image = @import("Image.zig");
|
||||
pub const Joystick = @import("Joystick.zig");
|
||||
pub const mod = @import("mod.zig");
|
||||
pub const Monitor = @import("Monitor.zig");
|
||||
pub const mouse_button = @import("mouse_button.zig");
|
||||
pub const version = @import("version.zig");
|
||||
|
|
@ -29,6 +27,8 @@ pub usingnamespace @import("clipboard.zig");
|
|||
pub usingnamespace @import("opengl.zig");
|
||||
pub usingnamespace @import("vulkan.zig");
|
||||
pub usingnamespace @import("time.zig");
|
||||
pub usingnamespace @import("hat.zig");
|
||||
pub usingnamespace @import("mod.zig");
|
||||
|
||||
/// Initializes the GLFW library.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ pub const Mods = packed struct {
|
|||
}
|
||||
}
|
||||
|
||||
pub inline fn toInt(comptime IntType: type, self: Mods) IntType {
|
||||
pub inline fn toInt(self: Mods, comptime IntType: type) IntType {
|
||||
verifyIntType(IntType);
|
||||
return @bitCast(IntType, self);
|
||||
}
|
||||
|
|
@ -61,12 +61,12 @@ test "shift int to bitmask" {
|
|||
const int_mod = RawMods.shift;
|
||||
const mod = Mods.fromInt(int_mod);
|
||||
|
||||
std.testing.expect(mod.shift == true);
|
||||
std.testing.expect(mod.control == false);
|
||||
std.testing.expect(mod.alt == false);
|
||||
std.testing.expect(mod.super == false);
|
||||
std.testing.expect(mod.caps_lock == false);
|
||||
std.testing.expect(mod.num_lock == false);
|
||||
try std.testing.expect(mod.shift == true);
|
||||
try std.testing.expect(mod.control == false);
|
||||
try std.testing.expect(mod.alt == false);
|
||||
try std.testing.expect(mod.super == false);
|
||||
try std.testing.expect(mod.caps_lock == false);
|
||||
try std.testing.expect(mod.num_lock == false);
|
||||
}
|
||||
|
||||
test "shift int and alt to bitmask" {
|
||||
|
|
@ -75,12 +75,12 @@ test "shift int and alt to bitmask" {
|
|||
const int_mod = RawMods.shift | RawMods.alt;
|
||||
const mod = Mods.fromInt(int_mod);
|
||||
|
||||
std.testing.expect(mod.shift == true);
|
||||
std.testing.expect(mod.control == false);
|
||||
std.testing.expect(mod.alt == true);
|
||||
std.testing.expect(mod.super == false);
|
||||
std.testing.expect(mod.caps_lock == false);
|
||||
std.testing.expect(mod.num_lock == false);
|
||||
try std.testing.expect(mod.shift == true);
|
||||
try std.testing.expect(mod.control == false);
|
||||
try std.testing.expect(mod.alt == true);
|
||||
try std.testing.expect(mod.super == false);
|
||||
try std.testing.expect(mod.caps_lock == false);
|
||||
try std.testing.expect(mod.num_lock == false);
|
||||
}
|
||||
|
||||
test "super int to bitmask" {
|
||||
|
|
@ -89,12 +89,12 @@ test "super int to bitmask" {
|
|||
const int_mod = RawMods.super;
|
||||
const mod = Mods.fromInt(int_mod);
|
||||
|
||||
std.testing.expect(mod.shift == false);
|
||||
std.testing.expect(mod.control == false);
|
||||
std.testing.expect(mod.alt == false);
|
||||
std.testing.expect(mod.super == true);
|
||||
std.testing.expect(mod.caps_lock == false);
|
||||
std.testing.expect(mod.num_lock == false);
|
||||
try std.testing.expect(mod.shift == false);
|
||||
try std.testing.expect(mod.control == false);
|
||||
try std.testing.expect(mod.alt == false);
|
||||
try std.testing.expect(mod.super == true);
|
||||
try std.testing.expect(mod.caps_lock == false);
|
||||
try std.testing.expect(mod.num_lock == false);
|
||||
}
|
||||
|
||||
test "num lock int to bitmask" {
|
||||
|
|
@ -103,12 +103,12 @@ test "num lock int to bitmask" {
|
|||
const int_mod = RawMods.num_lock;
|
||||
const mod = Mods.fromInt(int_mod);
|
||||
|
||||
std.testing.expect(mod.shift == false);
|
||||
std.testing.expect(mod.control == false);
|
||||
std.testing.expect(mod.alt == false);
|
||||
std.testing.expect(mod.super == false);
|
||||
std.testing.expect(mod.caps_lock == false);
|
||||
std.testing.expect(mod.num_lock == true);
|
||||
try std.testing.expect(mod.shift == false);
|
||||
try std.testing.expect(mod.control == false);
|
||||
try std.testing.expect(mod.alt == false);
|
||||
try std.testing.expect(mod.super == false);
|
||||
try std.testing.expect(mod.caps_lock == false);
|
||||
try std.testing.expect(mod.num_lock == true);
|
||||
}
|
||||
|
||||
test "all int to bitmask" {
|
||||
|
|
@ -119,12 +119,12 @@ test "all int to bitmask" {
|
|||
RawMods.caps_lock | RawMods.num_lock;
|
||||
const mod = Mods.fromInt(int_mod);
|
||||
|
||||
std.testing.expect(mod.shift == true);
|
||||
std.testing.expect(mod.control == true);
|
||||
std.testing.expect(mod.alt == true);
|
||||
std.testing.expect(mod.super == true);
|
||||
std.testing.expect(mod.caps_lock == true);
|
||||
std.testing.expect(mod.num_lock == true);
|
||||
try std.testing.expect(mod.shift == true);
|
||||
try std.testing.expect(mod.control == true);
|
||||
try std.testing.expect(mod.alt == true);
|
||||
try std.testing.expect(mod.super == true);
|
||||
try std.testing.expect(mod.caps_lock == true);
|
||||
try std.testing.expect(mod.num_lock == true);
|
||||
}
|
||||
|
||||
test "shift bitmask to int" {
|
||||
|
|
@ -133,7 +133,7 @@ test "shift bitmask to int" {
|
|||
const mod = Mods{ .shift = true };
|
||||
const int_mod = mod.toInt(c_int);
|
||||
|
||||
std.testing.expectEqual(int_mod, RawMods.shift);
|
||||
try std.testing.expectEqual(int_mod, RawMods.shift);
|
||||
}
|
||||
|
||||
test "shift and alt bitmask to int" {
|
||||
|
|
@ -142,7 +142,7 @@ test "shift and alt bitmask to int" {
|
|||
const mod = Mods{ .shift = true, .alt = true };
|
||||
const int_mod = mod.toInt(c_int);
|
||||
|
||||
std.testing.expectEqual(int_mod, RawMods.shift | RawMods.alt);
|
||||
try std.testing.expectEqual(int_mod, RawMods.shift | RawMods.alt);
|
||||
}
|
||||
|
||||
test "all bitmask to int" {
|
||||
|
|
@ -162,5 +162,5 @@ test "all bitmask to int" {
|
|||
RawMods.alt | RawMods.super |
|
||||
RawMods.caps_lock | RawMods.num_lock;
|
||||
|
||||
std.testing.expectEqual(int_mod, expected);
|
||||
try std.testing.expectEqual(int_mod, expected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue