Skip to content

Commit

Permalink
1.60更新
Browse files Browse the repository at this point in the history
[新增] 白名单模式
[新增] 峰值位置调整功能
[修正] 开机启动勾选框的状态无法保存的问题
[优化] 现在在Launchpad中会始终禁用平滑滚动
[优化] 稍微改进了下写的很烂的判断逻辑
[优化] 提高了可以最大滚动的峰值
  • Loading branch information
Caldis committed Aug 20, 2017
1 parent f083243 commit 2145dc7
Show file tree
Hide file tree
Showing 21 changed files with 457 additions and 174 deletions.
18 changes: 12 additions & 6 deletions Mos/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// 是否返回原始事件
var handbackOriginalEvent = true

// 判断输入源
// 判断输入源 (无法区分黑苹果, 因为黑苹果的触控板驱动是模拟鼠标输入的)
if ScrollCore.isTouchPad(of: event) {
// 当触控板输入, 啥都不干
// 当触控板输入时, 啥都不干
} else {
// 当鼠标输入, 根据需要执行翻转方向/平滑滚动

Expand All @@ -37,21 +37,24 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

// 获取列表中应用程序的设置信息
let ignoredApplicaton = ScrollCore.applicationInIgnoreListOf(bundleId: ScrollCore.eventTargetBundleId)

// 处理滚动数据
var scrollFixY = Int64(event.getIntegerValueField(.scrollWheelEventDeltaAxis1))
var scrollPtY = event.getDoubleValueField(.scrollWheelEventPointDeltaAxis1)
var scrollFixPtY = event.getDoubleValueField(.scrollWheelEventFixedPtDeltaAxis1)
// Y轴
if var scrollY = ScrollCore.yAxisExistDataIn(scrollFixY, scrollPtY, scrollFixPtY) {
// 是否翻转滚动, 且窗口BundleId不在禁止翻转滚动列表内
if ScrollCore.option.reverse && !ScrollCore.applicationInReverseIgnoreList(bundleId: ScrollCore.eventTargetBundleId) {
// 是否翻转滚动
if ScrollCore.enableReverse(ignoredApplicaton: ignoredApplicaton) {
event.setIntegerValueField(.scrollWheelEventDeltaAxis1, value: -scrollFixY)
event.setDoubleValueField(.scrollWheelEventPointDeltaAxis1, value: -scrollPtY)
event.setDoubleValueField(.scrollWheelEventFixedPtDeltaAxis1, value: -scrollFixPtY)
scrollY.data = -scrollY.data
}
// 是否平滑滚动, 且窗口BundleId不包含在禁止翻转滚动列表内
if ScrollCore.option.smooth && !ScrollCore.applicationInSmoothIgnoreList(bundleId: ScrollCore.eventTargetBundleId) {
// 是否平滑滚动
if ScrollCore.enableSmooth(ignoredApplicaton: ignoredApplicaton) {
// 禁止返回原始事件
handbackOriginalEvent = false
// 如果输入值为Fixed型则不处理; 如果为非Fixed类型且小于10则归一化为10
Expand All @@ -68,7 +71,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
// 启动一下事件
ScrollCore.activeScrollEventPoster()
}


}

// X轴 (横向滚轮, 如 Logetech MxMaster)
// if event.getIntegerValueField(.scrollWheelEventDeltaAxis2) != 0 {
// 暂时不作处理
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "disclaimer.pdf"
"filename" : "multiple_inputs.pdf"
}
],
"info" : {
Expand Down
Binary file not shown.
187 changes: 143 additions & 44 deletions Mos/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Mos/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.5.1</string>
<string>1.6.0</string>
<key>CFBundleVersion</key>
<string>20170329</string>
<string>20170820</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Mos/MouseEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ +(void)scroll:(uint32_t)type yScroll:(int32_t)yScroll xScroll:(int32_t)xScroll {
CGEventPost(kCGSessionEventTap, event);
}

// 获取鼠标当前位置的顶层窗口信息 (暂时不可用, 无法获取外接屏幕的窗口信息)
// 获取鼠标当前位置的顶层窗口信息 (暂时不可用, 无法获取到外接屏幕的窗口信息)
// var eventTargetOwnerName:String!
// if let eventTargetWindowData = MouseEvent.getWindowData(from: event) {
// eventTargetOwnerName = eventTargetWindowData["kCGWindowOwnerName"] as! String
Expand Down
42 changes: 40 additions & 2 deletions Mos/PreferencesAdvanceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class PreferencesAdvanceViewController: NSViewController {
@IBOutlet weak var scrollTimeSlider: NSSlider!
@IBOutlet weak var scrollTimeLabel: NSTextField!
@IBOutlet weak var scrollTimeStepper: NSStepper!
@IBOutlet weak var scrollPeakSlider: NSSlider!
@IBOutlet weak var scrollPeakLabel: NSTextField!
@IBOutlet weak var scrollPeakStepper: NSStepper!

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -28,6 +31,10 @@ class PreferencesAdvanceViewController: NSViewController {
scrollTimeSlider.intValue = Int32(ScrollCore.advancedOption.time)
scrollTimeLabel.stringValue = String(ScrollCore.advancedOption.time)
scrollTimeStepper.intValue = Int32(ScrollCore.advancedOption.time)
// 峰值
scrollPeakSlider.doubleValue = ScrollCore.advancedOption.peak
scrollPeakLabel.stringValue = String(format: "%.2f", ScrollCore.advancedOption.peak)
scrollPeakStepper.doubleValue = ScrollCore.advancedOption.peak
}

// 速度设置
Expand All @@ -37,7 +44,7 @@ class PreferencesAdvanceViewController: NSViewController {
// 更新值
setScrollSpeed(value: sender.doubleValue)
}
@IBAction func scrollSpeedSteeperChange(_ sender: NSStepper) {
@IBAction func scrollSpeedStepperChange(_ sender: NSStepper) {
// 修改Slider
scrollSpeedSlider.doubleValue = sender.doubleValue
// 更新值
Expand All @@ -61,7 +68,7 @@ class PreferencesAdvanceViewController: NSViewController {
// 更新值
setScrollTime(value: sender.intValue)
}
@IBAction func scrollTimeSteeperChange(_ sender: NSStepper) {
@IBAction func scrollTimeStepperChange(_ sender: NSStepper) {
// 修改Slider
scrollTimeSlider.intValue = sender.intValue
// 更新值
Expand All @@ -80,6 +87,31 @@ class PreferencesAdvanceViewController: NSViewController {
UserDefaults.standard.set(ScrollCore.advancedOption.time, forKey:"time")
}

// 峰值设置
@IBAction func scrollPeakSliderChange(_ sender: NSSlider) {
// 修改Stepper
scrollPeakStepper.doubleValue = sender.doubleValue
// 更新值
setScrollPeak(value: sender.doubleValue)
}
@IBAction func scrollPeakStepperChange(_ sender: NSStepper) {
// 修改Slider
scrollPeakSlider.doubleValue = sender.doubleValue
// 更新值
setScrollPeak(value: sender.doubleValue)
}
func setScrollPeak(value: Double) {
// 修改文字
scrollPeakLabel.stringValue = String(format: "%.2f", value)
// 修改实际参数
ScrollCore.advancedOption.peak = value
// 重新初始化曲线
ScrollCore.basePluseData = ScrollCore.initPluseData()
// 保存设置
UserDefaults.standard.set(ScrollCore.advancedOption.peak, forKey:"peak")
}


// 重置
@IBAction func resetAllToDefaultClick(_ sender: NSButton) {
// 重置速度
Expand All @@ -94,5 +126,11 @@ class PreferencesAdvanceViewController: NSViewController {
scrollTimeSlider.intValue = defTime
scrollTimeLabel.stringValue = String(format: "%.2i", defTime)
setScrollTime(value: defTime)
// 重置峰值
let defPeak = ScrollCore.defAdvancedOption.peak
scrollPeakSlider.doubleValue = defPeak
scrollPeakStepper.doubleValue = defPeak
scrollPeakLabel.stringValue = String(format: "%.2f", defPeak)
setScrollPeak(value: defPeak)
}
}
25 changes: 20 additions & 5 deletions Mos/PreferencesIgnoreViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,27 @@ import Cocoa

class PreferencesIgnoreViewController: NSViewController {

// tableView引用
// 白名单CheckBox
@IBOutlet weak var whiteListModeCheckBox: NSButton!
// 表格, 表格底部工具栏
@IBOutlet weak var tableView: NSTableView!
// tableViewToolBar引用
@IBOutlet weak var tableViewToolBar: NSSegmentedControl!

override func viewDidLoad() {
super.viewDidLoad()
// 恢复一下设置
whiteListModeCheckBox.state = ScrollCore.whiteListMode ? 1 : 0
}

// 是否启用白名单模式
@IBAction func whiteListModeClick(_ sender: NSButton) {
if sender.state == 0 {
ScrollCore.whiteListMode = false
} else {
ScrollCore.whiteListMode = true
}
// 保存设置
UserDefaults.standard.set(ScrollCore.whiteListMode ? "true" : "false", forKey:"whiteListMode")
}

// 列表底部的工具栏
Expand Down Expand Up @@ -55,7 +69,8 @@ class PreferencesIgnoreViewController: NSViewController {
let applicationIcon = NSWorkspace.shared().icon(forFile: applicationPath)
let applicationName = FileManager().displayName(atPath: applicationUrl).removingPercentEncoding!
if let applicationBundleId = Bundle(url: openPanel.url!)?.bundleIdentifier {
let application = IgnoredApplication(notSmooth: true, notReverse: true, icon: applicationIcon, title: applicationName, bundleId: applicationBundleId)
// 添加的例外应用的默认状态与是否启用白名单模式挂钩, 如果启用了白名单模式, 则默认都不禁用; 如果未启用白名单模式, 则默认都禁用
let application = IgnoredApplication(notSmooth: !ScrollCore.whiteListMode, notReverse: !ScrollCore.whiteListMode, icon: applicationIcon, title: applicationName, bundleId: applicationBundleId)
ScrollCore.ignoredApplications.append(application)
ScrollCore.updateIgnoreList()
self.tableView.reloadData()
Expand Down Expand Up @@ -126,7 +141,7 @@ extension PreferencesIgnoreViewController: NSTableViewDelegate {
// 生成每个Cell
if let cell = tableView.make(withIdentifier: tableColumnIdentifier, owner: self) as? NSTableCellView {
let rowItem = ScrollCore.ignoredApplications[row]
// notSmooth列
// notSmooth列, 绑定对应方法
if tableColumnIdentifier == CellIdentifiers.notSmoothCell {
let checkBox = cell.nextKeyView as! NSButton
checkBox.tag = row
Expand All @@ -135,7 +150,7 @@ extension PreferencesIgnoreViewController: NSTableViewDelegate {
checkBox.state = rowItem.notSmooth==true ? 1 : 0
return cell
}
// notReverse列
// notReverse列, 绑定对应方法
if tableColumnIdentifier == CellIdentifiers.notReverseCell {
let checkBox = cell.nextKeyView as! NSButton
checkBox.tag = row
Expand Down
Loading

0 comments on commit 2145dc7

Please sign in to comment.