Getting actions or buttons to work

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

Moderator: Moderators

Post Reply
axeljaeger
Posts: 3
Joined: Sun Dec 31, 2017 7:07 am

Getting actions or buttons to work

Post by axeljaeger »

Hello,
I am currently adding support for 3dconnexion devices in my application. Yesterday I was able to move and rotate a triangle in a sample application. I am unable to get the buttons to work. Here is what I tried so far:

I am using Qt for my application so I created a small demo application. I open and register in the constructor of my OpenGLWidget:

Code: Select all

    SpwRetVal retVal;
    retVal = SiInitialize();

    if (retVal == SPW_ERROR ) {
        qWarning() << "Error in SiInitialize()";
    }

    SiOpenData oData;
    SiOpenWinInit( &oData, (HWND)winId() );

    m_hdl = SiOpen ("PAC", SI_ANY_DEVICE, SI_NO_MASK,
                             SI_EVENT, &oData);

    if (m_hdl == SI_NO_HANDLE) {
        qWarning() << "Could not open a 3DxWare device";
    }
In my native event handler, I get the events:

Code: Select all

bool GLWidget::nativeEvent(const QByteArray &eventType, void *message, long *result)
{
    if(eventType == "windows_generic_MSG") {
        const MSG *msg = reinterpret_cast<MSG *>(message);
        SiGetEventData eData;  /* Platform-specific event data */
        SiSpwEvent siEvent;    /* 3DxWare data event */

        SiGetEventWinInit (&eData, msg->message, msg->wParam,
                           msg->lParam);
        if (SiGetEvent (m_hdl, 0, &eData, &siEvent) == SI_IS_EVENT) {
            switch (siEvent.type) {
            case SI_MOTION_EVENT: {
		// Handling of motion events. This gets called and works
                } break;

            case SI_ZERO_EVENT:
                break;

            case SI_APP_EVENT:
                qDebug() << "App event"; // Neither does this one gets called
                break;

            case SI_CMD_EVENT:
                qDebug() << "CMD event"; // Nor does this one gets called

                break;

            case SI_DEVICE_CHANGE_EVENT:
                break;

            default:
                break;
            } /* end switch on 3DxWare event type*/
        }
    }

    return QOpenGLWidget::nativeEvent(eventType, message, result);
}
I read in this topic that I need a config file to make actions work:
viewtopic.php?f=19&t=11485

The driver automatically generated a config file for me. I manually added the XML-part at the end of the file, however the buttons still do not issue any events. I would like to attach my config file, however neither xml nor txt is accepted as file extions.

I am using 3Dware V 10.5.4.

Best regards

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

Re: Getting actions or buttons to work

Post by jwick »

Hello Axel,

Your code looks ok. Probably the cfg file being used for your application is sending the old style button events.
You can change your code to use the old style events or create a cfg for your application that uses the new style events. We'd prefer that you switched to the new style events. They are have a better future.

There is a new SDK in the works that will choose a better cfg file for you.

To use the new style events, make a copy of this file using your application name (PAC.xml?). Change the Name and ExecutableName to your app name. Save it into %PROGRAMDATA%\3Dconnexion\3DxWare\Cfg. Delete any other cfg files in %APPDATA%/3Dconnexion/3DxWare/Cfg that have your ExecutableName. Restart the driver.

This file is for the next driver version but it should work with 17.5.4.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!--
(c) Copyright 3Dconnexion. All rights reserved. 
$Revision: 12613 $

This cfg file is a starting point for ISVs that support V3DCMDs through the 3Dx SDK.

V3DCMDs are as far removed as possible from the hardware buttons that generated them.  
Any button on any device can be assigned to a V3DCMD.
Some devices will generate very few V3DCMDs because they have very few buttons.  
High end devices will generate most of them.

It is very important for all apps to use V3DCMDs instead of earlier mechanisms so they have the best chance
of working when new 3Dx devices are released.

Naturally, over time, new V3DCMDs will be added to support unforeseen functionality.
These buttons won't be supported natively until the applications are updated with the new list of V3DCMDs.  
But all other the buttons will work regardless of what physical button generates the V3DCMD.  

Generally the driver and/or 3Dx-plugins will probably do something useful with these new buttons
until the apps catch up.

