Tracking multiple optical mice

264 views
Skip to first unread message

Chinmay Purandare

unread,
Nov 26, 2019, 7:08:14 PM11/26/19
to Bonsai Users
Hello
I am new to Bonsai and found the MouseMove source in Windows.input to be very helpful. I was wondering if it can track 2 separately connected USB mice. I am hoping to develop that into a VR game controlled by 2 subjects and eventually adapted to 2 rats. I think if I can access the source code for the Windows Input package, it should be possible to make modifications such that each mousemove source comes with a specification of port/usb/mouse source number(similar to how arduino sources allows you to choose the COM port).
Has anyone dealt with this type of modification to the packages before and can point me in the correct direction?
Thanks
Chinmay

Gonçalo Lopes

unread,
Nov 30, 2019, 3:37:10 PM11/30/19
to Chinmay Purandare, Bonsai Users
Hi Chinmay,

Using the MouseMove operator in Windows.Input this is not possible, as it uses the data from the single OS mouse cursor.

However, using the Mouse operator in the Shaders.Input package you can specify the Index for which mouse you want to read from. The tradeoff is you have to poll it rather than respond to OS-events, for example using the UpdateFrame event as an input, like so:

image.png

Beware that if you try this on your laptop, your touch-screen and mousepad may show up as two different devices (as in my case), so an external mouse will actually be Index 2, and not Index 1. Play around a bit with the indices until you get it to work.

Hope this helps.

--
You received this message because you are subscribed to the Google Groups "Bonsai Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bonsai-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bonsai-users/6524bbf0-99a8-40ea-b874-980aa51b1e60%40googlegroups.com.

Marcelo J. Moglie

unread,
May 3, 2021, 11:51:53 AM5/3/21
to Bonsai Users
Hi all, 

Hope you are all well. I have a somehow related question: I was wondering which will the best the most efficient way to record mouse position. Which would be the best operator or combination of operators to retrieve the cursor position in the most precise and fastest way? I am trying to get that information from a touch screen and I have been experiencing some issues when the cursor goes from one screen to another because there is some lag between the touchscreen recognizing being touched and the reading obtained.

Many thanks,
Marcelo

Gonçalo Lopes

unread,
May 9, 2021, 6:16:01 PM5/9/21
to Marcelo J. Moglie, Bonsai Users
Hi Marcelo,

In terms of latency, the MouseMove operator in Bonsai is directly connected to the global OS mouse handler interrupt so it should be relatively fast, however it does have limitations in terms of handling multiple mice.

Using a touchscreen instead of an optical mouse might also affect the reading latency of the cursor.

Out of curiosity, how are you benchmarking the lag currently?

Gonçalo Lopes

unread,
May 16, 2021, 2:09:26 PM5/16/21
to Marcelo J. Moglie, Bonsai Users
Ah, interesting, indeed sometimes the mouse hardware interface will have compensation behaviors when bouncing against screen edges, dragging, clicking, etc which can be quite annoying. Let us know if you figure out what the problem was!

On Tue, 11 May 2021 at 18:29, Marcelo J. Moglie <mjmo...@gmail.com> wrote:
Hi Gonçalo,

Thank you very much for your response. I was not benchmarking the time lag but evaluating the readings obtained. When the cursor is far away from the active window in the touchscreen and the screen is touched, using the MouseMove operator, I didn't get the instant value but a sequence of values until reaching the position that was touched. This was reflected as an overshoot in the mouse position read that becomes higher, the fastest the movement is. 

I am trying to contact the suppliers of the touchscreen to determine whether this can be fixed by changing the firmware. 

Best Regards,
Marcelo


Reply all
Reply to author
Forward
0 new messages