c# programing with the Space Navigator

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

Moderator: Moderators

Post Reply
eyalmaoz
Posts: 6
Joined: Wed Jul 04, 2018 5:35 am

c# programing with the Space Navigator

Post by eyalmaoz » Wed Jul 04, 2018 5:56 am

Hello,
im having some trouble with the setting of the joystick.
My main purpose is to be able to control with the joystick on specific form (something like cursor moving)
BUT to be able to move the focus to other windows/forms. what happens now, looking on the sdk example, is that the event is been checked in the "WndProc(Message)" func of the specific form, but if im not focused on that form... the joystick doesnt do anything (on the wanted form).
Do you have any idea what can i do to make the event of the joystick work non stop when the joystick is connected and how can i track the messeges that it send to the computer without "WndProc(Message)"?

Thank you very much,
Eyal Maoz

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

Re: c# programing with the Space Navigator

Post by jwick » Thu Jul 05, 2018 9:10 am

If you just want to move the cursor, the driver can do that for you.

If you need to get the data in your application regardless of the position of the cursor, use the SiGrabDevice API call. The driver will only send data to your application while the hard grab is in effect. No other application will get data while you have it grabbed.

There are other options if this doesn't work for you.

eyalmaoz
Posts: 6
Joined: Wed Jul 04, 2018 5:35 am

Re: c# programing with the Space Navigator

Post by eyalmaoz » Sun Jul 29, 2018 12:32 am

jwick wrote:
Thu Jul 05, 2018 9:10 am
If you just want to move the cursor, the driver can do that for you.

If you need to get the data in your application regardless of the position of the cursor, use the SiGrabDevice API call. The driver will only send data to your application while the hard grab is in effect. No other application will get data while you have it grabbed.

There are other options if this doesn't work for you.
Hey! Thank you for the reply!
Where is the SiGrabDevice? How do i call it from the progrem?
Couldnt find a function with this name...

eyalmaoz
Posts: 6
Joined: Wed Jul 04, 2018 5:35 am

Re: c# programing with the Space Navigator

Post by eyalmaoz » Sun Jul 29, 2018 2:21 am

Why cant i see this function? Where is it suppose to be?
The SiGrabDevice

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

Re: c# programing with the Space Navigator

Post by jwick » Tue Jul 31, 2018 2:54 am

I see. We didn't get import it in the Siapp.cs sample file.

You have two options, depending on the distribution of the app. That is, if it should cooperate with other apps that want to use the 3D mouse.

1) Create a cfg file for your app that specifies <Grab>Hard</Grab>. This isn't recommended for production use.

Code: Select all

<AppCfg ThisFileVersion="1.4" CfgFormatVersion="1.2" xmlns="" Default="true">
  <AppInfo>
  ...
  </AppInfo>
  <CfgProperties>
    <Grab>Hard</Grab>
  </CfgProperties>
  ...
  
2) Import the function from the C DLL (see C API doc). This is probably what the Import looks like:

Code: Select all

   [DllImport(SI_DLL)]
    public static extern SpwRetVal SiGrabDevice([In] IntPtr hdl, [In] long exclusive);
In both cases, an exclusive/hard Grab means only your app gets data while it is running. This isn't nice to other apps that may be running, but sometimes it is necessary. Using the function allows you to turn on/off the Grab as needed. E.g., when your app loses focus, you should release the Grab.

eyalmaoz
Posts: 6
Joined: Wed Jul 04, 2018 5:35 am

Re: c# programing with the Space Navigator

Post by eyalmaoz » Tue Jul 31, 2018 8:12 am

Perfect! Thank you so much.

Post Reply