As we introduce more, varied devices, our strategy on button events has changed over the years to get farther away from the specific hardware events. We now recommend using our generic Virtual 3D Commands. These are independent of the hardware that generates them. The driver has to be told what sort of button events you want to receive. By default it sends button events that are for older applications.
There are two ways to tell it.
1) Create a cfg file for your application. While this gives you complete control, it is difficult.
2) Tell the driver you want it to use a specific default file (different from the one for older applications).
You do this by sending it a hint (code from the TestSiApp C# demo code):
Code: Select all
// Tell the driver we want to receive V3DCMDs instead of V3DKeys
SiApp.SiOpenWinAddHintBoolEnum(openData, SiApp.SiHintEnum.SI_HINT_USESV3DCMDS, 1);
With this Hint, it will send the application SI_CMD_EVENTS:
Code: Select all
SiApp.SiSpwEvent spwEvent = new SiApp.SiSpwEvent();
SiApp.SpwRetVal val = SiApp.SiGetEvent(devHdl, SiApp.SI_AVERAGE_EVENTS, eventData, spwEvent);
if (val == SiApp.SpwRetVal.SI_IS_EVENT)
{
switch (spwEvent.type)
{
...
case SiApp.SiEventType.SI_CMD_EVENT:
Log("SI_CMD_EVENT: ", string.Format("V3DCMD = {0}, pressed = {1}", spwEvent.cmdEventData.functionNumber, spwEvent.cmdEventData.pressed > 0));
Print("V3DCMD event: V3DCMD = {0}, pressed = {1}", spwEvent.cmdEventData.functionNumber, spwEvent.cmdEventData.pressed > 0);
break;
...
An additional step is to export a list (tree) of your application commands to the driver so users can see them in our GUI and assign them to the device buttons (and radial menus). In general, there are some events, such as reset view, Top View, Back View, that will be handled via V3DCMDs (SI_CMD_EVENTs) and application functions that are handled via SI_APP_EVENTs.
With SDK v4 you don't need to handle those viewing commands. The lib takes care of all viewing operations.