input: remove `physical_key` from the key event (all keys are physical)

pull/7320/head
Mitchell Hashimoto 2025-05-08 20:53:09 -07:00
parent 11a623aa17
commit 5962696c3b
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
8 changed files with 6 additions and 21 deletions

View File

@ -1870,7 +1870,7 @@ pub fn keyCallback(
// Process the cursor state logic. This will update the cursor shape if // Process the cursor state logic. This will update the cursor shape if
// needed, depending on the key state. // needed, depending on the key state.
if ((SurfaceMouse{ if ((SurfaceMouse{
.physical_key = event.physical_key, .physical_key = event.key,
.mouse_event = self.io.terminal.flags.mouse_event, .mouse_event = self.io.terminal.flags.mouse_event,
.mouse_shape = self.io.terminal.mouse_shape, .mouse_shape = self.io.terminal.mouse_shape,
.mods = self.mouse.mods, .mods = self.mouse.mods,

View File

@ -98,7 +98,6 @@ pub const App = struct {
return .{ return .{
.action = self.action, .action = self.action,
.key = physical_key, .key = physical_key,
.physical_key = physical_key,
.mods = self.mods, .mods = self.mods,
.consumed_mods = self.consumed_mods, .consumed_mods = self.consumed_mods,
.composing = self.composing, .composing = self.composing,

View File

@ -1108,7 +1108,6 @@ pub const Surface = struct {
const key_event: input.KeyEvent = .{ const key_event: input.KeyEvent = .{
.action = action, .action = action,
.key = key, .key = key,
.physical_key = key,
.mods = mods, .mods = mods,
.consumed_mods = .{}, .consumed_mods = .{},
.composing = false, .composing = false,

View File

@ -1891,7 +1891,6 @@ pub fn keyEvent(
const effect = self.core_surface.keyCallback(.{ const effect = self.core_surface.keyCallback(.{
.action = action, .action = action,
.key = physical_key, .key = physical_key,
.physical_key = physical_key,
.mods = mods, .mods = mods,
.consumed_mods = consumed_mods, .consumed_mods = consumed_mods,
.composing = self.im_composing, .composing = self.im_composing,
@ -2043,7 +2042,6 @@ fn gtkInputCommit(
_ = self.core_surface.keyCallback(.{ _ = self.core_surface.keyCallback(.{
.action = .press, .action = .press,
.key = .unidentified, .key = .unidentified,
.physical_key = .unidentified,
.mods = .{}, .mods = .{},
.consumed_mods = .{}, .consumed_mods = .{},
.composing = false, .composing = false,

View File

@ -1731,7 +1731,7 @@ pub const Set = struct {
pub fn getEvent(self: *const Set, event: KeyEvent) ?Entry { pub fn getEvent(self: *const Set, event: KeyEvent) ?Entry {
var trigger: Trigger = .{ var trigger: Trigger = .{
.mods = event.mods.binding(), .mods = event.mods.binding(),
.key = .{ .physical = event.physical_key }, .key = .{ .physical = event.key },
}; };
if (self.get(trigger)) |v| return v; if (self.get(trigger)) |v| return v;

View File

@ -2190,7 +2190,6 @@ test "legacy: hu layout ctrl+ő sends proper codepoint" {
var enc: KeyEncoder = .{ var enc: KeyEncoder = .{
.event = .{ .event = .{
.key = .bracket_left, .key = .bracket_left,
.physical_key = .bracket_left,
.mods = .{ .ctrl = true }, .mods = .{ .ctrl = true },
.utf8 = "ő", .utf8 = "ő",
.unshifted_codepoint = 337, .unshifted_codepoint = 337,

View File

@ -16,12 +16,10 @@ pub const KeyEvent = struct {
/// The action: press, release, etc. /// The action: press, release, etc.
action: Action = .press, action: Action = .press,
/// "key" is the logical key that was pressed. For example, if /// The keycode of the physical key that was pressed. This is agnostic
/// a Dvorak keyboard layout is being used on a US keyboard, /// to the layout. Layout-dependent matching can only be done via the
/// the "i" physical key will be reported as "c". The physical /// UTF-8 or unshifted codepoint.
/// key is the key that was physically pressed on the keyboard. key: Key = .unidentified,
key: Key,
physical_key: Key = .unidentified,
/// Mods are the modifiers that are pressed. /// Mods are the modifiers that are pressed.
mods: Mods = .{}, mods: Mods = .{},
@ -63,7 +61,6 @@ pub const KeyEvent = struct {
// These are all the fields that are explicitly part of Trigger. // These are all the fields that are explicitly part of Trigger.
std.hash.autoHash(&hasher, self.key); std.hash.autoHash(&hasher, self.key);
std.hash.autoHash(&hasher, self.physical_key);
std.hash.autoHash(&hasher, self.unshifted_codepoint); std.hash.autoHash(&hasher, self.unshifted_codepoint);
std.hash.autoHash(&hasher, self.mods.binding()); std.hash.autoHash(&hasher, self.mods.binding());

View File

@ -117,13 +117,6 @@ pub const Event = struct {
_ = cimgui.c.igTableSetColumnIndex(1); _ = cimgui.c.igTableSetColumnIndex(1);
cimgui.c.igText("%s", @tagName(self.event.key).ptr); cimgui.c.igText("%s", @tagName(self.event.key).ptr);
} }
if (self.event.physical_key != self.event.key) {
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
_ = cimgui.c.igTableSetColumnIndex(0);
cimgui.c.igText("Physical Key");
_ = cimgui.c.igTableSetColumnIndex(1);
cimgui.c.igText("%s", @tagName(self.event.physical_key).ptr);
}
if (!self.event.mods.empty()) { if (!self.event.mods.empty()) {
cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0); cimgui.c.igTableNextRow(cimgui.c.ImGuiTableRowFlags_None, 0);
_ = cimgui.c.igTableSetColumnIndex(0); _ = cimgui.c.igTableSetColumnIndex(0);