macOS: build

This commit is contained in:
Mitchell Hashimoto
2025-05-08 10:58:41 -07:00
parent 24d433333b
commit b991d36343
5 changed files with 379 additions and 476 deletions

View File

@@ -104,9 +104,28 @@ typedef enum {
} ghostty_input_action_e; } ghostty_input_action_e;
typedef enum { typedef enum {
GHOSTTY_KEY_INVALID, GHOSTTY_KEY_UNIDENTIFIED,
// a-z // "Writing System Keys" § 3.1.1
GHOSTTY_KEY_BACKQUOTE,
GHOSTTY_KEY_BACKSLASH,
GHOSTTY_KEY_BRACKET_LEFT,
GHOSTTY_KEY_BRACKET_RIGHT,
GHOSTTY_KEY_COMMA,
GHOSTTY_KEY_DIGIT_0,
GHOSTTY_KEY_DIGIT_1,
GHOSTTY_KEY_DIGIT_2,
GHOSTTY_KEY_DIGIT_3,
GHOSTTY_KEY_DIGIT_4,
GHOSTTY_KEY_DIGIT_5,
GHOSTTY_KEY_DIGIT_6,
GHOSTTY_KEY_DIGIT_7,
GHOSTTY_KEY_DIGIT_8,
GHOSTTY_KEY_DIGIT_9,
GHOSTTY_KEY_EQUAL,
GHOSTTY_KEY_INTL_BACKSLASH,
GHOSTTY_KEY_INTL_RO,
GHOSTTY_KEY_INTL_YEN,
GHOSTTY_KEY_A, GHOSTTY_KEY_A,
GHOSTTY_KEY_B, GHOSTTY_KEY_B,
GHOSTTY_KEY_C, GHOSTTY_KEY_C,
@@ -133,56 +152,90 @@ typedef enum {
GHOSTTY_KEY_X, GHOSTTY_KEY_X,
GHOSTTY_KEY_Y, GHOSTTY_KEY_Y,
GHOSTTY_KEY_Z, GHOSTTY_KEY_Z,
// numbers
GHOSTTY_KEY_ZERO,
GHOSTTY_KEY_ONE,
GHOSTTY_KEY_TWO,
GHOSTTY_KEY_THREE,
GHOSTTY_KEY_FOUR,
GHOSTTY_KEY_FIVE,
GHOSTTY_KEY_SIX,
GHOSTTY_KEY_SEVEN,
GHOSTTY_KEY_EIGHT,
GHOSTTY_KEY_NINE,
// puncuation
GHOSTTY_KEY_SEMICOLON,
G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_KEY_RIGHT_SUPER,
} ghostty_input_key_e; } ghostty_input_key_e;
typedef struct { typedef struct {
@@ -265,7 +303,6 @@ typedef struct {
} ghostty_input_key_s; } ghostty_input_key_s;
typedef enum { typedef enum {
GHOSTTY_TRIGGER_TRANSLATED,
GHOSTTY_TRIGGER_PHYSICAL, GHOSTTY_TRIGGER_PHYSICAL,
GHOSTTY_TRIGGER_UNICODE, GHOSTTY_TRIGGER_UNICODE,
} ghostty_input_trigger_tag_e; } ghostty_input_trigger_tag_e;

View File

@@ -5,12 +5,6 @@ import GhosttyKit
extension Ghostty { extension Ghostty {
// MARK: Keyboard Shortcuts // MARK: Keyboard Shortcuts
/// Returns the SwiftUI KeyEquivalent for a given key. Note that not all keys known by
/// Ghostty have a macOS equivalent since macOS doesn't allow all keys as equivalents.
static func keyEquivalent(key: ghostty_input_key_e) -> KeyEquivalent? {
return Self.keyToEquivalent[key]
}
/// Return the key equivalent for the given trigger. /// Return the key equivalent for the given trigger.
/// ///
/// Returns nil if the trigger doesn't have an equivalent KeyboardShortcut. This is possible /// Returns nil if the trigger doesn't have an equivalent KeyboardShortcut. This is possible
@@ -22,16 +16,11 @@ extension Ghostty {
static func keyboardShortcut(for trigger: ghostty_input_trigger_s) -> KeyboardShortcut? { static func keyboardShortcut(for trigger: ghostty_input_trigger_s) -> KeyboardShortcut? {
let key: KeyEquivalent let key: KeyEquivalent
switch (trigger.tag) { switch (trigger.tag) {
case GHOSTTY_TRIGGER_TRANSLATED:
if let v = Ghostty.keyEquivalent(key: trigger.key.translated) {
key = v
} else {
return nil
}
case GHOSTTY_TRIGGER_PHYSICAL: case GHOSTTY_TRIGGER_PHYSICAL:
if let v = Ghostty.keyEquivalent(key: trigger.key.physical) { // Only functional keys can be converted to a KeyboardShortcut. Other physical
key = v // mappings cannot because KeyboardShortcut in Swift is inherently layout-dependent.
if let equiv = Self.keyToEquivalent[trigger.key.physical] {
key = equiv
} else { } else {
return nil return nil
} }
@@ -86,64 +75,11 @@ extension Ghostty {
/// not all ghostty key enum values are represented here because not all of them can be /// not all ghostty key enum values are represented here because not all of them can be
/// mapped to a KeyEquivalent. /// mapped to a KeyEquivalent.
static let keyToEquivalent: [ghostty_input_key_e : KeyEquivalent] = [ static let keyToEquivalent: [ghostty_input_key_e : KeyEquivalent] = [
// 0-9
GHOSTTY_KEY_ZERO: "0",
GHOSTTY_KEY_ONE: "1",
GHOSTTY_KEY_TWO: "2",
GHOSTTY_KEY_THREE: "3",
GHOSTTY_KEY_FOUR: "4",
GHOSTTY_KEY_FIVE: "5",
GHOSTTY_KEY_SIX: "6",
GHOSTTY_KEY_SEVEN: "7",
GHOSTTY_KEY_EIGHT: "8",
GHOSTTY_KEY_NINE: "9",
// a-z
GHOSTTY_KEY_A: "a",
GHOSTTY_KEY_B: "b",
GHOSTTY_KEY_C: "c",
GHOSTTY_KEY_D: "d",
GHOSTTY_KEY_E: "e",
GHOSTTY_KEY_F: "f",
GHOSTTY_KEY_G: "g",
GHOSTTY_KEY_H: "h",
GHOSTTY_KEY_I: "i",
GHOSTTY_KEY_J: "j",
GHOSTTY_KEY_K: "k",
GHOSTTY_KEY_L: "l",
GHOSTTY_KEY_M: "m",
GHOSTTY_KEY_N: "n",
GHOSTTY_KEY_O: "o",
GHOSTTY_KEY_P: "p",
GHOSTTY_KEY_Q: "q",
GHOSTTY_KEY_R: "r",
GHOSTTY_KEY_S: "s",
GHOSTTY_KEY_T: "t",
GHOSTTY_KEY_U: "u",
GHOSTTY_KEY_V: "v",
GHOSTTY_KEY_W: "w",
GHOSTTY_KEY_X: "x",
GHOSTTY_KEY_Y: "y",
GHOSTTY_KEY_Z: "z",
// Symbols
GHOSTTY_KEY_APOSTROPHE: "'",
GHOSTTY_KEY_BACKSLASH: "\\",
GHOSTTY_KEY_COMMA: ",",
GHOSTTY_KEY_EQUAL: "=",
GHOSTTY_KEY_GRAVE_ACCENT: "`",
GHOSTTY_KEY_LEFT_BRACKET: "[",
GHOSTTY_KEY_MINUS: "-",
GHOSTTY_KEY_PERIOD: ".",
GHOSTTY_KEY_RIGHT_BRACKET: "]",
GHOSTTY_KEY_SEMICOLON: ";",
GHOSTTY_KEY_SLASH: "/",
// Function keys // Function keys
GHOSTTY_KEY_UP: .upArrow, GHOSTTY_KEY_ARROW_UP: .upArrow,
GHOSTTY_KEY_DOWN: .downArrow, GHOSTTY_KEY_ARROW_DOWN: .downArrow,
GHOSTTY_KEY_LEFT: .leftArrow, GHOSTTY_KEY_ARROW_LEFT: .leftArrow,
GHOSTTY_KEY_RIGHT: .rightArrow, GHOSTTY_KEY_ARROW_RIGHT: .rightArrow,
GHOSTTY_KEY_HOME: .home, GHOSTTY_KEY_HOME: .home,
GHOSTTY_KEY_END: .end, GHOSTTY_KEY_END: .end,
GHOSTTY_KEY_DELETE: .delete, GHOSTTY_KEY_DELETE: .delete,
@@ -153,104 +89,22 @@ extension Ghostty {
GHOSTTY_KEY_ENTER: .return, GHOSTTY_KEY_ENTER: .return,
GHOSTTY_KEY_TAB: .tab, GHOSTTY_KEY_TAB: .tab,
GHOSTTY_KEY_BACKSPACE: .delete, GHOSTTY_KEY_BACKSPACE: .delete,
] GHOSTTY_KEY_SPACE: .space,
static let asciiToKey: [UInt8 : ghostty_input_key_e] = [
// 0-9
0x30: GHOSTTY_KEY_ZERO,
0x31: GHOSTTY_KEY_ONE,
0x32: GHOSTTY_KEY_TWO,
0x33: GHOSTTY_KEY_THREE,
0x34: GHOSTTY_KEY_FOUR,
0x35: GHOSTTY_KEY_FIVE,
0x36: GHOSTTY_KEY_SIX,
0x37: GHOSTTY_KEY_SEVEN,
0x38: GHOSTTY_KEY_EIGHT,
0x39: GHOSTTY_KEY_NINE,
// A-Z
0x41: GHOSTTY_KEY_A,
0x42: GHOSTTY_KEY_B,
0x43: GHOSTTY_KEY_C,
0x44: GHOSTTY_KEY_D,
0x45: GHOSTTY_KEY_E,
0x46: GHOSTTY_KEY_F,
0x47: GHOSTTY_KEY_G,
0x48: GHOSTTY_KEY_H,
0x49: GHOST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TTY_KEY_MINUS,
0x2E: GHOSTTY_KEY_PERIOD,
0x5D: GHOSTTY_KEY_RIGHT_BRACKET,
0x3B: GHOSTTY_KEY_SEMICOLON,
0x2F: GHOSTTY_KEY_SLASH,
] ]
// Mapping of event keyCode to ghostty input key values. This is cribbed from // Mapping of event keyCode to ghostty input key values. This is cribbed from
// glfw mostly since we started as a glfw-based app way back in the day! // glfw mostly since we started as a glfw-based app way back in the day!
static let keycodeToKey: [UInt16 : ghostty_input_key_e] = [ static let keycodeToKey: [UInt16 : ghostty_input_key_e] = [
0x1D: GHOSTTY_KEY_ZERO, 0x1D: GHOSTTY_KEY_DIGIT_0,
0x12: GHOSTTY_KEY_ONE, 0x12: GHOSTTY_KEY_DIGIT_1,
0x13: GHOSTTY_KEY_TWO, 0x13: GHOSTTY_KEY_DIGIT_2,
0x14: GHOSTTY_KEY_THREE, 0x14: GHOSTTY_KEY_DIGIT_3,
0x15: GHOSTTY_KEY_FOUR, 0x15: GHOSTTY_KEY_DIGIT_4,
0x17: GHOSTTY_KEY_FIVE, 0x17: GHOSTTY_KEY_DIGIT_5,
0x16: GHOSTTY_KEY_SIX, 0x16: GHOSTTY_KEY_DIGIT_6,
0x1A: GHOSTTY_KEY_SEVEN, 0x1A: GHOSTTY_KEY_DIGIT_7,
0x1C: GHOSTTY_KEY_EIGHT, 0x1C: GHOSTTY_KEY_DIGIT_8,
0x19: GHOSTTY_KEY_NINE, 0x19: GHOSTTY_KEY_DIGIT_9,
0x00: GHOSTTY_KEY_A, 0x00: GHOSTTY_KEY_A,
0x0B: GHOSTTY_KEY_B, 0x0B: GHOSTTY_KEY_B,
0x08: GHOSTTY_KEY_C, 0x08: GHOSTTY_KEY_C,
@@ -278,22 +132,22 @@ extension Ghostty {
0x10: GHOSTTY_KEY_Y, 0x10: GHOSTTY_KEY_Y,
0x06: GHOSTTY_KEY_Z, 0x06: GHOSTTY_KEY_Z,
0x27: GHOSTTY_KEY_APOSTROPHE, 0x27: GHOSTTY_KEY_QUOTE,
0x2A: GHOSTTY_KEY_BACKSLASH, 0x2A: GHOSTTY_KEY_BACKSLASH,
0x2B: GHOSTTY_KEY_COMMA, 0x2B: GHOSTTY_KEY_COMMA,
0x18: GHOSTTY_KEY_EQUAL, 0x18: GHOSTTY_KEY_EQUAL,
0x32: GHOSTTY_KEY_GRAVE_ACCENT, 0x32: GHOSTTY_KEY_BACKQUOTE,
0x21: GHOSTTY_KEY_LEFT_BRACKET, 0x21: GHOSTTY_KEY_BRACKET_LEFT,
0x1B: GHOSTTY_KEY_MINUS, 0x1B: GHOSTTY_KEY_MINUS,
0x2F: GHOSTTY_KEY_PERIOD, 0x2F: GHOSTTY_KEY_PERIOD,
0x1E: GHOSTTY_KEY_RIGHT_BRACKET, 0x1E: GHOSTTY_KEY_BRACKET_RIGHT,
0x29: GHOSTTY_KEY_SEMICOLON, 0x29: GHOSTTY_KEY_SEMICOLON,
0x2C: GHOSTTY_KEY_SLASH, 0x2C: GHOSTTY_KEY_SLASH,
0x33: GHOSTTY_KEY_BACKSPACE, 0x33: GHOSTTY_KEY_BACKSPACE,
0x39: GHOSTTY_KEY_CAPS_LOCK, 0x39: GHOSTTY_KEY_CAPS_LOCK,
0x75: GHOSTTY_KEY_DELETE, 0x75: GHOSTTY_KEY_DELETE,
0x7D: GHOSTTY_KEY_DOWN, 0x7D: GHOSTTY_KEY_ARROW_DOWN,
0x77: GHOSTTY_KEY_END, 0x77: GHOSTTY_KEY_END,
0x24: GHOSTTY_KEY_ENTER, 0x24: GHOSTTY_KEY_ENTER,
0x35: GHOSTTY_KEY_ESCAPE, 0x35: GHOSTTY_KEY_ESCAPE,
@@ -319,39 +173,39 @@ extension Ghostty {
0x5A: GHOSTTY_KEY_F20, 0x5A: GHOSTTY_KEY_F20,
0x73: GHOSTTY_KEY_HOME, 0x73: GHOSTTY_KEY_HOME,
0x72: GHOSTTY_KEY_INSERT, 0x72: GHOSTTY_KEY_INSERT,
0x7B: GHOSTTY_KEY_LEFT, 0x7B: GHO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0x56: GHOSTTY_KEY_NUMPAD_4,
0x57: GHOSTTY_KEY_KP_5, 0x57: GHOSTTY_KEY_NUMPAD_5,
0x58: GHOSTTY_KEY_KP_6, 0x58: GHOSTTY_KEY_NUMPAD_6,
0x59: GHOSTTY_KEY_KP_7, 0x59: GHOSTTY_KEY_NUMPAD_7,
0x5B: GHOSTTY_KEY_KP_8, 0x5B: GHOSTTY_KEY_NUMPAD_8,
0x5C: GHOSTTY_KEY_KP_9, 0x5C: GHOSTTY_KEY_NUMPAD_9,
0x45: GHOSTTY_KEY_KP_ADD, 0x45: GHOSTTY_KEY_NUMPAD_ADD,
0x41: GHOSTTY_KEY_KP_DECIMAL, 0x41: GHOSTTY_KEY_NUMPAD_DECIMAL,
0x4B: GHOSTTY_KEY_KP_DIVIDE, 0x4B: GHOSTTY_KEY_NUMPAD_DIVIDE,
0x4C: GHOSTTY_KEY_KP_ENTER, 0x4C: GHOSTTY_KEY_NUMPAD_ENTER,
0x51: GHOSTTY_KEY_KP_EQUAL, 0x51: GHOSTTY_KEY_NUMPAD_EQUAL,
0x43: GHOSTTY_KEY_KP_MULTIPLY, 0x43: GHOSTTY_KEY_NUMPAD_MULTIPLY,
0x4E: GHOSTTY_KEY_KP_SUBTRACT, 0x4E: GHOSTTY_KEY_NUMPAD_SUBTRACT,
]; ];
} }

View File

@@ -92,41 +92,12 @@ pub const App = struct {
// We want to get the physical unmapped key to process keybinds. // We want to get the physical unmapped key to process keybinds.
const physical_key = keycode: for (input.keycodes.entries) |entry| { const physical_key = keycode: for (input.keycodes.entries) |entry| {
if (entry.native == self.keycode) break :keycode entry.key; if (entry.native == self.keycode) break :keycode entry.key;
} else .invalid; } else .unidentified;
// If the resulting text has length 1 then we can take its key
// and attempt to translate it to a key enum and call the key callback.
// If the length is greater than 1 then we're going to call the
// charCallback.
//
// We also only do key translation if this is not a dead key.
const key = if (!self.composing) key: {
// If our physical key is a keypad key, we use that.
if (physical_key.keypad()) break :key physical_key;
// A completed key. If the length of the key is one then we can
// attempt to translate it to a key enum and call the key
// callback. First try plain ASCII.
if (text.len > 0) {
if (input.Key.fromASCII(text[0])) |key| {
break :key key;
}
}
// If the above doesn't work, we use the unmodified value.
if (std.math.cast(u8, unshifted_codepoint)) |ascii| {
if (input.Key.fromASCII(ascii)) |key| {
break :key key;
}
}
break :key physical_key;
} else .invalid;
// Build our final key event // Build our final key event
return .{ return .{
.action = self.action, .action = self.action,
.key = key, .key = physical_key,
.physical_key = physical_key, .physical_key = physical_key,
.mods = self.mods, .mods = self.mods,
.consumed_mods = self.consumed_mods, .consumed_mods = self.consumed_mods,

View File

@@ -270,7 +270,7 @@ pub const Action = enum(c_int) {
/// UTF-8 and are produced by the associated apprt. Ghostty core has /// UTF-8 and are produced by the associated apprt. Ghostty core has
/// no mechanism to map input events to strings without the apprt. /// no mechanism to map input events to strings without the apprt.
/// ///
/// IMPORTANT: Any changes here update include/ghostty.h /// IMPORTANT: Any changes here update include/ghostty.h ghostty_input_key_e
pub const Key = enum(c_int) { pub const Key = enum(c_int) {
unidentified, unidentified,
@@ -618,61 +618,61 @@ pub const Key = enum(c_int) {
/// Returns the cimgui key constant for this key. /// Returns the cimgui key constant for this key.
pub fn imguiKey(self: Key) ?c_uint { pub fn imguiKey(self: Key) ?c_uint {
return switch (self) { return switch (self) {
.a => cimgui.c.ImGuiKey_A, .key_a => cimgui.c.ImGuiKey_A,
.b => cimgui.c.ImGuiKey_B, .key_b => cimgui.c.ImGuiKey_B,
.c => cimgui.c.ImGuiKey_C, .key_c => cimgui.c.ImGuiKey_C,
.d => cimgui.c.ImGuiKey_D, .key_d => cimgui.c.ImGuiKey_D,
.e => cimgui.c.ImGuiKey_E, .key_e => cimgui.c.ImGuiKey_E,
.f => cimgui.c.ImGuiKey_F, .key_f => cimgui.c.ImGuiKey_F,
.g => cimgui.c.ImGuiKey_G, .key_g => cimgui.c.ImGuiKey_G,
.h => cimgui.c.ImGuiKey_H, .key_h => cimgui.c.ImGuiKey_H,
.i => cimgui.c.ImGuiKey_I, .key_i => cimgui.c.ImGuiKey_I,
.j => cimgui.c.ImGuiKey_J, .key_j => cimgui.c.ImGuiKey_J,
.k => cimgui.c.ImGuiKey_K, .key_k => cimgui.c.ImGuiKey_K,
.l => cimgui.c.ImGuiKey_L, .key_l => cimgui.c.ImGuiKey_L,
.m => cimgui.c.ImGuiKey_M, .key_m => cimgui.c.ImGuiKey_M,
.n => cimgui.c.ImGuiKey_N, .key_n => cimgui.c.ImGuiKey_N,
.o => cimgui.c.ImGuiKey_O, .key_o => cimgui.c.ImGuiKey_O,
.p => cimgui.c.ImGuiKey_P, .key_p => cimgui.c.ImGuiKey_P,
.q => cimgui.c.ImGuiKey_Q, .key_q => cimgui.c.ImGuiKey_Q,
.r => cimgui.c.ImGuiKey_R, .key_r => cimgui.c.ImGuiKey_R,
.s => cimgui.c.ImGuiKey_S, .key_s => cimgui.c.ImGuiKey_S,
.t => cimgui.c.ImGuiKey_T, .key_t => cimgui.c.ImGuiKey_T,
.u => cimgui.c.ImGuiKey_U, .key_u => cimgui.c.ImGuiKey_U,
.v => cimgui.c.ImGuiKey_V, .key_v => cimgui.c.ImGuiKey_V,
.w => cimgui.c.ImGuiKey_W, .key_w => cimgui.c.ImGuiKey_W,
.x => cimgui.c.ImGuiKey_X, .key_x => cimgui.c.ImGuiKey_X,
.y => cimgui.c.ImGuiKey_Y, .key_y => cimgui.c.ImGuiKey_Y,
.z => cimgui.c.ImGuiKey_Z, .key_z => cimgui.c.ImGuiKey_Z,
.zero => cimgui.c.ImGuiKey_0, .digit_0 => cimgui.c.ImGuiKey_0,
.one => cimgui.c.ImGuiKey_1, .digit_1 => cimgui.c.ImGuiKey_1,
.two => cimgui.c.ImGuiKey_2, .digit_2 => cimgui.c.ImGuiKey_2,
.three => cimgui.c.ImGuiKey_3, .digit_3 => cimgui.c.ImGuiKey_3,
.four => cimgui.c.ImGuiKey_4, .digit_4 => cimgui.c.ImGuiKey_4,
.five => cimgui.c.ImGuiKey_5, .digit_5 => cimgui.c.ImGuiKey_5,
.six => cimgui.c.ImGuiKey_6, .digit_6 => cimgui.c.ImGuiKey_6,
.seven => cimgui.c.ImGuiKey_7, .digit_7 => cimgui.c.ImGuiKey_7,
.eight => cimgui.c.ImGuiKey_8, .digit_8 => cimgui.c.ImGuiKey_8,
.nine => cimgui.c.ImGuiKey_9, .digit_9 => cimgui.c.ImGuiKey_9,
.semicolon => cimgui.c.ImGuiKey_Semicolon, .semicolon => cimgui.c.ImGuiKey_Semicolon,
.space => cimgui.c.ImGuiKey_Space, .space => cimgui.c.ImGuiKey_Space,
.apostrophe => cimgui.c.ImGuiKey_Apostrophe, .quote => cimgui.c.ImGuiKey_Apostrophe,
.comma => cimgui.c.ImGuiKey_Comma, .comma => cimgui.c.ImGuiKey_Comma,
.grave_accent => cimgui.c.ImGuiKey_GraveAccent, .backquote => cimgui.c.ImGuiKey_GraveAccent,
.period => cimgui.c.ImGuiKey_Period, .period => cimgui.c.ImGuiKey_Period,
.slash => cimgui.c.ImGuiKey_Slash, .slash => cimgui.c.ImGuiKey_Slash,
.minus => cimgui.c.ImGuiKey_Minus, .minus => cimgui.c.ImGuiKey_Minus,
.equal => cimgui.c.ImGuiKey_Equal, .equal => cimgui.c.ImGuiKey_Equal,
.left_bracket => cimgui.c.ImGuiKey_LeftBracket, .bracket_left => cimgui.c.ImGuiKey_LeftBracket,
.right_bracket => cimgui.c.ImGuiKey_RightBracket, .bracket_right => cimgui.c.ImGuiKey_RightBracket,
.backslash => cimgui.c.ImGuiKey_Backslash, .backslash => cimgui.c.ImGuiKey_Backslash,
.up => cimgui.c.ImGuiKey_UpArrow, .arrow_up => cimgui.c.ImGuiKey_UpArrow,
.down => cimgui.c.ImGuiKey_DownArrow, .arrow_down => cimgui.c.ImGuiKey_DownArrow,
.left => cimgui.c.ImGuiKey_LeftArrow, .arrow_left => cimgui.c.ImGuiKey_LeftArrow,
.right => cimgui.c.ImGuiKey_RightArrow, .arrow_right => cimgui.c.ImGuiKey_RightArrow,
.home => cimgui.c.ImGuiKey_Home, .home => cimgui.c.ImGuiKey_Home,
.end => cimgui.c.ImGuiKey_End, .end => cimgui.c.ImGuiKey_End,
.insert => cimgui.c.ImGuiKey_Insert, .insert => cimgui.c.ImGuiKey_Insert,
@@ -703,48 +703,47 @@ pub const Key = enum(c_int) {
.f11 => cimgui.c.ImGuiKey_F11, .f11 => cimgui.c.ImGuiKey_F11,
.f12 => cimgui.c.ImGuiKey_F12, .f12 => cimgui.c.ImGuiKey_F12,
.kp_0 => cimgui.c.ImGuiKey_Keypad0, .numpad_0 => cimgui.c.ImGuiKey_Keypad0,
.kp_1 => cimgui.c.ImGuiKey_Keypad1, .numpad_1 => cimgui.c.ImGuiKey_Keypad1,
.kp_2 => cimgui.c.ImGuiKey_Keypad2, .numpad_2 => cimgui.c.ImGuiKey_Keypad2,
.kp_3 => cimgui.c.ImGuiKey_Keypad3, .numpad_3 => cimgui.c.ImGuiKey_Keypad3,
.kp_4 => cimgui.c.ImGuiKey_Keypad4, .numpad_4 => cimgui.c.ImGuiKey_Keypad4,
.kp_5 => cimgui.c.ImGuiKey_Keypad5, .numpad_5 => cimgui.c.ImGuiKey_Keypad5,
.kp_6 => cimgui.c.ImGuiKey_Keypad6, .numpad_6 => cimgui.c.ImGuiKey_Keypad6,
.kp_7 => cimgui.c.ImGuiKey_Keypad7, .numpad_7 => cimgui.c.ImGuiKey_Keypad7,
.kp_8 => cimgui.c.ImGuiKey_Keypad8, .numpad_8 => cimgui.c.ImGuiKey_Keypad8,
.kp_9 => cimgui.c.ImGuiKey_Keypad9, .numpad_9 => cimgui.c.ImGuiKey_Keypad9,
.kp_decimal => cimgui.c.ImGuiKey_KeypadDecimal, .numpad_decimal => cimgui.c.ImGuiKey_KeypadDecimal,
.kp_divide => cimgui.c.ImGuiKey_KeypadDivide, .numpad_divide => cimgui.c.ImGuiKey_KeypadDivide,
.kp_multiply => cimgui.c.ImGuiKey_KeypadMultiply, .numpad_multiply => cimgui.c.ImGuiKey_KeypadMultiply,
.kp_subtract => cimgui.c.ImGuiKey_KeypadSubtract, .numpad_subtract => cimgui.c.ImGuiKey_KeypadSubtract,
.kp_add => cimgui.c.ImGuiKey_KeypadAdd, .numpad_add => cimgui.c.ImGuiKey_KeypadAdd,
.kp_enter => cimgui.c.ImGuiKey_KeypadEnter, .numpad_enter => cimgui.c.ImGuiKey_KeypadEnter,
.kp_equal => cimgui.c.ImGuiKey_KeypadEqual, .numpad_equal => cimgui.c.ImGuiKey_KeypadEqual,
// We map KP_SEPARATOR to Comma because traditionally a numpad would // We map KP_SEPARATOR to Comma because traditionally a numpad would
// have a numeric separator key. Most modern numpads do not // have a numeric separator key. Most modern numpads do not
.kp_separator => cimgui.c.ImGuiKey_Comma, .numpad_left => cimgui.c.ImGuiKey_LeftArrow,
.kp_left => cimgui.c.ImGuiKey_LeftArrow, .numpad_right => cimgui.c.ImGuiKey_RightArrow,
.kp_right => cimgui.c.ImGuiKey_RightArrow, .numpad_up => cimgui.c.ImGuiKey_UpArrow,
.kp_up => cimgui.c.ImGuiKey_UpArrow, .numpad_down => cimgui.c.ImGuiKey_DownArrow,
.kp_down => cimgui.c.ImGuiKey_DownArrow, .numpad_page_up => cimgui.c.ImGuiKey_PageUp,
.kp_page_up => cimgui.c.ImGuiKey_PageUp, .numpad_page_down => cimgui.c.ImGuiKey_PageUp,
.kp_page_down => cimgui.c.ImGuiKey_PageUp, .numpad_home => cimgui.c.ImGuiKey_Home,
.kp_home => cimgui.c.ImGuiKey_Home, .numpad_end => cimgui.c.ImGuiKey_End,
.kp_end => cimgui.c.ImGuiKey_End, .numpad_insert => cimgui.c.ImGuiKey_Insert,
.kp_insert => cimgui.c.ImGuiKey_Insert, .numpad_delete => cimgui.c.ImGuiKey_Delete,
.kp_delete => cimgui.c.ImGuiKey_Delete, .numpad_begin => cimgui.c.ImGuiKey_NamedKey_BEGIN,
.kp_begin => cimgui.c.ImGuiKey_NamedKey_BEGIN,
.left_shift => cimgui.c.ImGuiKey_LeftShift, .shift_left => cimgui.c.ImGuiKey_LeftShift,
.left_control => cimgui.c.ImGuiKey_LeftCtrl, .control_left => cimgui.c.ImGuiKey_LeftCtrl,
.left_alt => cimgui.c.ImGuiKey_LeftAlt, .alt_left => cimgui.c.ImGuiKey_LeftAlt,
.left_super => cimgui.c.ImGuiKey_LeftSuper, .meta_left => cimgui.c.ImGuiKey_LeftSuper,
.right_shift => cimgui.c.ImGuiKey_RightShift, .shift_right => cimgui.c.ImGuiKey_RightShift,
.right_control => cimgui.c.ImGuiKey_RightCtrl, .control_right => cimgui.c.ImGuiKey_RightCtrl,
.right_alt => cimgui.c.ImGuiKey_RightAlt, .alt_right => cimgui.c.ImGuiKey_RightAlt,
.right_super => cimgui.c.ImGuiKey_RightSuper, .meta_right => cimgui.c.ImGuiKey_RightSuper,
.invalid, // These keys aren't represented in cimgui
.f13, .f13,
.f14, .f14,
.f15, .f15,
@@ -758,9 +757,51 @@ pub const Key = enum(c_int) {
.f23, .f23,
.f24, .f24,
.f25, .f25,
.intl_backslash,
.intl_ro,
.intl_yen,
.convert,
.kana_mode,
.non_convert,
.numpad_backspace,
.numpad_clear,
.numpad_clear_entry,
.numpad_comma,
.numpad_memory_add,
.numpad_memory_clear,
.numpad_memory_recall,
.numpad_memory_store,
.numpad_memory_subtract,
.numpad_paren_left,
.numpad_paren_right,
.@"fn",
.fn_lock,
.browser_back,
.browser_favorites,
.browser_forward,
.browser_home,
.browser_refresh,
.browser_search,
.browser_stop,
.eject,
.launch_app_1,
.launch_app_2,
.launch_mail,
.media_play_pause,
.media_select,
.media_stop,
.media_track_next,
.media_track_previous,
.power,
.sleep,
.audio_volume_down,
.audio_volume_mute,
.audio_volume_up,
.wake_up,
.help,
=> null,
// These keys aren't represented in cimgui .unidentified,
.plus,
=> null, => null,
}; };
} }

View File

@@ -19,7 +19,7 @@ pub const entries: []const Entry = entries: {
for (raw_entries, 0..) |raw, i| { for (raw_entries, 0..) |raw, i| {
@setEvalBranchQuota(10000); @setEvalBranchQuota(10000);
result[i] = .{ result[i] = .{
.key = code_to_key.get(raw[5]) orelse .invalid, .key = code_to_key.get(raw[5]) orelse .unidentified,
.usb = raw[0], .usb = raw[0],
.code = raw[5], .code = raw[5],
.native = raw[native_idx], .native = raw[native_idx],
@@ -45,42 +45,42 @@ pub const Entry = struct {
const code_to_key = code_to_key: { const code_to_key = code_to_key: {
@setEvalBranchQuota(5000); @setEvalBranchQuota(5000);
break :code_to_key std.StaticStringMap(Key).initComptime(.{ break :code_to_key std.StaticStringMap(Key).initComptime(.{
.{ "KeyA", .a }, .{ "KeyA", .key_a },
.{ "KeyB", .b }, .{ "KeyB", .key_b },
.{ "KeyC", .c }, .{ "KeyC", .key_c },
.{ "KeyD", .d }, .{ "KeyD", .key_d },
.{ "KeyE", .e }, .{ "KeyE", .key_e },
.{ "KeyF", .f }, .{ "KeyF", .key_f },
.{ "KeyG", .g }, .{ "KeyG", .key_g },
.{ "KeyH", .h }, .{ "KeyH", .key_h },
.{ "KeyI", .i }, .{ "KeyI", .key_i },
.{ "KeyJ", .j }, .{ "KeyJ", .key_j },
.{ "KeyK", .k }, .{ "KeyK", .key_k },
.{ "KeyL", .l }, .{ "KeyL", .key_l },
.{ "KeyM", .m }, .{ "KeyM", .key_m },
.{ "KeyN", .n }, .{ "KeyN", .key_n },
.{ "KeyO", .o }, .{ "KeyO", .key_o },
.{ "KeyP", .p }, .{ "KeyP", .key_p },
.{ "KeyQ", .q }, .{ "KeyQ", .key_q },
.{ "KeyR", .r }, .{ "KeyR", .key_r },
.{ "KeyS", .s }, .{ "KeyS", .key_s },
.{ "KeyT", .t }, .{ "KeyT", .key_t },
.{ "KeyU", .u }, .{ "KeyU", .key_u },
.{ "KeyV", .v }, .{ "KeyV", .key_v },
.{ "KeyW", .w }, .{ "KeyW", .key_w },
.{ "KeyX", .x }, .{ "KeyX", .key_x },
.{ "KeyY", .y }, .{ "KeyY", .key_y },
.{ "KeyZ", .z }, .{ "KeyZ", .key_z },
.{ "Digit1", .one }, .{ "Digit1", .digit_1 },
.{ "Digit2", .two }, .{ "Digit2", .digit_2 },
.{ "Digit3", .three }, .{ "Digit3", .digit_3 },
.{ "Digit4", .four }, .{ "Digit4", .digit_4 },
.{ "Digit5", .five }, .{ "Digit5", .digit_5 },
.{ "Digit6", .six }, .{ "Digit6", .digit_6 },
.{ "Digit7", .seven }, .{ "Digit7", .digit_7 },
.{ "Digit8", .eight }, .{ "Digit8", .digit_8 },
.{ "Digit9", .nine }, .{ "Digit9", .digit_9 },
.{ "Digit0", .zero }, .{ "Digit0", .digit_0 },
.{ "Enter", .enter }, .{ "Enter", .enter },
.{ "Escape", .escape }, .{ "Escape", .escape },
.{ "Backspace", .backspace }, .{ "Backspace", .backspace },
@@ -88,12 +88,12 @@ const code_to_key = code_to_key: {
.{ "Space", .space }, .{ "Space", .space },
.{ "Minus", .minus }, .{ "Minus", .minus },
.{ "Equal", .equal }, .{ "Equal", .equal },
.{ "BracketLeft", .left_bracket }, .{ "BracketLeft", .bracket_left },
.{ "BracketRight", .right_bracket }, .{ "BracketRight", .bracket_left },
.{ "Backslash", .backslash }, .{ "Backslash", .backslash },
.{ "Semicolon", .semicolon }, .{ "Semicolon", .semicolon },
.{ "Quote", .apostrophe }, .{ "Quote", .quote },
.{ "Backquote", .grave_accent }, .{ "Backquote", .backquote },
.{ "Comma", .comma }, .{ "Comma", .comma },
.{ "Period", .period }, .{ "Period", .period },
.{ "Slash", .slash }, .{ "Slash", .slash },
@@ -131,37 +131,37 @@ const code_to_key = code_to_key: {
.{ "Delete", .delete }, .{ "Delete", .delete },
.{ "End", .end }, .{ "End", .end },
.{ "PageDown", .page_down }, .{ "PageDown", .page_down },
.{ "ArrowRight", .right }, .{ "ArrowRight", .arrow_right },
.{ "ArrowLeft", .left }, .{ "ArrowLeft", .arrow_left },
.{ "ArrowDown", .down }, .{ "ArrowDown", .arrow_down },
.{ "ArrowUp", .up }, .{ "ArrowUp", .arrow_up },
.{ "NumLock", .num_lock }, .{ "NumLock", .num_lock },
.{ "NumpadDivide", .kp_divide }, .{ "NumpadDivide", .numpad_divide },
.{ "NumpadMultiply", .kp_multiply }, .{ "NumpadMultiply", .numpad_multiply },
.{ "NumpadSubtract", .kp_subtract }, .{ "NumpadSubtract", .numpad_subtract },
.{ "NumpadAdd", .kp_add }, .{ "NumpadAdd", .numpad_add },
.{ "NumpadEnter", .kp_enter }, .{ "NumpadEnter", .numpad_enter },
.{ "Numpad1", .kp_1 }, .{ "Numpad1", .numpad_1 },
.{ "Numpad2", .kp_2 }, .{ "Numpad2", .numpad_2 },
.{ "Numpad3", .kp_3 }, .{ "Numpad3", .numpad_3 },
.{ "Numpad4", .kp_4 }, .{ "Numpad4", .numpad_4 },
.{ "Numpad5", .kp_5 }, .{ "Numpad5", .numpad_5 },
.{ "Numpad6", .kp_6 }, .{ "Numpad6", .numpad_6 },
.{ "Numpad7", .kp_7 }, .{ "Numpad7", .numpad_7 },
.{ "Numpad8", .kp_8 }, .{ "Numpad8", .numpad_8 },
.{ "Numpad9", .kp_9 }, .{ "Numpad9", .numpad_9 },
.{ "Numpad0", .kp_0 }, .{ "Numpad0", .numpad_0 },
.{ "NumpadDecimal", .kp_decimal }, .{ "NumpadDecimal", .numpad_decimal },
.{ "NumpadEqual", .kp_equal }, .{ "NumpadEqual", .numpad_equal },
.{ "ContextMenu", .context_menu }, .{ "ContextMenu", .context_menu },
.{ "ControlLeft", .left_control }, .{ "ControlLeft", .control_left },
.{ "ShiftLeft", .left_shift }, .{ "ShiftLeft", .shift_left },
.{ "AltLeft", .left_alt }, .{ "AltLeft", .alt_left },
.{ "MetaLeft", .left_super }, .{ "MetaLeft", .meta_left },
.{ "ControlRight", .right_control }, .{ "ControlRight", .control_right },
.{ "ShiftRight", .right_shift }, .{ "ShiftRight", .shift_right },
.{ "AltRight", .right_alt }, .{ "AltRight", .alt_right },
.{ "MetaRight", .right_super }, .{ "MetaRight", .meta_right },
}); });
}; };