Access SDK from WPF/.NET

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

Moderator: Moderators

Post Reply
daveapman
Posts: 8
Joined: Fri Feb 07, 2014 5:01 pm

Access SDK from WPF/.NET

Post by daveapman » Mon Mar 31, 2014 11:42 am

From My WPF/.NET code I have successfully detected and processed 3dMouse device events using the 'Raw mode' interface as shown in ftp site example code.

But, we want to be able to use the SDK, which would allow us to act on device events already processed/smoothed by the SDK/3dConnexion drivers and that also conform to the settings in the 3dConnextion Properties Dialog.

So, my first question is:

Will there ever be .NET SDK support, and if so, when?

As an attempt of a workaround, i have attempted to access the SDK from C++ code that I call from my managed WPF app.
But, the call i make to SiOpenWinInit() always crashes!

In my WPF code, I get the HWND equivalent of my WPF main window with the following code:

Code: Select all

            Window myWin = Application.Current.MainWindow;               // App main window
            IntPtr hwnd = IntPtr.Zero;                                                    // IntPtr variable to hold window handle
            hwnd = new WindowInteropHelper(myWin).Handle;               // get HWND equivalent from app main window
            _mouseSDK = frameAcc.init3dMouseSDK( hwnd );                   // pass window handle to C++
(The frameAcc is bridge code for calling C++)
the init3dMouseSDK() method instantiates a C++ Mouse3dInterface class and calls the init() method(below)
that attempts to access 3dConnexion SDK:

Code: Select all

