diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b5c6a5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,20 @@ +build/ +DerivedData/ + +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +*.moved-aside +*.xcuserstate + +*.hmap +*.ipa +*.dSYM.zip +*.dSYM diff --git a/DiscreteScroll.xcodeproj/project.pbxproj b/DiscreteScroll.xcodeproj/project.pbxproj new file mode 100644 index 0000000..b97b724 --- /dev/null +++ b/DiscreteScroll.xcodeproj/project.pbxproj @@ -0,0 +1,250 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + C32391431DE7B5670068C5B9 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = C32391421DE7B5670068C5B9 /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + C323913A1DE7B5670068C5B9 /* DiscreteScroll.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DiscreteScroll.app; sourceTree = BUILT_PRODUCTS_DIR; }; + C323913E1DE7B5670068C5B9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C32391421DE7B5670068C5B9 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + C32391371DE7B5670068C5B9 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + C32391311DE7B5670068C5B9 = { + isa = PBXGroup; + children = ( + C323913C1DE7B5670068C5B9 /* DiscreteScroll */, + C323913B1DE7B5670068C5B9 /* Products */, + ); + sourceTree = ""; + }; + C323913B1DE7B5670068C5B9 /* Products */ = { + isa = PBXGroup; + children = ( + C323913A1DE7B5670068C5B9 /* DiscreteScroll.app */, + ); + name = Products; + sourceTree = ""; + }; + C323913C1DE7B5670068C5B9 /* DiscreteScroll */ = { + isa = PBXGroup; + children = ( + C32391421DE7B5670068C5B9 /* main.m */, + C323913E1DE7B5670068C5B9 /* Info.plist */, + ); + path = DiscreteScroll; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + C32391391DE7B5670068C5B9 /* DiscreteScroll */ = { + isa = PBXNativeTarget; + buildConfigurationList = C32391571DE7B5670068C5B9 /* Build configuration list for PBXNativeTarget "DiscreteScroll" */; + buildPhases = ( + C32391361DE7B5670068C5B9 /* Sources */, + C32391371DE7B5670068C5B9 /* Frameworks */, + C32391381DE7B5670068C5B9 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DiscreteScroll; + productName = DiscreteScroll; + productReference = C323913A1DE7B5670068C5B9 /* DiscreteScroll.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + C32391321DE7B5670068C5B9 /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0620; + ORGANIZATIONNAME = "Emre Yolcu"; + TargetAttributes = { + C32391391DE7B5670068C5B9 = { + CreatedOnToolsVersion = 6.2; + }; + }; + }; + buildConfigurationList = C32391351DE7B5670068C5B9 /* Build configuration list for PBXProject "DiscreteScroll" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = C32391311DE7B5670068C5B9; + productRefGroup = C323913B1DE7B5670068C5B9 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + C32391391DE7B5670068C5B9 /* DiscreteScroll */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + C32391381DE7B5670068C5B9 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + C32391361DE7B5670068C5B9 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C32391431DE7B5670068C5B9 /* main.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + C32391551DE7B5670068C5B9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + C32391561DE7B5670068C5B9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.9; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + }; + name = Release; + }; + C32391581DE7B5670068C5B9 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = DiscreteScroll/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + C32391591DE7B5670068C5B9 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = DiscreteScroll/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + C32391351DE7B5670068C5B9 /* Build configuration list for PBXProject "DiscreteScroll" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C32391551DE7B5670068C5B9 /* Debug */, + C32391561DE7B5670068C5B9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C32391571DE7B5670068C5B9 /* Build configuration list for PBXNativeTarget "DiscreteScroll" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C32391581DE7B5670068C5B9 /* Debug */, + C32391591DE7B5670068C5B9 /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = C32391321DE7B5670068C5B9 /* Project object */; +} diff --git a/DiscreteScroll.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/DiscreteScroll.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..29a791b --- /dev/null +++ b/DiscreteScroll.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/DiscreteScroll/Info.plist b/DiscreteScroll/Info.plist new file mode 100644 index 0000000..d073c8d --- /dev/null +++ b/DiscreteScroll/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + Emre.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + LSUIElement + + NSHumanReadableCopyright + Copyright © 2016 Emre Yolcu. All rights reserved. + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/DiscreteScroll/main.m b/DiscreteScroll/main.m new file mode 100644 index 0000000..c485827 --- /dev/null +++ b/DiscreteScroll/main.m @@ -0,0 +1,35 @@ +#import + +#define SIGN(x) (((x) > 0) - ((x) < 0)) +#define LINES 3 + +CGEventRef cgEventCallback(CGEventTapProxy proxy, CGEventType type, + CGEventRef event, void *refcon) +{ + if (!CGEventGetIntegerValueField(event, kCGScrollWheelEventIsContinuous)) { + int64_t delta = CGEventGetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1); + + CGEventSetIntegerValueField(event, kCGScrollWheelEventDeltaAxis1, SIGN(delta) * LINES); + } + + return event; +} + +int main(void) +{ + CFMachPortRef eventTap; + CFRunLoopSourceRef runLoopSource; + + eventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, 0, + 1 << kCGEventScrollWheel, cgEventCallback, NULL); + runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0); + + CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes); + CGEventTapEnable(eventTap, true); + CFRunLoopRun(); + + CFRelease(eventTap); + CFRelease(runLoopSource); + + return 0; +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..191674b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Emre Yolcu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..86a5718 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# discrete-scroll \ No newline at end of file