如何告诉 OS X 忽略两个连接的 USB 鼠标之一的输入?

发布于 2024-09-15 03:35:33 字数 242 浏览 2 评论 0原文

我的 Mac 连接了两只 USB 鼠标,其中一只用作扫描仪。我需要访问通用 X 和 Y 数据,但我不希望该数据移动光标。在碳或可可环境下,我如何告诉系统忽略鼠标作为指点设备?

编辑:经过一番挖掘,我发现我可以使用 CGAssociateMouseAndMouseCursorPosition() 函数关闭鼠标位置更新,但这不允许我指定单个鼠标。谁能解释一下 OS X HID 鼠标设备和光标之间的关系?逐个设备的硬件和软件之间必须存在绑定,但我找不到它。

I have two USB mice connected to my Mac, one of which I'm using as a scanner. I need access to the Generic X and Y data but I don't want that data to move the cursor. How, under either carbon or cocoa environments, do I tell the system to ignore the mouse as a pointing device?

Edit: after some digging I've found that I can turn off mouse position updating with the CGAssociateMouseAndMouseCursorPosition() function, but this does not allow me to specify a single mouse. Can anyone explain the OS X relationship between HID mouse devices and the cursor? There has to be a binding between the hardware and software on a device by device basis but I can't find it.

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

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

发布评论

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

评论(1

罪#恶を代价 2024-09-22 03:35:33

我会考虑为鼠标编写一个基本的用户空间驱动程序。
这将允许您将鼠标作为 USB 设备直接访问。您还可以从系统控制设备供您专用。

这里有一些文档:

使用 USB 设备接口

首先,连接到 USB 设备的设置步骤如下(我认为,我的IOKit 生锈了)

包括 IOKit/IOKitLib.h >且< IOKit/usb/IOUSBLib.h >

  1. 使用 IOServiceMatching() 查找您感兴趣的设备。这使您可以根据 USB 设备的属性(包括供应商 ID 等)来选择找到正确的 USB 设备。 (参见下面的 IORegistryExplorer 工具屏幕截图)
  2. 通过 IOCreatePlugInInterfaceForService() 获取 USB 插件实例(我们称之为 plugin),
  3. 使用第 2 步中的 plugin使用 (**plugin)->QueryInterface() 获取设备接口(我们称之为 device
  4. device 代表您的连接句柄USB 设备 - 首先使用 (**device).USBDeviceOpen(**device).USBDeviceOpenSeize() 打开它。从那里您应该能够发送/接收数据。

听起来我知道很多......并且可能有一种更简单的方法,但这就是我想到的。不确定对设备进行这种级别的控制可能会带来一些好处。祝你好运。

IORegistryExplorer 屏幕截图

I would look into writing a basic user-space driver for the mouse.
This will allow you direct access to the mouse as a USB device. You can also take control of the device from the system for your exclusive use.

There is some documentation here:

Working With USB Device Interfaces

To get you started, the set up steps to connect to a USB device go like this (I think, my IOKit is rusty)

include < IOKit/IOKitLib.h > and < IOKit/usb/IOUSBLib.h >

  1. find the device you are interested in using IOServiceMatching(). This lets you pick find the correct USB device based on its properties, including things like vendor ID, &c. (See the IORegistryExplorer tool screen shot below)
  2. get a USB plugin instance (let's call it plugin) with IOCreatePlugInInterfaceForService()
  3. use plugin from step 2 get a device interface (let's call it device) using (**plugin)->QueryInterface()
  4. device represents a connection handle to your USB device--open it first using either (**device).USBDeviceOpen or (**device).USBDeviceOpenSeize(). from there you should be able to send/receive data.

Sounds like a lot I know.. and there might be an easier way, but this is what comes to my mind. There may be some benefits to having this level of control of the device, not sure. good luck.

IORegistryExplorer screen shot

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