apprt/glfw: builds
parent
a3462dd2bd
commit
24d433333b
|
|
@ -1895,12 +1895,12 @@ pub fn keyCallback(
|
|||
// if we didn't have a previous event and this is a release
|
||||
// event then we just want to set it to null.
|
||||
const prev = self.pressed_key orelse break :event null;
|
||||
if (prev.key == copy.key) copy.key = .invalid;
|
||||
if (prev.key == copy.key) copy.key = .unidentified;
|
||||
}
|
||||
|
||||
// If our key is invalid and we have no mods, then we're done!
|
||||
// This helps catch the state that we naturally released all keys.
|
||||
if (copy.key == .invalid and copy.mods.empty()) break :event null;
|
||||
if (copy.key == .unidentified and copy.mods.empty()) break :event null;
|
||||
|
||||
break :event copy;
|
||||
};
|
||||
|
|
@ -2295,7 +2295,7 @@ pub fn focusCallback(self: *Surface, focused: bool) !void {
|
|||
pressed_key.action = .release;
|
||||
|
||||
// Release the full key first
|
||||
if (pressed_key.key != .invalid) {
|
||||
if (pressed_key.key != .unidentified) {
|
||||
assert(self.keyCallback(pressed_key) catch |err| err: {
|
||||
log.warn("error releasing key on focus loss err={}", .{err});
|
||||
break :err .ignored;
|
||||
|
|
@ -2315,8 +2315,15 @@ pub fn focusCallback(self: *Surface, focused: bool) !void {
|
|||
if (@field(pressed_key.mods, key)) {
|
||||
@field(pressed_key.mods, key) = false;
|
||||
inline for (&.{ "right", "left" }) |side| {
|
||||
const keyname = if (comptime std.mem.eql(u8, key, "ctrl")) "control" else key;
|
||||
pressed_key.key = @field(input.Key, side ++ "_" ++ keyname);
|
||||
const keyname = comptime keyname: {
|
||||
break :keyname if (std.mem.eql(u8, key, "ctrl"))
|
||||
"control"
|
||||
else if (std.mem.eql(u8, key, "super"))
|
||||
"meta"
|
||||
else
|
||||
key;
|
||||
};
|
||||
pressed_key.key = @field(input.Key, keyname ++ "_" ++ side);
|
||||
if (pressed_key.key != original_key) {
|
||||
assert(self.keyCallback(pressed_key) catch |err| err: {
|
||||
log.warn("error releasing key on focus loss err={}", .{err});
|
||||
|
|
|
|||
|
|
@ -966,46 +966,46 @@ pub const Surface = struct {
|
|||
.repeat => .repeat,
|
||||
};
|
||||
const key: input.Key = switch (glfw_key) {
|
||||
.a => .a,
|
||||
.b => .b,
|
||||
.c => .c,
|
||||
.d => .d,
|
||||
.e => .e,
|
||||
.f => .f,
|
||||
.g => .g,
|
||||
.h => .h,
|
||||
.i => .i,
|
||||
.j => .j,
|
||||
.k => .k,
|
||||
.l => .l,
|
||||
.m => .m,
|
||||
.n => .n,
|
||||
.o => .o,
|
||||
.p => .p,
|
||||
.q => .q,
|
||||
.r => .r,
|
||||
.s => .s,
|
||||
.t => .t,
|
||||
.u => .u,
|
||||
.v => .v,
|
||||
.w => .w,
|
||||
.x => .x,
|
||||
.y => .y,
|
||||
.z => .z,
|
||||
.zero => .zero,
|
||||
.one => .one,
|
||||
.two => .two,
|
||||
.three => .three,
|
||||
.four => .four,
|
||||
.five => .five,
|
||||
.six => .six,
|
||||
.seven => .seven,
|
||||
.eight => .eight,
|
||||
.nine => .nine,
|
||||
.up => .up,
|
||||
.down => .down,
|
||||
.right => .right,
|
||||
.left => .left,
|
||||
.a => .key_a,
|
||||
.b => .key_b,
|
||||
.c => .key_c,
|
||||
.d => .key_d,
|
||||
.e => .key_e,
|
||||
.f => .key_f,
|
||||
.g => .key_g,
|
||||
.h => .key_h,
|
||||
.i => .key_i,
|
||||
.j => .key_j,
|
||||
.k => .key_k,
|
||||
.l => .key_l,
|
||||
.m => .key_m,
|
||||
.n => .key_n,
|
||||
.o => .key_o,
|
||||
.p => .key_p,
|
||||
.q => .key_q,
|
||||
.r => .key_r,
|
||||
.s => .key_s,
|
||||
.t => .key_t,
|
||||
.u => .key_u,
|
||||
.v => .key_v,
|
||||
.w => .key_w,
|
||||
.x => .key_x,
|
||||
.y => .key_y,
|
||||
.z => .key_z,
|
||||
.zero => .digit_0,
|
||||
.one => .digit_1,
|
||||
.two => .digit_2,
|
||||
.three => .digit_3,
|
||||
.four => .digit_4,
|
||||
.five => .digit_5,
|
||||
.six => .digit_6,
|
||||
.seven => .digit_7,
|
||||
.eight => .digit_8,
|
||||
.nine => .digit_9,
|
||||
.up => .arrow_up,
|
||||
.down => .arrow_down,
|
||||
.right => .arrow_right,
|
||||
.left => .arrow_left,
|
||||
.home => .home,
|
||||
.end => .end,
|
||||
.page_up => .page_up,
|
||||
|
|
@ -1036,34 +1036,34 @@ pub const Surface = struct {
|
|||
.F23 => .f23,
|
||||
.F24 => .f24,
|
||||
.F25 => .f25,
|
||||
.kp_0 => .kp_0,
|
||||
.kp_1 => .kp_1,
|
||||
.kp_2 => .kp_2,
|
||||
.kp_3 => .kp_3,
|
||||
.kp_4 => .kp_4,
|
||||
.kp_5 => .kp_5,
|
||||
.kp_6 => .kp_6,
|
||||
.kp_7 => .kp_7,
|
||||
.kp_8 => .kp_8,
|
||||
.kp_9 => .kp_9,
|
||||
.kp_decimal => .kp_decimal,
|
||||
.kp_divide => .kp_divide,
|
||||
.kp_multiply => .kp_multiply,
|
||||
.kp_subtract => .kp_subtract,
|
||||
.kp_add => .kp_add,
|
||||
.kp_enter => .kp_enter,
|
||||
.kp_equal => .kp_equal,
|
||||
.grave_accent => .grave_accent,
|
||||
.kp_0 => .numpad_0,
|
||||
.kp_1 => .numpad_1,
|
||||
.kp_2 => .numpad_2,
|
||||
.kp_3 => .numpad_3,
|
||||
.kp_4 => .numpad_4,
|
||||
.kp_5 => .numpad_5,
|
||||
.kp_6 => .numpad_6,
|
||||
.kp_7 => .numpad_7,
|
||||
.kp_8 => .numpad_8,
|
||||
.kp_9 => .numpad_9,
|
||||
.kp_decimal => .numpad_decimal,
|
||||
.kp_divide => .numpad_divide,
|
||||
.kp_multiply => .numpad_multiply,
|
||||
.kp_subtract => .numpad_subtract,
|
||||
.kp_add => .numpad_add,
|
||||
.kp_enter => .numpad_enter,
|
||||
.kp_equal => .numpad_equal,
|
||||
.grave_accent => .backquote,
|
||||
.minus => .minus,
|
||||
.equal => .equal,
|
||||
.space => .space,
|
||||
.semicolon => .semicolon,
|
||||
.apostrophe => .apostrophe,
|
||||
.apostrophe => .quote,
|
||||
.comma => .comma,
|
||||
.period => .period,
|
||||
.slash => .slash,
|
||||
.left_bracket => .left_bracket,
|
||||
.right_bracket => .right_bracket,
|
||||
.left_bracket => .bracket_left,
|
||||
.right_bracket => .bracket_right,
|
||||
.backslash => .backslash,
|
||||
.enter => .enter,
|
||||
.tab => .tab,
|
||||
|
|
@ -1075,20 +1075,20 @@ pub const Surface = struct {
|
|||
.num_lock => .num_lock,
|
||||
.print_screen => .print_screen,
|
||||
.pause => .pause,
|
||||
.left_shift => .left_shift,
|
||||
.left_control => .left_control,
|
||||
.left_alt => .left_alt,
|
||||
.left_super => .left_super,
|
||||
.right_shift => .right_shift,
|
||||
.right_control => .right_control,
|
||||
.right_alt => .right_alt,
|
||||
.right_super => .right_super,
|
||||
.left_shift => .shift_left,
|
||||
.left_control => .control_left,
|
||||
.left_alt => .alt_left,
|
||||
.left_super => .meta_left,
|
||||
.right_shift => .shift_right,
|
||||
.right_control => .control_right,
|
||||
.right_alt => .alt_right,
|
||||
.right_super => .meta_right,
|
||||
.menu => .context_menu,
|
||||
|
||||
.menu,
|
||||
.world_1,
|
||||
.world_2,
|
||||
.unknown,
|
||||
=> .invalid,
|
||||
=> .unidentified,
|
||||
};
|
||||
|
||||
// This is a hack for GLFW. We require our apprts to send both
|
||||
|
|
|
|||
|
|
@ -155,14 +155,12 @@ const ChordBinding = struct {
|
|||
while (l_trigger != null and r_trigger != null) {
|
||||
const lhs_key: c_int = blk: {
|
||||
switch (l_trigger.?.data.key) {
|
||||
.translated => |key| break :blk @intFromEnum(key),
|
||||
.physical => |key| break :blk @intFromEnum(key),
|
||||
.unicode => |key| break :blk @intCast(key),
|
||||
}
|
||||
};
|
||||
const rhs_key: c_int = blk: {
|
||||
switch (r_trigger.?.data.key) {
|
||||
.translated => |key| break :blk @intFromEnum(key),
|
||||
.physical => |key| break :blk @intFromEnum(key),
|
||||
.unicode => |key| break :blk @intCast(key),
|
||||
}
|
||||
|
|
@ -254,8 +252,7 @@ fn prettyPrint(alloc: Allocator, keybinds: Config.Keybinds) !u8 {
|
|||
result = win.printSegment(.{ .text = " + " }, .{ .col_offset = result.col });
|
||||
}
|
||||
const key = switch (trigger.data.key) {
|
||||
.translated => |k| try std.fmt.allocPrint(alloc, "{s}", .{@tagName(k)}),
|
||||
.physical => |k| try std.fmt.allocPrint(alloc, "physical:{s}", .{@tagName(k)}),
|
||||
.physical => |k| try std.fmt.allocPrint(alloc, "{s}", .{@tagName(k)}),
|
||||
.unicode => |c| try std.fmt.allocPrint(alloc, "{u}", .{c}),
|
||||
};
|
||||
result = win.printSegment(.{ .text = key }, .{ .col_offset = result.col });
|
||||
|
|
@ -297,8 +294,7 @@ fn iterateBindings(alloc: Allocator, iter: anytype, win: *const vaxis.Window) !s
|
|||
if (t.mods.shift) try std.fmt.format(buf.writer(), "shift + ", .{});
|
||||
|
||||
switch (t.key) {
|
||||
.translated => |k| try std.fmt.format(buf.writer(), "{s}", .{@tagName(k)}),
|
||||
.physical => |k| try std.fmt.format(buf.writer(), "physical:{s}", .{@tagName(k)}),
|
||||
.physical => |k| try std.fmt.format(buf.writer(), "{s}", .{@tagName(k)}),
|
||||
.unicode => |c| try std.fmt.format(buf.writer(), "{u}", .{c}),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -573,14 +573,14 @@ pub const Key = enum(c_int) {
|
|||
/// True if this key is a modifier.
|
||||
pub fn modifier(self: Key) bool {
|
||||
return switch (self) {
|
||||
.left_shift,
|
||||
.left_control,
|
||||
.left_alt,
|
||||
.left_super,
|
||||
.right_shift,
|
||||
.right_control,
|
||||
.right_alt,
|
||||
.right_super,
|
||||
.shift_left,
|
||||
.control_left,
|
||||
.alt_left,
|
||||
.meta_left,
|
||||
.shift_right,
|
||||
.control_right,
|
||||
.alt_right,
|
||||
.meta_right,
|
||||
=> true,
|
||||
|
||||
else => false,
|
||||
|
|
|
|||
Loading…
Reference in New Issue