mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: send the left/right status of modifier keys
This commit is contained in:
@ -83,6 +83,10 @@ typedef enum {
|
|||||||
GHOSTTY_MODS_SUPER = 1 << 3,
|
GHOSTTY_MODS_SUPER = 1 << 3,
|
||||||
GHOSTTY_MODS_CAPS = 1 << 4,
|
GHOSTTY_MODS_CAPS = 1 << 4,
|
||||||
GHOSTTY_MODS_NUM = 1 << 5,
|
GHOSTTY_MODS_NUM = 1 << 5,
|
||||||
|
GHOSTTY_MODS_SHIFT_RIGHT = 1 << 6,
|
||||||
|
GHOSTTY_MODS_CTRL_RIGHT = 1 << 7,
|
||||||
|
GHOSTTY_MODS_ALT_RIGHT = 1 << 8,
|
||||||
|
GHOSTTY_MODS_SUPER_RIGHT = 1 << 9,
|
||||||
} ghostty_input_mods_e;
|
} ghostty_input_mods_e;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -480,12 +480,21 @@ extension Ghostty {
|
|||||||
|
|
||||||
private static func translateFlags(_ flags: NSEvent.ModifierFlags) -> ghostty_input_mods_e {
|
private static func translateFlags(_ flags: NSEvent.ModifierFlags) -> ghostty_input_mods_e {
|
||||||
var mods: UInt32 = GHOSTTY_MODS_NONE.rawValue
|
var mods: UInt32 = GHOSTTY_MODS_NONE.rawValue
|
||||||
|
|
||||||
if (flags.contains(.shift)) { mods |= GHOSTTY_MODS_SHIFT.rawValue }
|
if (flags.contains(.shift)) { mods |= GHOSTTY_MODS_SHIFT.rawValue }
|
||||||
if (flags.contains(.control)) { mods |= GHOSTTY_MODS_CTRL.rawValue }
|
if (flags.contains(.control)) { mods |= GHOSTTY_MODS_CTRL.rawValue }
|
||||||
if (flags.contains(.option)) { mods |= GHOSTTY_MODS_ALT.rawValue }
|
if (flags.contains(.option)) { mods |= GHOSTTY_MODS_ALT.rawValue }
|
||||||
if (flags.contains(.command)) { mods |= GHOSTTY_MODS_SUPER.rawValue }
|
if (flags.contains(.command)) { mods |= GHOSTTY_MODS_SUPER.rawValue }
|
||||||
if (flags.contains(.capsLock)) { mods |= GHOSTTY_MODS_CAPS.rawValue }
|
if (flags.contains(.capsLock)) { mods |= GHOSTTY_MODS_CAPS.rawValue }
|
||||||
|
|
||||||
|
// Handle sided input. We can't tell that both are pressed in the
|
||||||
|
// Ghostty structure but thats okay -- we don't use that information.
|
||||||
|
let rawFlags = flags.rawValue
|
||||||
|
if (rawFlags & UInt(NX_DEVICERSHIFTKEYMASK) != 0) { mods |= GHOSTTY_MODS_SHIFT_RIGHT.rawValue }
|
||||||
|
if (rawFlags & UInt(NX_DEVICERCTLKEYMASK) != 0) { mods |= GHOSTTY_MODS_CTRL_RIGHT.rawValue }
|
||||||
|
if (rawFlags & UInt(NX_DEVICERALTKEYMASK) != 0) { mods |= GHOSTTY_MODS_ALT_RIGHT.rawValue }
|
||||||
|
if (rawFlags & UInt(NX_DEVICERCMDKEYMASK) != 0) { mods |= GHOSTTY_MODS_SUPER_RIGHT.rawValue }
|
||||||
|
|
||||||
return ghostty_input_mods_e(mods)
|
return ghostty_input_mods_e(mods)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user