summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-10 23:17:54 +0100
committerder richter <der.richter@gmx.de>2024-03-14 23:33:15 +0100
commit5482eecb8afe686101ce386184cafde00798606e (patch)
treee0e375ac1d158b5b57a683a22928f84c6ddeef25
parent18fb71498be4a569f1c2ea99d897aa6bd1035202 (diff)
downloadmpv-5482eecb8afe686101ce386184cafde00798606e.tar.bz2
mpv-5482eecb8afe686101ce386184cafde00798606e.tar.xz
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.
-rw-r--r--osdep/mac/input_helper.swift4
-rw-r--r--osdep/mac/swift_extensions.swift6
2 files changed, 8 insertions, 2 deletions
diff --git a/osdep/mac/input_helper.swift b/osdep/mac/input_helper.swift
index 9e1b4811a9..48e289f409 100644
--- a/osdep/mac/input_helper.swift
+++ b/osdep/mac/input_helper.swift
@@ -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
}
diff --git a/osdep/mac/swift_extensions.swift b/osdep/mac/swift_extensions.swift
index c0a7cd95e4..004927766d 100644
--- a/osdep/mac/swift_extensions.swift
+++ b/osdep/mac/swift_extensions.swift
@@ -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)