bool Mouse3dInterface::init( HWND hWnd )
{
   if( SiInitialize() == SPW_DLL_LOAD_ERROR )  return false;

   SiOpenWinInit( &deviceData_, hWnd );               // THIS ALWAYS CRASHES !!! ???
   
So, my next set of questions are:

In the use case I've shown, does anyone have any ideas on why the call to SiOpenWinInit() would be crashing?

Has anyone else had success accessing SDK from WPF/.NET (via c++) ?

Are there other ways that anyone has been able to access the SDK from WPF/.NET ?

Thanks for reading!
Dave

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

Re: Access SDK from WPF/.NET

Post by jwick » Tue Apr 01, 2014 7:33 am

Turn on logging in the driver to see what the driver makes of your arguments.
The log file is written as: %appdata%/3dconnexion/3dxware/3dxservice.log.

You don't need to use the SDK to use 3DxWare 10 but it does do many nice things for you.
You can make a RawInput Cfg for your application.
Start with S3DM_Viewer.xml. Change the Name and ExecutableName.

daveapman
Posts: 8
Joined: Fri Feb 07, 2014 5:01 pm

Re: Access SDK from WPF/.NET

Post by daveapman » Tue Apr 01, 2014 9:19 am

Thanks for the reply!

How do i "turn on logging in the driver"? Is that documented somewhere?

You suggest i make a RawInput Cfg for my application.
What is a RawInput Cfg and how does it work with my current "raw mode" input and '3DxWare 10'?
Where is S3Dm_Viewer.xml (i assume it is a sample Cfg file?)?
What do these Cfg files do?

I assumed that when using raw input mode, 3Dx driver is bypassed.
Is there a way to interact with 3Dx driver when using raw mode input?

Is there a way to utilize 3dConnection properties dialog settings when using raw mode input?

I've spent days looking through all the documentation provided with driver(3DxWare for Windows version 6.17.8) and SDK but have not found info on these subjects.
The raw input mode i have working in my WPF app seems to work well at dynamically detecting the devices and delivering events.
But we REALLY would rather use the SDK or some other means to get driver smoothed data and to have device events conform to 3dConnexion Properties Dialog (user) settings.
Any help with that is greatly appreciated.

Thanks again,
Dave

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

Re: Access SDK from WPF/.NET

Post by jwick » Wed Apr 02, 2014 1:41 am

Ah, I see. You are using the "old" driver. You need to switch to the "new" driver.

Download the "SpaceNavigator Wireless" driver from the web site.
After starting it, right click on the systray icon to enable "Write Log File".

In the installation dir (e.g., C:\Program Files\3Dconnexion\3DxWare\3DxWinCore64/) you will find Cfg/S3DM_Viewer.xml. This is a Cfg file for one of our sample Raw Input apps. Make a copy of that file, renaming it, changing the Name and ExecutableName to your app details.

When you start your application, the driver will switch to your Cfg. Your data will still come from Raw Input (WM_INPUT) but the driver's GUI can be used to modify the data.

The SDK doesn't do smoothing so much as it does event compression. That is, it collapses multiple events into one when you call SiGetEvent. In your Raw Input code, you should read all available 3D mouse motion events and only use the last that was in the queue.

The SDK also handles making multiple devices look like one, and all devices look the same. Raw Input code should handle multiple devices. This isn't a problem unless your users may have multiple devices of different types.

daveapman
Posts: 8
Joined: Fri Feb 07, 2014 5:01 pm

Re: Access SDK from WPF/.NET

Post by daveapman » Wed Apr 02, 2014 11:36 am

Wow, that new driver changes everything. Thanks!

Now I can do 3dMouse view manipulations and customize the parameters using the app specific settings in the 3dConnexion Properties dialog.

This is most of what we need for our first release, so for now I will put my attempt to hook into the SDK on hold.

My next short term goal will be to get at least "Fit View" and "post 3dConnexion Properties" working from the 3dMouse button events.
Currently my raw mode handler gets just basic indexes in the mouse button mask data.
For example, using my simple 2 button 3dMouse, i can detect 0, 1, 2, 3 values from the button mask (corresponding to release, left, right, both).
But, I'd rather get the data associated from the Properties Dialog (Fit, ShowProperties, etc.)
So, I guess i need to know how i can get the properties dialog specified button data from the raw mode button events.

I will also need to figure out how to use the CFG file, for specifying default app and device data.
In particular i'd like to know how to setup the Fit and ShowProperties functionality.
Also, I need to know best practices for our application supplying/installing a CFG file for our customers to use.

Depending on how all that goes, i may need to re-address using the SDK later on.

Thanks again, Dave

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

Re: Access SDK from WPF/.NET

Post by jwick » Thu Apr 03, 2014 1:04 am

You can create your own default Cfg file and install it into %PROGRAMDATA%\3dconnexion\3dxware\cfg.

In it you should assign the Menu button to tell the driver to bring up its GUI. You don't have to do anything in your app.
You should handle button 2 as a Fit View. The driver can't do that. It doesn't know how to reset your view matrix.

As you probably noticed, we have established a standard (like the 2D mouse) in which the two main 3D mouse buttons are used consistently. The left (inside) button launches the GUI or a popup menu. The right (outside) button resets the view. It's the same model as the 2D mouse, but for the left hand.

daveapman
Posts: 8
Joined: Fri Feb 07, 2014 5:01 pm

Re: Access SDK from WPF/.NET

Post by daveapman » Thu Apr 03, 2014 9:56 am

You can create your own default Cfg file and install it into %PROGRAMDATA%\3dconnexion\3dxware\cfg.
Excellent. That will be easy!
In it you should assign the Menu button to tell the driver to bring up its GUI. You don't have to do anything in your app.
You should handle button 2 as a Fit View. The driver can't do that. It doesn't know how to reset your view matrix.
I have the handling of button 2 to do fit view working!

But I' can't figure out how to assign in my app cfg file, the menu button to bring up the GUI.
I am able to interactively open the properties dialog from 3D Mouse Home, and change the Left (button 1) assignment from the default "Show App Popup Menu" to 3DConnexion "Show Popup Menu" and then it works how i would like in the app.
I also see that after i make that interactive left button assignment change in the properties dialog, that it creates a file in my user appdata folder where it associates "HIDButton_1_ input action with "Driver_ShowDriverPopupMenu" output action.
So, i'd like to know how to make this "Driver_ShowDriverPopupMenu" as the default action for the left button for my application.
Hopefully i can do that for all supported devices and not just for example, the SpaceNavigator device i am testing it with.
As you probably noticed, we have established a standard (like the 2D mouse) in which the two main 3D mouse buttons are used consistently. The left (inside) button launches the GUI or a popup menu. The right (outside) button resets the view. It's the same model as the 2D mouse, but for the left hand.
Very nice!

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

Re: Access SDK from WPF/.NET

Post by jwick » Fri Apr 04, 2014 12:48 am

Driver_ShowDriverPopupMenu has gone out of favor. Use Driver_ShowDriverGUI instead. That launches the big GUI.

You can assign this in your default file by copying the Button entry from the file in APPDATA to your default file that you will be installing in ProgramData.

Unfortunately, you need to assign the buttons in every device for this release. In the next release, there will be a generic device where you can make the assignment just once and every device will inherit from the generic device.

In the meantime, AppDefCfg_S80.xml (and Base.xml) shows which button is the Fit button on each device (App_ResetYourView is assigned to it).

daveapman
Posts: 8
Joined: Fri Feb 07, 2014 5:01 pm

Re: Access SDK from WPF/.NET

Post by daveapman » Fri Apr 04, 2014 9:45 am

Sounds good!
I think we're good to go for our first release coming up soon.
There are quite a few engineers at some big companies that are going to be very happy for the 3dmouse support.
I'll probably have more questions when we attempt more button customization for our next release.

Thanks again for the great support!

Dave

Post Reply