Multiple mice on OS X

后端 未结 6 2067
清歌不尽
清歌不尽 2021-02-01 20:51

I am developing an OS X application that is supposed to take input from two mice. I want to read the motion of each mouse independently. What would be the best way to do this?

6条回答
  •  广开言路
    2021-02-01 21:31

    You're going to want to check out the I/O Kit and HID (Human Interface Device) manager stuff.

    HID manager is part of I/O Kit, so looking into there might be useful. There are two APIs for HID management, the older API is a bit more painful and then you have the new 10.5 and above API which is a bit more comfortable.

    Important thing to understand is this isn't going to probably be just a quick fix, it may take some significant work to get it running. If you can assume you'll have 10.5 or better installed, using the Leopard API will definitely help.

    Also; depending on how you accomplish what you're doing, may be important for you to hide the mouse cursor as it may still move a lot even if you're receiving the information from both mice. If your application grabs the screen, I'd use CoreGraphics to disable the cursor and just draw my own.

    You might also consider finding a wrapper for one of these APIs, an example can be found in this question.

提交回复
热议问题