mac/input: define AltGr mask as static NSEvent.ModifierFlags variable

this makes it possible to properly test for those modifiers in a proper
swift like way.
This commit is contained in:
der richter 2024-03-10 23:17:54 +01:00
parent 18fb71498b
commit 5482eecb8a
2 changed files with 8 additions and 2 deletions

View File

@ -85,8 +85,8 @@ class InputHelper: NSObject {
if modifiers.contains(.command) {
mask |= MP_KEY_MODIFIER_META
}
if modifiers.rawValue & UInt(NX_DEVICELALTKEYMASK) != 0 ||
modifiers.rawValue & UInt(NX_DEVICERALTKEYMASK) != 0 && !mp_input_use_alt_gr(input)
if modifiers.contains(.optionLeft) ||
modifiers.contains(.optionRight) && !mp_input_use_alt_gr(input)
{
mask |= MP_KEY_MODIFIER_ALT
}

View File

@ -16,6 +16,7 @@
*/
import Cocoa
import IOKit.hidsystem
extension NSDeviceDescriptionKey {
static let screenNumber = NSDeviceDescriptionKey("NSScreenNumber")
@ -41,6 +42,11 @@ extension NSColor {
}
}
extension NSEvent.ModifierFlags {
public static var optionLeft: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICELALTKEYMASK))
public static var optionRight: NSEvent.ModifierFlags = .init(rawValue: UInt(NX_DEVICERALTKEYMASK))
}
extension Bool {
init(_ int32: Int32) {
self.init(int32 != 0)