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