开发者

How do I tell OS X to ignore the input from one of two connected USB mice?

开发者 https://www.devze.com 2023-01-11 23:11 出处:网络
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 coco

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 开发者_如何学Gome 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.


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.

How do I tell OS X to ignore the input from one of two connected USB mice?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号