-->
<AppCfg Default="true" xmlns="" CfgFormatVersion="1.2" ThisFileVersion="1.4">
  <AppInfo>
    <Signature>
      <Name>Your Application Name</Name>
      <ExecutableName>YourApplicationName.exe</ExecutableName>
      <VersionRange>
        <Min>1.0.0.0</Min>
        <Max>10.99</Max>
      </VersionRange>
      <Transport>S80</Transport>
    </Signature>
    <Options>
      <IgnoreMouseWheelInertia>true</IgnoreMouseWheelInertia>
      <SendDeviceChangeEvent>true</SendDeviceChangeEvent>
    </Options>
  </AppInfo>
  <CfgProperties>
    <Grab>None</Grab>
  </CfgProperties>
  <AuthorInfo>
    <DriverVersion>17.5.5</DriverVersion>
    <Created>
      <Tool>3DxService.exe</Tool>
      <Version>17.5.5</Version>
      <Date>2017:11:2:28:10:58:11:745</Date>
      <User>3DxCfgAdmin</User>
    </Created>
  </AuthorInfo>
  <Settings>
    <ResponseCurve>1.7</ResponseCurve>
  </Settings>
  <ButtonActions xmlns:driver_images="./images/3DxService/">
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_MENU_OPTIONS</ID>
      <Name>Your App Menu</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F1</ID>
      <Name>Your App cmd 1</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F2</ID>
      <Name>Your App cmd 2</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F3</ID>
      <Name>Your App cmd 3</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F4</ID>
      <Name>Your App cmd 4</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F5</ID>
      <Name>Your App cmd 5</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F6</ID>
      <Name>Your App cmd 6</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F7</ID>
      <Name>Your App cmd 7</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F8</ID>
      <Name>Your App cmd 8</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F9</ID>
      <Name>Your App cmd 9</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F10</ID>
      <Name>Your App cmd 10</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F11</ID>
      <Name>Your App cmd 11</Name>
    </ButtonAction>
    <ButtonAction Type="V3DCMD">
      <ID>V3DCMD_KEY_F12</ID>
      <Name>Your App cmd 12</Name>
    </ButtonAction>
	<ButtonAction Type="Menu">
		<ID>RadialMenu_SampleRM</ID>
		<Name>SampleRM</Name>
		<Image>
			<Source>[driver_images:HIDMouse_RadialMenu.png]</Source>
		</Image>
		<MenuID>MenuRM_Sample</MenuID>
	</ButtonAction>
  </ButtonActions>

  <Menus>
    <Executable>3DxPieMenus.exe</Executable>
    <Menu Type="Radial">
      <Name>SampleRM</Name>
      <ID>MenuRM_Sample</ID>
      <GesturesEnabled>true</GesturesEnabled>
      <Button>
        <Input>
          <ActionID>MenuButton_1</ActionID>
        </Input>
        <Output>
          <ActionID>V3DCMD_KEY_F1</ActionID>
        </Output>
      </Button>
      <Button>
        <Input>
          <ActionID>MenuButton_2</ActionID>
        </Input>
        <Output>
          <ActionID>V3DCMD_KEY_F2</ActionID>
        </Output>
      </Button>
      <Button>
        <Input>
          <ActionID>MenuButton_3</ActionID>
        </Input>
        <Output>
          <ActionID>V3DCMD_KEY_F3</ActionID>
        </Output>
      </Button>
      <Button>
        <Input>
          <ActionID>MenuButton_4</ActionID>
        </Input>
        <Output>
          <ActionID>V3DCMD_KEY_F4</ActionID>
        </Output>
      </Button>
    </Menu>
  </Menus>

  <Devices>
    <Device>
      <Name>Standard 3D Mouse</Name>
      <VendorID>0</VendorID>
      <ProductID>0</ProductID>
      <AxisFilter>None</AxisFilter>
      <CurrentButtonBank>Default</CurrentButtonBank>
      <ButtonBank Default="true">
        <Name>STR_DEFAULT_BUTTONBANK</Name>
        <ID>Default</ID>
        <Button>
          <Input>
            <ActionID>V3DK_MENU</ActionID>
          </Input>
          <Output>
            <ActionID>V3DCMD_MENU_OPTIONS</ActionID>
          </Output>
        </Button>
        <Button>
          <Input>
            <ActionID>V3DK_FIT</ActionID>
          </Input>
          <Output>
            <ActionID>V3DCMD_VIEW_FIT</ActionID>
          </Output>
        </Button>
		<Button>
			<Input>
				<ActionID>V3DK_TOP</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_TOP</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_LEFT</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_LEFT</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_RIGHT</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_RIGHT</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_FRONT</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_FRONT</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_BOTTOM</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_BOTTOM</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_BACK</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_BACK</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_ROLL_CW</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_ROLLCW</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_ROLL_CCW</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_ROLLCCW</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_ISO1</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_ISO1</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_ISO2</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_VIEW_ISO2</ActionID>
			</Output>
		</Button>
        <Button>
          <Input>
            <ActionID>V3DK_1</ActionID>
          </Input>
          <Output>
            <ActionID>V3DCMD_KEY_F1</ActionID>
          </Output>
        </Button>
        <Button>
          <Input>
            <ActionID>V3DK_2</ActionID>
          </Input>
          <Output>
            <ActionID>V3DCMD_KEY_F2</ActionID>
          </Output>
        </Button>
        <Button>
          <Input>
            <ActionID>V3DK_3</ActionID>
          </Input>
          <Output>
            <ActionID>V3DCMD_KEY_F3</ActionID>
          </Output>
        </Button>
        <Button>
          <Input>
            <ActionID>V3DK_4</ActionID>
          </Input>
          <Output>
            <ActionID>V3DCMD_KEY_F4</ActionID>
          </Output>
        </Button>
		<Button>
			<Input>
				<ActionID>V3DK_5</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F5</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_6</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F6</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_7</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F7</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_8</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F8</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_9</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F9</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_10</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F10</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_11</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F11</ActionID>
			</Output>
		</Button>
		<Button>
			<Input>
				<ActionID>V3DK_12</ActionID>
			</Input>
			<Output>
				<ActionID>V3DCMD_KEY_F12</ActionID>
			</Output>
		</Button>
        <Button>
          <Input>
            <ActionID>V3DK_MENU_1</ActionID>
          </Input>
          <Output>
            <ActionID>Base_RadialMenu_MenuRM1</ActionID>
          </Output>
        </Button>
        <Button>
          <Input>
            <ActionID>V3DK_MENU_2</ActionID>
          </Input>
          <Output>
            <ActionID>RadialMenu_SampleRM</ActionID>
          </Output>
        </Button>
      </ButtonBank>
    </Device>
	<Device>
		<Name>Standard 2D Mouse</Name>
		<VendorID>0</VendorID>
		<ProductID>0</ProductID>
		<AxisFilter>None</AxisFilter>
		<CurrentButtonBank>Default</CurrentButtonBank>
		<ButtonBank Default="true">
			<Name>STR_DEFAULT_BUTTONBANK</Name>
			<ID>Default</ID>
			<Button>
				<Input>
					<ActionID>V2DK_FORWARD</ActionID>
				</Input>
				<Output>
					<ActionID>V3DCMD_VIEW_QZ_IN</ActionID>
				</Output>
			</Button>
			<Button>
				<Input>
					<ActionID>V2DK_BACKWARD</ActionID>
				</Input>
				<Output>
					<ActionID>V3DCMD_VIEW_QZ_OUT</ActionID>
				</Output>
			</Button>
		</ButtonBank>
	</Device>
  </Devices>
  <UI>
	<ButtonFlyouts>
		<Category Sort="false">
			<ID>AppCommand</ID><Name>Your Application Name</Name>
			<Category>
			   <ID>App Commands</ID><Name>App Commands</Name>
			   <ButtonAction><ID>V3DCMD_MENU_OPTIONS</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F1</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F2</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F3</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F4</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F5</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F6</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F7</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F8</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F9</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F10</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F11</ID></ButtonAction>					
			   <ButtonAction><ID>V3DCMD_KEY_F12</ID></ButtonAction>					
			</Category>
		</Category>
		
		<Category Sort="false">
			<ID>UI_3Dx</ID>
			<Name>STR_UI_3DX</Name>
			<ButtonAction><ID>V3DCMD_VIEW_QZ_IN</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_QZ_OUT</ID></ButtonAction>			
		</Category>

		<Category Sort="false">
			<ID>UI_Views</ID><Name>STR_UI_VIEWS</Name>
			<ButtonAction><ID>V3DCMD_VIEW_FIT</ID></ButtonAction>					
			<ButtonAction><ID>V3DCMD_VIEW_1</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_2</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_3</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_SAVE_VIEW_1</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_SAVE_VIEW_2</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_SAVE_VIEW_3</ID></ButtonAction>										
			<ButtonAction><ID>V3DCMD_VIEW_TOP</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_LEFT</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_RIGHT</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_FRONT</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_BOTTOM</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_BACK</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_ROLLCW</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_ROLLCCW</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_ISO1</ID></ButtonAction>
			<ButtonAction><ID>V3DCMD_VIEW_ISO2</ID></ButtonAction>
		</Category>
	</ButtonFlyouts>
  </UI>
</AppCfg>
axeljaeger
Posts: 3
Joined: Sun Dec 31, 2017 7:07 am

Re: Getting actions or buttons to work

Post by axeljaeger »

Hi,
thank you for your answer. Using your provided example as base, I get the desired events now. Is there any documentation what can be configured in this file? When using the complete file, I can no longer rotate so I guess this behaviour is configured somewhere within the file?

Best regards

Axel
axeljaeger
Posts: 3
Joined: Sun Dec 31, 2017 7:07 am

Re: Getting actions or buttons to work

Post by axeljaeger »

Never mind, I just pressed lock rotate accidentally.
Terryhart
Posts: 1
Joined: Wed May 09, 2018 6:17 am

Re: Getting actions or buttons to work

Post by Terryhart »

{
if(eventType == "windows_generic_MSG") {
const MSG *msg = reinterpret_cast<MSG *>(message);
SiGetEventData eData; /* Platform-specific event data */
SiSpwEvent siEvent; /* 3DxWare data event */

SiGetEventWinInit (&eData, msg->message, msg->wParam,
msg->lParam);
if (SiGetEvent (m_hdl, 0, &eData, &siEvent) == SI_IS_EVENT)
Post Reply