🎉 Smaller increment

- You can now change brightness and volume in smaller increments just like native holding `alt + shift`
This commit is contained in:
Guillaume Broder 2019-06-05 00:01:23 +02:00
parent 9657e4bd6d
commit bfc91fd5ec
No known key found for this signature in database
GPG key ID: 66FB02D063D9E08F
8 changed files with 38 additions and 30 deletions

View file

@ -1,4 +1,4 @@
github "the0neyouseek/MediaKeyTap" "master"
github "the0neyouseek/MediaKeyTap"
github "reitermarkus/DDC.swift" "master"
github "rnine/AMCoreAudio"
github "shpakovski/MASPreferences"

View file

@ -1,4 +1,4 @@
github "reitermarkus/DDC.swift" "5c03666e17a1a850892c08a5db6f4a208f762f26"
github "rnine/AMCoreAudio" "3.3"
github "shpakovski/MASPreferences" "1.3"
github "the0neyouseek/MediaKeyTap" "abfe09f53ccabb1aa14a0f4ab99cfb8812f41919"
github "the0neyouseek/MediaKeyTap" "3.1.0"

View file

@ -312,7 +312,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = "Guillaume Broder";
TargetAttributes = {
56754EAA1D9A4016007BCDC5 = {
@ -634,7 +634,9 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 560;
DEVELOPMENT_TEAM = KGY56RWR9A;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
@ -643,6 +645,7 @@
);
INFOPLIST_FILE = MonitorControl/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControl;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -658,7 +661,9 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 560;
DEVELOPMENT_TEAM = KGY56RWR9A;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
@ -667,6 +672,7 @@
);
INFOPLIST_FILE = MonitorControl/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControl;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
@ -686,10 +692,13 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 560;
DEVELOPMENT_TEAM = KGY56RWR9A;
ENABLE_HARDENED_RUNTIME = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MonitorControlHelper/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControlHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@ -708,10 +717,13 @@
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 560;
DEVELOPMENT_TEAM = KGY56RWR9A;
ENABLE_HARDENED_RUNTIME = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MonitorControlHelper/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MARKETING_VERSION = 1.6.0;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControlHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1100"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
@ -38,8 +36,8 @@
ReferencedContainer = "container:MonitorControl.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
@ -61,8 +59,6 @@
ReferencedContainer = "container:MonitorControl.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"

View file

@ -197,29 +197,29 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// MARK: - Media Key Tap delegate
extension AppDelegate: MediaKeyTapDelegate {
func handle(mediaKey: MediaKey, event _: KeyEvent?) {
func handle(mediaKey: MediaKey, event _: KeyEvent?, modifiers: NSEvent.ModifierFlags?) {
guard let currentDisplay = Utils.getCurrentDisplay(from: displays) else { return }
let allDisplays = prefs.bool(forKey: Utils.PrefKeys.allScreens.rawValue) ? self.displays : [currentDisplay]
let isSmallIncrement = modifiers?.isSuperset(of: NSEvent.ModifierFlags([.shift, .option])) ?? false
for display in allDisplays {
if (prefs.object(forKey: "\(display.identifier)-state") as? Bool) ?? true {
switch mediaKey {
case .brightnessUp:
let value = display.calcNewValue(for: .brightness, withRel: +self.step)
display.setBrightness(to: value)
let value = display.calcNewValue(for: .brightness, withRel: +(isSmallIncrement ? self.step / 4 : self.step))
display.setBrightness(to: value, isSmallIncrement: isSmallIncrement)
case .brightnessDown:
let value = currentDisplay.calcNewValue(for: .brightness, withRel: -self.step)
display.setBrightness(to: value)
let value = currentDisplay.calcNewValue(for: .brightness, withRel: -(isSmallIncrement ? self.step / 4 : self.step))
display.setBrightness(to: value, isSmallIncrement: isSmallIncrement)
case .mute:
display.mute()
case .volumeUp:
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: +self.step)
display.setVolume(to: value)
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: +(isSmallIncrement ? self.step / 4 : self.step))
display.setVolume(to: value, isSmallIncrement: isSmallIncrement)
case .volumeDown:
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: -self.step)
display.setVolume(to: value)
let value = display.calcNewValue(for: .audioSpeakerVolume, withRel: -(isSmallIncrement ? self.step / 4 : self.step))
display.setVolume(to: value, isSmallIncrement: isSmallIncrement)
default:
return
}

View file

@ -71,7 +71,7 @@ class Display {
}
}
func setVolume(to value: Int) {
func setVolume(to value: Int, isSmallIncrement: Bool = false) {
if value > 0, self.isMuted {
self.mute(forceVolume: value)
} else if value == 0 {
@ -85,7 +85,7 @@ class Display {
}
self.hideDisplayOsd()
self.showOsd(command: .audioSpeakerVolume, value: value)
self.showOsd(command: .audioSpeakerVolume, value: value, isSmallIncrement: isSmallIncrement)
self.playVolumeChangedSound()
}
@ -96,7 +96,7 @@ class Display {
self.saveValue(value, for: .audioSpeakerVolume)
}
func setBrightness(to value: Int) {
func setBrightness(to value: Int, isSmallIncrement: Bool = false) {
if self.prefs.bool(forKey: Utils.PrefKeys.lowerContrast.rawValue) {
if value == 0 {
DispatchQueue.global(qos: .userInitiated).async {
@ -120,7 +120,7 @@ class Display {
return
}
self.showOsd(command: .brightness, value: value)
self.showOsd(command: .brightness, value: value, isSmallIncrement: isSmallIncrement)
}
if let slider = brightnessSliderHandler?.slider {
@ -161,7 +161,7 @@ class Display {
return self.prefs.string(forKey: "friendlyName-\(self.identifier)") ?? self.name
}
private func showOsd(command: DDC.Command, value: Int) {
private func showOsd(command: DDC.Command, value: Int, isSmallIncrement: Bool = false) {
guard let manager = OSDManager.sharedManager() as? OSDManager else {
return
}
@ -176,7 +176,7 @@ class Display {
}
}
let step = maxValue / 16
let step = isSmallIncrement ? maxValue / maxValue : maxValue / 16
manager.showImage(osdImage,
onDisplayID: self.identifier,

View file

@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.5.2</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>560</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>

View file

@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.5.2</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>533</string>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSBackgroundOnly</key>