How to use SiGrabDevice

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

Moderator: Moderators

Post Reply
Tobias Leis
Posts: 2
Joined: Fri Apr 26, 2019 2:36 am

How to use SiGrabDevice

Post by Tobias Leis » Fri Apr 26, 2019 2:44 am

Hello together,

I am currently working on an application based on the C# example "TestSiapp". I need to always receive data from the mouse, also when the console window (the app is running in) doesn't have focus.
As I found in the forum, the function "SiGrabDevice" could be used for that. Unfortunately I don't know how to use this function.
I read the SDK documentation but i couldn't find the class this function is belonging to and how to access it. Can you help me?

Thanks in advance.
Regards,
Tobias

jwick
Moderator
Moderator
Posts: 2462
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: How to use SiGrabDevice

Post by jwick » Fri Apr 26, 2019 7:40 am

Hello Tobias,

That function didn't make it into the sample code. You can add it to Siapp.cs:

[DllImport(SI_DLL)]
public static extern SpwRetVal SiGrabDevice([In] IntPtr hdl, [In] int exclusive);

Call it like this:
SiApp.SiGrabDevice(devHdl, 1);

Where the 1 arg means your app will get all 3D mouse events while it is running. This grab is released when your app ends. Or you can call it with a 0 to release it manually.

It isn't the friendliest thing to do to other applications that are running, but in some circumstances it is a last resort that must be used.
If you tell us more about what you are doing, we might be able to suggest another method that will cooperate better with the other applications.

Tobias Leis
Posts: 2
Joined: Fri Apr 26, 2019 2:36 am

Re: How to use SiGrabDevice

Post by Tobias Leis » Thu May 09, 2019 4:42 am

Thank you very much for your fast response, this really helped me out!

Further information to my project:
I am using the 3D mouse as "joystick" to control various simulation programs created with Unity. My current approach is to send the received mouse events via a socket connection to my simulations. I know that's not the intended way to use your SDK, but at the moment it runs fast and stable and only minor changes were needed. If you have other ideas for my project, I am always open for input :)

Post Reply