Preferred way of handling buttons from profile

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

Moderator: Moderators

Post Reply
Zarlox
Posts: 11
Joined: Fri Jul 11, 2014 11:37 am

Preferred way of handling buttons from profile

Post by Zarlox » Mon Jul 28, 2014 8:47 am

Hi,

I have looked at most of the supported application profiles and I can see that they all use "AppCommand" macros to assign events to the 3D mouse buttons.

This will dispatch the event to the application via a SI_APP_EVENT instead of a SI_BUTTON_EVENT. I guess this is the preferred method as different mouse could have different HIDs and passToApplication would not work so well.

How do I recognize a named app event? I see the message in the spwOOB.message variable.

The other thing that confuse me is that the SI_APP_EVENT is called 2 times; one with the spwOrientation variable set to SI_RIGHT and the other with spwOrientation set to SI_LEFT. Why is that?

Can anyone clarify how to handle those messages?

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

Re: Preferred way of handling buttons from profile

Post by jwick » Tue Jul 29, 2014 1:22 am

If you have the driver send SI_APP_EVENTs, then the data is in the SiAppCommandData struct. The data is the string that is specified in the Cfg. This is meant to be useful to the application. In our plugins (say for Solidworks), it is usually some internal application command name.

This way there is no limitation on the number of events you can receive. Receiving button events limits you to about 30 different commands that uses can assign in the GUI.

Zarlox
Posts: 11
Joined: Fri Jul 11, 2014 11:37 am

Re: Preferred way of handling buttons from profile

Post by Zarlox » Tue Jul 29, 2014 4:17 pm

I do not see a SiAppCommandData structure. You must mean the SiAppEventData one. The comment in si.h says it goes with the SI_APP_EVENT.

However, the structure only have a integer member called "functionNumber". What is this number associated to? It does not seem to be associated to my AppCommand.

The only place where I can see the string command in SiSpwEvent is under the SiSpwOOB structure. Am I doing something wrong. I am setting my XML profile like the following

Button actions are declared like this:

Code: Select all

<ButtonAction Type="AppCommand">
	  <ID>AppCommand_ICAM_FLY_MODE</ID>
	  <Name>Fly Mode</Name>
	  <AppCmdID>ICAM_FLY_MODE</AppCmdID>
</ButtonAction>
<ButtonAction Type="AppCommand">
	  <ID>AppCommand_ICAM_OBJECT_MODE</ID>
	  <Name>Object Mode</Name>
	  <AppCmdID>ICAM_OBJECT_MODE</AppCmdID>
</ButtonAction>
Then button handling is like the following:

Code: Select all

<Button>
	<Input>
	<ActionID>HIDButton_13</ActionID>
	</Input>
	<Output>
	<ActionID>AppCommand_ICAM_FLY_MODE</ActionID>
	</Output>
</Button>
<Button>
	<Input>
	<ActionID>HIDButton_14</ActionID>
	</Input>
	<Output>
	<ActionID>AppCommand_ICAM_OBJECT_DIALOG</ActionID>
	</Output>
</Button>
And I receive the SI_APP_EVENT but like I say, the message is only available in the Out Of Band structure while the "functionNumber" of SiSpwEventData is always 1 on the first call and then 0 on the automatic subsequent call.

Can you see what I am doing wrong?

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

Re: Preferred way of handling buttons from profile

Post by jwick » Wed Jul 30, 2014 1:23 am

I think you have an old SDK. What version is it? And where did you get it from?
Maybe we never updated it externally.

Contact apisupport-win at 3dconnexion.com.

Your struct should look like this:

Code: Select all

typedef struct          /* 3DxWare event */
{
  int type;                 /* Event type */
  union
  {
    SiSpwData spwData;            /* Button, motion, or combo data        */
    SiSpwOOB spwOOB;              /* Out of band message                  */
    SiOrientation spwOrientation; /* Which hand orientation is the device */
    char exData[SI_MAXBUF];       /* Exception data. Driver use only      */
    SiKeyboardData spwKeyData;    /* String for keyboard data             */
    SiSyncPacket siSyncPacket;    /* GUI SyncPacket sent to applications  */
    SiHWButtonData hwButtonEvent; /* V3DKey that goes with          *
                                   * SI_BUTTON_PRESS/RELEASE_EVENT        */
    SiAppCommandData appCommandData;  /* Application command event function data that *
                                   * goes with an SI_APP_EVENT event      */
    SiDeviceChangeEventData deviceChangeEventData;    /* Data for connecting/disconnecting devices */
    SiCmdEventData cmdEventData;  /* V3DCMD_* function data that *
                                   * goes with an SI_CMD_EVENT event      */
  } u;
} SiSpwEvent;

Zarlox
Posts: 11
Joined: Fri Jul 11, 2014 11:37 am

Re: Preferred way of handling buttons from profile

Post by Zarlox » Wed Jul 30, 2014 11:14 am

OK, I will contact support but just to let you know, I got the SDK from the

http://www.3dconnexion.com/service/soft ... nload.html

page after login in with My3DX account.

3dxware SDK package is: 3DxWare-SDK_v3-0-2_r7538.exe

And the main header file "si.h" is dated from 2/7/2012

Post Reply