macos 在 Mac OS X 中禁用鼠标加速

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5782884/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:59:41  来源:igfitidea点击:

Disabling mouse acceleration in Mac OS X

macosmousehid

提问by aib

First of all, here's the userland question: Disabling mouse acceleration in Mac OS X @ superuser

首先,这是用户领域的问题:在 Mac OS X @ superuser 中禁用鼠标加速

To summarize: I want to have linear mouse responseon Mac OS X. That is, no acceleration; an adjustablebut constantpixels pointer moves / meters mouse movedratio.

总结一下:我想在 Mac OS X 上有线性鼠标响应。也就是说,没有加速;一个可调恒定的pixels pointer moves / meters mouse moved比率。

I have no idea how to go about this. (Well, not true, but it's better to start from scratch.) Should I write a mouse driver? A startup program? A click-and-forget settings adjuster? A preferences pane?

我不知道该怎么做。(好吧,这不是真的,但最好从头开始。) 我应该编写鼠标驱动程序吗?启动程序?单击并忘记设置调整器?首选项面板?

I want my solution to be as simple, universal and unintrusive as possible, so some criteria might be:

我希望我的解决方案尽可能简单、通用和不干扰,所以一些标准可能是:

  • Works on Snow Leopard (10.6.5) and later - much later, unless an important piece of the API gets deprecated
  • Works on mice but not touchpads, tablets, magic wands... (Or maybe configurable?)
  • Can easily be applied/run by other people who want the same thing (all 42 of us on the planet)
  • 适用于 Snow Leopard (10.6.5) 及更高版本 - 很久以后,除非 API 的重要部分被弃用
  • 适用于鼠标,但不适用于触摸板、平板电脑、魔杖......(或者可配置?)
  • 可以很容易地被其他想要同样事情的人应用/运行(我们这个星球上的 42 个人)

I'm a fairly experienced C programmer, both in user and kernel space (in Linux and Windows), but know next to nothing about Mac OS X or Darwin. So anything is appreciated, really ("can't distribute drivers without certificate from Apple") but some documentation/reference would get me a long way ("Darwin's Next Generation Mouse Curve Editing API and Examples").

我是一个相当有经验的 C 程序员,无论是在用户空间还是内核空间(在 Linux 和 Windows 中),但对 Mac OS X 或 Darwin 几乎一无所知。因此,任何事情都值得赞赏,真的(“没有来自 Apple 的证书就不能分发驱动程序”),但一些文档/参考会让我走得很远(“达尔文的下一代鼠标曲线编辑 API 和示例”)。

I know the question is a bit open but I don't even know what kindof a solution could work. Thanks in advance.

我知道这个问题有点开放,但我什至不知道什么的解决方案可行。提前致谢。

Edit: Although I've asked both questions to solve the same problem, this is the programmatical counterpart to the other one. (See the first sentence of this question.) Here I'm trying to create my own solution, so to speak, using - I don't know - some HID API? A driver? A solution on the lines of "open current user's prefs file and change this setting to this" should probably be posted on the other question, but note that such a solution probably doesn't exist.

编辑:虽然我已经问了两个问题来解决同一个问题,但这是另一个问题的编程对应。(请参阅此问题的第一句话。)在这里,我正在尝试创建自己的解决方案,可以这么说,使用 - 我不知道 - 一些 HID API?一个司机?“打开当前用户的首选项文件并将此设置更改为此”这一行的解决方案可能应该发布在另一个问题上,但请注意,这样的解决方案可能不存在。

回答by Beetle

This answer is on the wrong website!

这个答案在错误的网站上!

A lot of my reputation on StackOverflow has come from people voting up this answer, which I wrote way back before I realised that there are several stack exchange websites and that StackOverflow is for programming questions and answers only. Therefore the question above is about how to tackle this if you want to code your own mouse drivers. For all other discussion, go have it here on the superuser sitewhere it belongs.

我在 StackOverflow 上的很多声誉都来自投票给这个答案的人,在我意识到有几个堆栈交换网站并且 StackOverflow 仅用于编程问题和答案之前,我写下了这个答案。因此,上面的问题是关于如果您想编写自己的鼠标驱动程序时如何解决这个问题。对于所有其他讨论,请在它所属的超级用户站点上进行讨论。

Original answer follows.

原答案如下。



Explanation

解释

There's a hidden preference that you can change from the Terminal. To read its current value type

您可以从终端更改隐藏的首选项。读取其当前值类型

defaults read .GlobalPreferences com.apple.mouse.scaling

at the Terminal prompt. Normal values are 0 ~ 3, which can be set by moving the 'Tracking Speed' slider in the Mouse pane of System Preferences. Values of 0 ~ 3 won't disable acceleration, therefore.

在终端提示下。正常值为 0 ~ 3,可以通过移动“系统偏好设置”的“鼠标”面板中的“跟踪速度”滑块来设置。因此,0 ~ 3 的值不会禁用加速。

How to Disable Acceleration

如何禁用加速

However, if you set it to -1 by typing

但是,如果您通过键入将其设置为 -1

defaults write .GlobalPreferences com.apple.mouse.scaling -1

in the Terminal, that seems to disable acceleration and set the mouse tracking speed to some constant predefined value which you can't change.

在终端中,这似乎禁用了加速并将鼠标跟踪速度设置为一些无法更改的恒定预定义值。

I found I had to log out and back in again for it to take effect. After that, the pixels pointer moves / meters mouse movedratio is constantbut unfortunately not adjustable.

我发现我必须注销并重新登录才能生效。在那之后,pixels pointer moves / meters mouse moved比率是恒定的,但不幸的是不可调整

How to Undo Changes

如何撤消更改

To revert back to Apple default settings, just open the Mouse pane of System Preferences and change the Tracking Speed to anything, then quit System Preferences.

要恢复到 Apple 默认设置,只需打开系统偏好设置的鼠标面板并将跟踪速度更改为任何内容,然后退出系统偏好设置。

Mouse ≠ Trackpad

鼠标≠触控板

Mac OS X stores mouse and trackpad settings independently. If you want to disable acceleration on a trackpad instead of a mouse, the instructions are the same, just replace with com.apple.trackpad.scalingwherever you see com.apple.mouse.scalingin the above (and use the Trackpad pane of System Preferences instead of the Mouse pane, obviously).

Mac OS X 独立存储鼠标和触控板设置。如果您想在触控板上禁用加速而不是鼠标,说明是相同的,只需替换为com.apple.trackpad.scalingcom.apple.mouse.scaling在上面看到的任何位置(显然,使用系统偏好设置的触控板面板而不是鼠标面板)。

Notes

笔记

I won't cite a source, since this tip is available in many places on the web. I tried it in OS 10.7 Lion, but many of the sources claim to be using 10.6 Snow Leopard.

我不会引用来源,因为该提示可在网络上的许多地方找到。我在 OS 10.7 Lion 中尝试过,但许多消息来源声称使用的是 10.6 Snow Leopard。