扩展 Magic Mouse 的功能:我需要 kext 吗?

发布于 2024-08-09 19:17:01 字数 1564 浏览 2 评论 0原文

我最近购买了一个妙控鼠标。它非常棒并且充满潜力。不幸的是,它受到软件支持的严重阻碍。我想解决这个问题。我已经做了相当多的研究,这些是迄今为止我对事件链的发现:

  1. Magic Mouse 向系统发送完整的多点触控事件。
  2. 多点触控事件在 MultitouchSupport.framework (Carbon) 中进行处理
  3. 事件在框架中进行解释并作为普通事件发送到系统
    • 当您用一根手指滚动时,它会发送实际的滚轮事件。
    • 当您用两根手指滑动时,它会发送一个滑动事件。
  4. 没有 NSTouch 事件发送到系统。您无法使用 NSTouch API 与鼠标交互。

发现上述所有内容后,我拆解了 MultitouchSupport.framework 文件,并通过一些谷歌搜索,找出了如何将我自己的回调插入链中,以便接收原始触摸事件数据。如果枚举设备列表,则可以为每个设备(触控板和鼠标)附加。这一发现将使我们能够创建一个在鼠标上使用多点触控的框架,但只能在单个应用程序中使用。请参阅我的帖子:原始多点触控跟踪

我想在整个系统中为鼠标添加新功能,而不仅仅是单个应用程序。

为了尝试这样做,我弄清楚了如何使用 事件点击,看看最低级别的事件点击是否允许我获取原始数据,解释它,并在其位置上发送我自己的事件。不幸的是,事实并非如此。即使在 HID 级别,事件点击仍然比在 MultitouchSupport.framework 中解释输入的位置高出一步。

请在此处查看我的事件点击尝试:事件点击 - 尝试原始多点触控
一个有趣的旁注:当接收到多点触控事件(例如滑动)时,会点击默认情况并打印出事件编号 29。标题显示 28 是最大值。

关于我的问题,现在您已经掌握了所有信息并看到了我所尝试的内容:扩展 Magic Mouse 功能的最佳方法是什么?我知道我需要在足够低的级别插入一些内容,以便在处理输入和调度预定义事件之前获取输入。因此,将其归结为一句话问题:

  • 是否有某种方法可以覆盖 MultitouchSupport.framework 中使用的默认回调?
  • 我需要编写一个 kext 并自己处理所有传入的数据吗?
  • 是否可以编写一个位于当前正在处理输入的 kext 的顶部的 kext,并在该 kext 完成所有艰苦工作后对其进行过滤?

我的第一个目标是,如果单击时设备上有两根手指,则能够调度中键单击事​​件。显然,还有很多事情可以做,但就目前而言,这似乎是一件值得努力的好事。

提前致谢!

-萨斯蒂拉

I recently purchased a Magic Mouse. It is fantastic and full of potential. Unfortunately, it is seriously hindered by the software support. I want to fix that. I have done quite a lot of research and these are my findings regarding the event chain thus far:

  1. The Magic Mouse sends full multitouch events to the system.
  2. Multitouch events are processed in the MultitouchSupport.framework (Carbon)
  3. The events are interpreted in the framework and sent up to the system as normal events
    • When you scroll with one finger it sends actual scroll wheel events.
    • When you swipe with two fingers it sends a swipe event.
  4. No NSTouch events are sent up to the system. You cannot use the NSTouch API to interact with the mouse.

After I discovered all of the above, I diassembled the MultitouchSupport.framework file and, with some googling, figured out how to insert a callback of my own into the chain so I would receive the raw touch event data. If you enumerate the list of devices, you can attach for each device (trackpad and mouse). This finding would enable us to create a framework for using multitouch on the mouse, but only in a single application. See my post here: Raw Multitouch Tracking.

I want to add new functionality to the mouse across the entire system, not just a single app.

In an attempt to do so, I figured out how to use Event Taps to see if the lowest level event tap would allow me to get the raw data, interpret it, and send up my own events in its place. Unfortunately, this is not the case. The event tap, even at the HID level, is still a step above where the input is being interpreted in MultitouchSupport.framework.

See my event tap attempt here: Event Tap - Attempt Raw Multitouch.
An interesting side note: when a multitouch event is received, such as a swipe, the default case is hit and prints out an event number of 29. The header shows 28 as being the max.

