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?
Using space mouse in Rhino 5 Plugin
Moderator: Moderators
Re: Using space mouse in Rhino 5 Plugin
I just realized this is the wrong place. Can someone move this topic to the Windows Developers forum?
Re: Using space mouse in Rhino 5 Plugin
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
Re: Using space mouse in Rhino 5 Plugin
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
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
Re: Using space mouse in Rhino 5 Plugin
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
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
Re: Using space mouse in Rhino 5 Plugin
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?
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?
Re: Using space mouse in Rhino 5 Plugin
Hi michaelr,
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).
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).