Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

macos

mouse

usb

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.

like image 579
Jeff Avatar asked Aug 18 '10 20:08

Jeff


1 Answers

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

like image 93
nielsbot Avatar answered Nov 05 '22 09:11

nielsbot