On to my question, now that you have all the information and have seen what I have tried: what would be the best approach to extending the functionality of the Magic Mouse? I know I need to insert something at a low enough level to get the input before it is processed and predefined events are dispatched. So, to boil it down to single sentence questions:

  • Is there some way to override the default callbacks used in MultitouchSupport.framework?
  • Do I need to write a kext and handle all the incoming data myself?
  • Is it possible to write a kext that sits on top of the kext that is handling the input now, and filters it after that kext has done all the hard work?

My first goal is to be able to dispatch a middle button click event if there are two fingers on the device when you click. Obviously there is far, far more that could be done, but this seems like a good thing to shoot for, for now.

Thanks in advance!

-Sastira

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

挽容 2024-08-16 19:17:01

魔术鼠标和玻璃触控板之间的 MultitouchSupport.framework 中发生的情况有何不同?如果它基于 IOKit 设备属性,我怀疑您将需要一个模拟触控板但实际上与鼠标通信的 KEXT。 Apple 有一些关于 Darwin 内核编程和内核扩展的文档:

(就我个人而言,我喜欢一些能够实现捏合放大和更多滑动/按钮手势的东西;事实上,Magic Mouse 是 Mighty Mouse 的四个按钮的功能降级版,[尽管Ever-clogging] 2D 滚轮更新:去年我写了Sesamouse 来做仅此而已,并且它不需要 kext(只需一两周盯着十六进制转储:-) 请参阅我的其他答案以获取 deets 和源代码。)

How does what is happening in MultitouchSupport.framework differ between the Magic Mouse and a glass trackpad? If it is based on IOKit device properties, I suspect you will need a KEXT that emulates a trackpad but actually communicates with the mouse. Apple have some documentation on Darwin kernel programming and kernel extensions specifically:

(Personally, I'd love something that enabled pinch magnification and more swipe/button gestures; as it is, the Magic Mouse is a functional downgrade from the Mighty Mouse's four buttons and [albeit ever-clogging] 2D scroll wheel. Update: last year I wrote Sesamouse to do just that, and it does NOT need a kext (just a week or two staring at hex dumps :-) See my other answer for the deets and source code.)

浮生面具三千个 2024-08-16 19:17:01

抱歉,我忘记更新这个答案,但我最终弄清楚了如何通过 Quartz 事件服务。我不确定它在 Lion 更新后的表现如何,但您可以在 https:// 查看底层源代码github.com/calftrail/Touch

它需要两个技巧:使用私有多点触控框架来获取设备输入,并将未记录 CGEvent结构注入到Quartz事件服务中。弄清楚如何实现它是非常有趣的,但现在我建议只购买一个 Magic Trackpad :-P

Sorry I forgot to update this answer, but I ended up figuring out how to inject multitouch and gesture events into the system from userland via Quartz Event Services. I'm not sure how well it survived the Lion update, but you can check out the underlying source code at https://github.com/calftrail/Touch

It requires two hacks: using the private Multitouch framework to get the device input, and injecting undocumented CGEvent structures into Quartz Event Services. It was incredibly fun to figure out how to pull it off, but these days I recommend just buying a Magic Trackpad :-P

梦里寻她 2024-08-16 19:17:01

我已经实现了用户空间可定制多点触摸事件包装器的概念验证。

您可以在这里阅读:http://aladino.dmi.unict.it/?a =multitouch(参见WaybackMachine)

--
一切顺利

I've implemented a proof-of-concept of userspace customizable multi-touch events wrapper.

You can read about it here: http://aladino.dmi.unict.it/?a=multitouch (see in WaybackMachine)

--
all the best

痕至 2024-08-16 19:17:01

如果您达到这一点,您可能需要考虑中键单击是鼠标上的三个手指而不是两个手指。我考虑过魔术鼠标的中键单击问题,我注意到我经常将第二根手指放在鼠标上,即使我只按左键单击。因此,“2 根手指”单击可能会被误认为是单次左键单击,并且还需要用户付出更多努力,始终保持第二根手指离开鼠标。因此,如果可以检测到,三个手指就会减少混乱和头痛。我想知道第一个“中键单击”解决方案将来自哪里,因为我渴望我的中键单击公开功能返回:)祝你好运。

If you get to that point, you may want to consider the middle click being three fingers on the mouse instead of two. I've thought about this middle click issue with the magic mouse and I notice that I often leave my 2nd finger on the mouse even though I am only pressing for a left click. So a "2 finger" click might be mistaken for a single left click, and it would also require the user more effort in always having to keep the 2nd finger off the mouse. Therefor if it's possible to detect, three fingers would cause less confusion and headaches. I wonder where the first "middle button click" solution will come from, as I am anxious for my middle click Expose feature to return :) Best of luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文