Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessor defines to alter the keys used #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint

## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# Pods/

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Carthage/Build

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

iOSInjectionProject/
10 changes: 7 additions & 3 deletions NativeDisplayBrightness/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@
#include <dlfcn.h>
@import Carbon;



#pragma mark - constants

#define BRIGHTNESS_DOWN_KEY kVK_F1
#define BRIGHTNESS_UP_KEY kVK_F2
static NSString *brightnessValuePreferenceKey = @"brightness";
static const float brightnessStep = 100/16.f;

Expand Down Expand Up @@ -45,7 +49,7 @@ CGEventRef keyboardCGEventCallback(CGEventTapProxy proxy,
if (type == NX_KEYDOWN || type == NX_KEYUP || type == NX_FLAGSCHANGED)
{
int64_t keyCode = CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
if (keyCode == kVK_F2 || keyCode == kVK_F1)
if (keyCode == BRIGHTNESS_UP_KEY || keyCode == BRIGHTNESS_DOWN_KEY)
{
return NULL;
}
Expand Down Expand Up @@ -102,7 +106,7 @@ - (void)_registerGlobalKeyboardEvents
{
[NSEvent addGlobalMonitorForEventsMatchingMask:NSEventMaskKeyDown | NSEventMaskKeyUp handler:^(NSEvent *_Nonnull event) {
//NSLog(@"event!!");
if (event.keyCode == kVK_F1)
if (event.keyCode == BRIGHTNESS_DOWN_KEY)
{
if (event.type == NSEventTypeKeyDown)
{
Expand All @@ -111,7 +115,7 @@ - (void)_registerGlobalKeyboardEvents
});
}
}
else if (event.keyCode == kVK_F2)
else if (event.keyCode == BRIGHTNESS_UP_KEY)
{
if (event.type == NSEventTypeKeyDown)
{
Expand Down