How can I handle multiple mouse inputs in Java?

别等时光非礼了梦想. 提交于 2019-11-30 03:52:01

Look at jinput.

I have had multiple keyboards working with it, I am nearly certain it supports multiple mice too.

dont know about java.. but for C#/c++ you can try the Microsoft Windows MultiPoint Software Development Kit

i've tried it on windows.. it works with 2 USB mice.

It depends on which operating system you intend to use.

On Windows, you can use:

  1. CPNMouse - a driver+software combination, very flexible and allows to completely hide some of the mice from the operating system.
  2. RawInput - an API provided by Windows XP only. You can use it to distinguish between two mouse inputs, draw the cursors yourself and hide the main cursor. Take a look at the code of SDGT, a C# usage of this API.
  3. For both solutions you would have to build a JNI bridge to your application

If you are using X.Org (X11) server, there is patched version called MPX that should support multiple mice even for legacy applications. It should now be a part of the X.Org trunk, but I'm not very familiar with it. Anyway it has an API so you can use it via JNI bridge.

You can use multiple devices, but at the Java level, all mouse events are coalesced into a single stream. The event does not include which mouse it came from. You did say you wanted to mix audio, right? Well this mix might be interesting, but surely not what you want.

I'd suggest using the Java-supported midi interface and connecting some simple midi controller device with multiple knobs or trackballs. These will come in as midi events, and you can examine the state for the details you need.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!