Using space mouse in Rhino 5 Plugin

Post questions, comments and feedback to our 3Dconnexion Windows Development Team.

Moderator: Moderators

Post Reply
michaelr
Posts: 3
Joined: Fri Sep 18, 2020 6:09 am

Using space mouse in Rhino 5 Plugin

Post by michaelr »

I would like to use the space mouse in a Rhinoceros 5 plugin. The plugin, written in C++, creates multiple windows and one of these windows should be controlled using the space mouse.
My first attempt was to use SiOpenWinInit()/SiGrabDevice() on my plugin window. However this does not work. There are no errors, but even if the plugin window has the focus the space mouse still operates on the Rhino scene view in the background.

I wonder if this scenario could work at all. May it is not possible to use the space mouse in this way. Does anybody know?
michaelr
Posts: 3
Joined: Fri Sep 18, 2020 6:09 am

Re: Using space mouse in Rhino 5 Plugin

Post by michaelr »

I just realized this is the wrong place. Can someone move this topic to the Windows Developers forum?
ngomes
Moderator
Moderator
Posts: 3318
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Using space mouse in Rhino 5 Plugin

Post by ngomes »

Doesn't Rhino already have support for 3D mice? If so, there may be a conflict if you add a plug-in connecting to the same driver.
Nuno Gomes
frist
Posts: 5
Joined: Tue Oct 20, 2020 5:37 am

Re: Using space mouse in Rhino 5 Plugin

Post by frist »

Hi,
I would also be very interested in an idea how to achieve what the OP wants to do. In my case its Rhino 7 and a Grasshopper plugin.

@ngomes: In case you just need this for a demonstration and can live with a super bad solution: I once used a 2nd program to capture the SpaceMouse input and stream it via socket connection to a Grasshopper plugin. As soon as the 2nd program has focus the SpaceMouse was available in my Grasshopper plugin - not a practical solution by any means but good enough for a single demo.

See you
Flo
frist
Posts: 5
Joined: Tue Oct 20, 2020 5:37 am

Re: Using space mouse in Rhino 5 Plugin

Post by frist »

Hi,
for some reason the first message that I wrote disappeared...

I'd also be very interested in an idea how to achieve what the OP wants to do. In my case I'd like to use the SpaceMouse in a Grasshopper plugin.

@michaelr: I once used a quick and dirty solution for the problem in an demo. I used a 2nd program to stream the SpaceMouse input via a socket connection to a Grasshopper plugin. So whenever the 2nd program had focus I had the SpaceMouse raw input data available in Grasshopper.

See you
flo
michaelr
Posts: 3
Joined: Fri Sep 18, 2020 6:09 am

Re: Using space mouse in Rhino 5 Plugin

Post by michaelr »

After some testing I am still unsure if and how this could work.

My first attempt was to use the siapp.dll API to implement space mouse message handling
in my plugin window, just as I would do in a normal application.
This did not work, no messages were sent to my window. Moreover, initializing the library in the
plugin is a bad idea - after closing the plugin window the space mouse stops working alltogether.
As ngomes already noted, connecting to the driver from a plugin may conflicht with Rhino's space
mouse integration.

So the question is, how can I get Rhino to route the space mouse messages to my plugin window?
ngomes
Moderator
Moderator
Posts: 3318
Joined: Mon Nov 27, 2006 7:22 am
Contact:

Re: Using space mouse in Rhino 5 Plugin

Post by ngomes »

Hi michaelr,
michaelr wrote: Fri Oct 23, 2020 8:46 am So the question is, how can I get Rhino to route the space mouse messages to my plugin window?
You're going down a rabbit hole.

When faced with multiple connections from the same application -- a perfectly valid scenario in many instances, the driver will use a heuristic approach to determine which of the connections gets the SpaceMouse data.

You mentioned SiGrabDevice() does not work but I cannot see why it wouldn't. Try setting the "exclusive" parameter to SPW_TRUE. Do note that an exclusive "grab" will affect other applications since you're basically controlling the driver focus at that point. You need to detect when to "release" the grab (SiReleaseGrab call).
Post Reply