如何告诉 OS X 忽略两个连接的 USB 鼠标之一的输入?
我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会考虑为鼠标编写一个基本的用户空间驱动程序。
这将允许您将鼠标作为 USB 设备直接访问。您还可以从系统控制设备供您专用。
这里有一些文档:
使用 USB 设备接口
首先,连接到 USB 设备的设置步骤如下(我认为,我的IOKit 生锈了)
包括 IOKit/IOKitLib.h >且< IOKit/usb/IOUSBLib.h >
IOServiceMatching()
查找您感兴趣的设备。这使您可以根据 USB 设备的属性(包括供应商 ID 等)来选择找到正确的 USB 设备。 (参见下面的 IORegistryExplorer 工具屏幕截图)IOCreatePlugInInterfaceForService()
获取 USB 插件实例(我们称之为plugin
),plugin
使用(**plugin)->QueryInterface()
获取设备接口(我们称之为device
)device
代表您的连接句柄USB 设备 - 首先使用(**device).USBDeviceOpen
或(**device).USBDeviceOpenSeize()
打开它。从那里您应该能够发送/接收数据。听起来我知道很多......并且可能有一种更简单的方法,但这就是我想到的。不确定对设备进行这种级别的控制可能会带来一些好处。祝你好运。
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 >
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)plugin
) withIOCreatePlugInInterfaceForService()
plugin
from step 2 get a device interface (let's call itdevice
) using(**plugin)->QueryInterface()
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.