C#| How to pass events to original behaviour

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

Moderator: Moderators

Post Reply
obu
Posts: 2
Joined: Mon Mar 11, 2019 9:01 am

C#| How to pass events to original behaviour

Post by obu »

Hey,

I want to implement the spacemouse in a plugin for the simulation program "Process Simulate" of Siemens Tecnomatix. In the standard behaviour, moving the knob of the spacemouse will move the camera of the view. In our tool, we want use the spacemouse to manipulate positions of objects. This behaviour should be switchable in the radialmenu of the driver.

Now my problems:
- I can't override the WndProc void of the simulation program
- A invisible background window recives always all spacemouse events. Good for our behaviour, bad for the standard behaviour.

Is there a possibility for passing through the events to the original behaviour or something like that?
I didn't found similar issues here in the forum and nothing like that in the documentation.

Many thanks in advance and best regards
obu
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: C#| How to pass events to original behaviour

Post by jwick »

Hello,

There are a lot of "it depends" about the details, but it can be done.

There can be multiple connections associated with an app. It's a question of telling the driver which to use. Normally the driver looks at keyboard focus to determine which connection to choose from. Often time, for plugins, this does not work, because the plugin never gets keyboard focus, and the plugin has to take over the decision making.

It depends on the specifics of the interfaces. If Tecnomatix has its own support for the 3D mouse, your plugin will have to cut that off when it wants events. There is an API call SiGrabDevice that allows you to do this. Your code will call it when you want the events sent to you. When you release the grab, probably the events will go back to Tecnomatix.

That is all assuming they are using our API. Which I don't know at the moment.
There are several ways of making this work. Let's start with this approach.
I am working on an API extension to make this more straightforward, but for now it is a bit messy.

The driver will write a log file about what it is doing if you turn it on (3Dx systray icon). The file is %localappdata%/3dconnexion/3DxWare/3DxService.log.
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: C#| How to pass events to original behaviour

Post by jwick »

I see we don't import that function in our sample.
Add it to Siapp.cs:

Code: Select all

    [DllImport(SI_DLL)]
    public static extern SpwRetVal SiGrabDevice([In] IntPtr hdl, [In] int exclusive);
And call it after SiOpen when you want to grab the connection.

Code: Select all

      SiApp.SiGrabDevice(devHdl, 1);
obu
Posts: 2
Joined: Mon Mar 11, 2019 9:01 am

Re: C#| How to pass events to original behaviour

Post by obu »

Hello jwick,

thanks for your reply.
The Tecnomatix products are listed on your homepage as certified Software. So I think they are using your API =)

I already found the SiGrabDevice function here in the forum and try it.
The background window is opened as a child of the Tecnomatix process. So if I have the simulation program in focus, the events are catched automaticly in our form (with or without "exclusive" in the SiGrabDevice, or without SiGrabDevice at all).

What we want is to lead the message back to the Tecnomatix implementation of the Space Mouse. Is there a method we can call to lead a event back to the original implementation?
The idea in my head is the following: Our plugin is somware in the middle of processing events and has the possibility to decide if an event is leaded to Tecnomatix or handled by us.

Many thanks in advance and best regards
jwick
Moderator
Moderator
Posts: 3331
Joined: Wed Dec 20, 2006 2:25 pm
Location: USA
Contact:

Re: C#| How to pass events to original behaviour

Post by jwick »

There is no official way to do this (yet).

I found a thread from 2 years ago that mentions that they are using our official API.
The 3D mouse support is a separate installation package.
There were some focus issues back then. Lots happens in 2 years.

Who is making the window that you are getting events on? If it is them, it could be a child window of their window.
It might be possible for you to let these events go through to their window (or forward them).
They will have to tell you, if this is something they had in mind. Spy++ can tell you about the windows hierarchy.
It's all very Windows-hacky without official support.

I assume you are calling our SiOpen function. That gives you a separate connection to the driver. It would be nice if they shared their connection with you. But that requires a lot of forethought on their part. So far, no one has done that, even with pleading from me.

Sign up as a developer (if you haven't already) so you can email log files to me. I'll take a look at how they are opening a connection to our driver. If it is also hidden, then the driver is going to have a hard time deciding between the two hidden windows. Probably the last one gets used.
It is disappointing that SiGrabDevice isn't releasing the events back to the main program.

I suspect we will see the device events going to the main program when it starts.
Then to your plugin when it is loaded.
Then back to TM when your plugin is unloaded. That probably destroys your event window. Leaving only their window.
The log file should record this.
Post Reply