mirror of
https://github.com/MonitorControl/MonitorControl.git
synced 2026-05-16 06:05:52 -06:00
Update MediaKeyTap dependency, Implement ctrl modifier for internal display
This commit is contained in:
parent
1557664b1b
commit
9f0bcae004
5 changed files with 18 additions and 17 deletions
2
Cartfile
2
Cartfile
|
|
@ -1,4 +1,4 @@
|
|||
github "the0neyouseek/MediaKeyTap"
|
||||
github "the0neyouseek/MediaKeyTap" "master"
|
||||
github "reitermarkus/DDC.swift" "master"
|
||||
github "rnine/AMCoreAudio"
|
||||
github "shpakovski/MASPreferences"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
github "reitermarkus/DDC.swift" "41e7c49b0450033c5349ca1cf5234a26ebc011b8"
|
||||
github "reitermarkus/DDC.swift" "1763870c94c555ff93878caaec8235fd3a9a429d"
|
||||
github "rnine/AMCoreAudio" "3.3.1"
|
||||
github "shpakovski/MASPreferences" "1.3"
|
||||
github "the0neyouseek/MediaKeyTap" "3.1.0"
|
||||
github "the0neyouseek/MediaKeyTap" "4314a361486c2907956756748939c61f460241bd"
|
||||
|
|
|
|||
|
|
@ -198,6 +198,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||
|
||||
extension AppDelegate: MediaKeyTapDelegate {
|
||||
func handle(mediaKey: MediaKey, event: KeyEvent?, modifiers: NSEvent.ModifierFlags?) {
|
||||
let isSmallIncrement = modifiers?.isSuperset(of: NSEvent.ModifierFlags([.shift, .option])) ?? false
|
||||
|
||||
// control internal display when holding ctrl modifier
|
||||
let isControlModifier = modifiers?.isSuperset(of: NSEvent.ModifierFlags([.control])) ?? false
|
||||
if isControlModifier, mediaKey == .brightnessUp || mediaKey == .brightnessDown {
|
||||
if let internalDisplay = DisplayManager.shared.getBuiltInDisplay() as? InternalDisplay {
|
||||
internalDisplay.stepBrightness(isUp: mediaKey == .brightnessUp, isSmallIncrement: isSmallIncrement)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let oppositeKey: MediaKey? = self.oppositeMediaKey(mediaKey: mediaKey)
|
||||
let isRepeat = event?.keyRepeat ?? false
|
||||
|
||||
|
|
@ -216,20 +227,10 @@ extension AppDelegate: MediaKeyTapDelegate {
|
|||
guard let currentDisplay = DisplayManager.shared.getCurrentDisplay() else { return }
|
||||
|
||||
let allDisplays = prefs.bool(forKey: Utils.PrefKeys.allScreens.rawValue) ? displays : [currentDisplay]
|
||||
let isSmallIncrement = modifiers?.isSuperset(of: NSEvent.ModifierFlags([.shift, .option])) ?? false
|
||||
|
||||
// Introduce a small delay to handle the media key being held down
|
||||
let delay = isRepeat ? 0.05 : 0
|
||||
|
||||
// PR open! https://github.com/the0neyouseek/MediaKeyTap/pull/5
|
||||
// if (modifiers?.isSuperset(of: NSEvent.ModifierFlags([.control]))) ?? false &&
|
||||
// if mediaKey == .brightnessUp || mediaKey == .brightnessDown {
|
||||
// if let internalDisplay = DisplayManager.shared.getBuiltInDisplay() as? InternalDisplay {
|
||||
// internalDisplay.stepBrightness(isUp: mediaKey == .brightnessUp, isSmallIncrement: isSmallIncrement)
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
|
||||
for display in allDisplays where display.isEnabled {
|
||||
switch mediaKey {
|
||||
case .brightnessUp, .brightnessDown:
|
||||
|
|
@ -239,13 +240,13 @@ extension AppDelegate: MediaKeyTapDelegate {
|
|||
case .mute:
|
||||
// The mute key should not respond to press + hold
|
||||
if !isRepeat {
|
||||
// volume/mute only matters for external displays
|
||||
// mute only matters for external displays
|
||||
if let display = display as? ExternalDisplay {
|
||||
display.toggleMute()
|
||||
}
|
||||
}
|
||||
case .volumeUp, .volumeDown:
|
||||
// volume/mute only matters for external displays
|
||||
// volume only matters for external displays
|
||||
if let display = display as? ExternalDisplay {
|
||||
self.keyRepeatTimers[mediaKey] = Timer.scheduledTimer(withTimeInterval: delay, repeats: false, block: { _ in
|
||||
display.stepVolume(isUp: mediaKey == .volumeUp, isSmallIncrement: isSmallIncrement)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>632</string>
|
||||
<string>636</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>632</string>
|
||||
<string>636</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSBackgroundOnly</key>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue