How can I handle multiple mouse inputs in Java?

2020-02-22 04:37发布

A friend of mine asked me to implement a blue and a red pointer to represent the inputs of two separate mice to expedite a mixing desk scenario for real time audio mixing. I'd love to, but as much as I think it is a great idea, I don't have a clue as to where to start looking for a possible solution.

Where should I start researching a viable method of implementing dual mouse inputs?

标签: java mouse hci
4条回答
倾城 Initia
2楼-- · 2020-02-22 05:09

Look at jinput.

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

查看更多
爷、活的狠高调
3楼-- · 2020-02-22 05:12

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.

查看更多
Melony?
4楼-- · 2020-02-22 05:24

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.

查看更多
干净又极端
5楼-- · 2020-02-22 05:25

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.

查看更多
登录 后发表回答