mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 17:08:39 +00:00
More Productive Gestures (#289)
* Scroll Functionality Works * updated md * Update README.md * Update README.md * attempted to fix readme * fixed readme * fixed readme
This commit is contained in:
parent
a0fc0b33c5
commit
f61550e510
@ -76,7 +76,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
} else {
|
} else {
|
||||||
TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier)
|
TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
AppSettings.blacklistedAppIds = TouchBarController.shared.blacklistAppIdentifiers
|
AppSettings.blacklistedAppIds = TouchBarController.shared.blacklistAppIdentifiers
|
||||||
TouchBarController.shared.updateActiveApp()
|
TouchBarController.shared.updateActiveApp()
|
||||||
updateIsBlockedApp()
|
updateIsBlockedApp()
|
||||||
@ -132,7 +132,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
let hapticFeedback = NSMenuItem(title: "Haptic Feedback", action: #selector(toggleHapticFeedback(_:)), keyEquivalent: "H")
|
let hapticFeedback = NSMenuItem(title: "Haptic Feedback", action: #selector(toggleHapticFeedback(_:)), keyEquivalent: "H")
|
||||||
hapticFeedback.state = AppSettings.hapticFeedbackState ? .on : .off
|
hapticFeedback.state = AppSettings.hapticFeedbackState ? .on : .off
|
||||||
|
|
||||||
let multitouchGestures = NSMenuItem(title: "Volume/Brightness gestures", action: #selector(toggleMultitouch(_:)), keyEquivalent: "")
|
let multitouchGestures = NSMenuItem(title: "Default Swipe Gestures", action: #selector(toggleMultitouch(_:)), keyEquivalent: "")
|
||||||
multitouchGestures.state = AppSettings.multitouchGestures ? .on : .off
|
multitouchGestures.state = AppSettings.multitouchGestures ? .on : .off
|
||||||
|
|
||||||
let settingSeparator = NSMenuItem(title: "Settings", action: nil, keyEquivalent: "")
|
let settingSeparator = NSMenuItem(title: "Settings", action: nil, keyEquivalent: "")
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import Foundation
|
|||||||
|
|
||||||
|
|
||||||
class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
||||||
|
var onefinger: NSPanGestureRecognizer!
|
||||||
var twofingers: NSPanGestureRecognizer!
|
var twofingers: NSPanGestureRecognizer!
|
||||||
var threefingers: NSPanGestureRecognizer!
|
var threefingers: NSPanGestureRecognizer!
|
||||||
var fourfingers: NSPanGestureRecognizer!
|
var fourfingers: NSPanGestureRecognizer!
|
||||||
@ -30,6 +31,11 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
|||||||
stackView.orientation = .horizontal
|
stackView.orientation = .horizontal
|
||||||
view = stackView
|
view = stackView
|
||||||
|
|
||||||
|
onefinger = NSPanGestureRecognizer(target: self, action: #selector(onefingerHandler(_:)))
|
||||||
|
onefinger.numberOfTouchesRequired = 1
|
||||||
|
onefinger.allowedTouchTypes = .direct
|
||||||
|
view.addGestureRecognizer(onefinger)
|
||||||
|
|
||||||
twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:)))
|
twofingers = NSPanGestureRecognizer(target: self, action: #selector(twofingersHandler(_:)))
|
||||||
twofingers.numberOfTouchesRequired = 2
|
twofingers.numberOfTouchesRequired = 2
|
||||||
twofingers.allowedTouchTypes = .direct
|
twofingers.allowedTouchTypes = .direct
|
||||||
@ -57,9 +63,31 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
|||||||
legacyPrevPositions[fingers] = position
|
legacyPrevPositions[fingers] = position
|
||||||
case .changed:
|
case .changed:
|
||||||
if self.legacyGesturesEnabled {
|
if self.legacyGesturesEnabled {
|
||||||
|
if fingers == 1 {
|
||||||
|
let prevPos = legacyPrevPositions[fingers]!
|
||||||
|
if ((position - prevPos) > 3) || ((prevPos - position) > 3) {
|
||||||
|
if position > prevPos {
|
||||||
|
GenericKeyPress(keyCode: CGKeyCode(124)).send()
|
||||||
|
} else if position < prevPos {
|
||||||
|
GenericKeyPress(keyCode: CGKeyCode(123)).send()
|
||||||
|
}
|
||||||
|
legacyPrevPositions[fingers] = position
|
||||||
|
}
|
||||||
|
}
|
||||||
if fingers == 2 {
|
if fingers == 2 {
|
||||||
let prevPos = legacyPrevPositions[fingers]!
|
let prevPos = legacyPrevPositions[fingers]!
|
||||||
if ((position - prevPos) > 10) || ((prevPos - position) > 10) {
|
if ((position - prevPos) > 50) || ((prevPos - position) > 50) {
|
||||||
|
if position > prevPos {
|
||||||
|
GenericKeyPress(keyCode: CGKeyCode(124)).send()
|
||||||
|
} else if position < prevPos {
|
||||||
|
GenericKeyPress(keyCode: CGKeyCode(123)).send()
|
||||||
|
}
|
||||||
|
legacyPrevPositions[fingers] = position
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if fingers == 3 {
|
||||||
|
let prevPos = legacyPrevPositions[fingers]!
|
||||||
|
if ((position - prevPos) > 15) || ((prevPos - position) > 15) {
|
||||||
if position > prevPos {
|
if position > prevPos {
|
||||||
HIDPostAuxKey(NX_KEYTYPE_SOUND_UP)
|
HIDPostAuxKey(NX_KEYTYPE_SOUND_UP)
|
||||||
} else if position < prevPos {
|
} else if position < prevPos {
|
||||||
@ -68,7 +96,7 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
|||||||
legacyPrevPositions[fingers] = position
|
legacyPrevPositions[fingers] = position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if fingers == 3 {
|
if fingers == 4 {
|
||||||
let prevPos = legacyPrevPositions[fingers]!
|
let prevPos = legacyPrevPositions[fingers]!
|
||||||
if ((position - prevPos) > 15) || ((prevPos - position) > 15) {
|
if ((position - prevPos) > 15) || ((prevPos - position) > 15) {
|
||||||
if position > prevPos {
|
if position > prevPos {
|
||||||
@ -90,6 +118,11 @@ class BasicView: NSCustomTouchBarItem, NSGestureRecognizerDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc func onefingerHandler(_ sender: NSGestureRecognizer?) {
|
||||||
|
let position = (sender?.location(in: sender?.view).x)!
|
||||||
|
self.gestureHandler(position: position, fingers: 1, state: sender!.state)
|
||||||
|
}
|
||||||
|
|
||||||
@objc func twofingersHandler(_ sender: NSGestureRecognizer?) {
|
@objc func twofingersHandler(_ sender: NSGestureRecognizer?) {
|
||||||
let position = (sender?.location(in: sender?.view).x)!
|
let position = (sender?.location(in: sender?.view).x)!
|
||||||
self.gestureHandler(position: position, fingers: 2, state: sender!.state)
|
self.gestureHandler(position: position, fingers: 2, state: sender!.state)
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>0.25</string>
|
<string>0.25</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>385</string>
|
<string>402</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.utilities</string>
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
13
README.md
13
README.md
@ -104,11 +104,16 @@ The pre-installed configuration contains less or more than you'll probably want,
|
|||||||
|
|
||||||
## Gestures
|
## Gestures
|
||||||
|
|
||||||
By default you can enable basic gestures from application menu (status bar -> MTMR icon -> Volume/Brightness gestures):
|
### Default Gestures
|
||||||
- two finger slide: change you Volume
|
|
||||||
- three finger slide: change you Brightness
|
|
||||||
|
|
||||||
### Custom gestures
|
By default you can enable basic gestures from application menu (status bar -> MTMR icon -> Default Swipe Gestures):
|
||||||
|
|
||||||
|
- ```one finger slide```: Move Caret
|
||||||
|
- ```two finger slide```: Move Caret with precision
|
||||||
|
- ```three finger slide```: Increase/Decrease Volume
|
||||||
|
- ```four finger slide```: Increase/Decrease Brightness
|
||||||
|
|
||||||
|
### Custom Gestures
|
||||||
|
|
||||||
You can add custom actions for two/three/four finger swipes. To do it, you need to use `swipe` type:
|
You can add custom actions for two/three/four finger swipes. To do it, you need to use `swipe` type:
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user