We did though, realize that we couldn't begin to predict all the wonderful uses people can imagine for our devices. In some cases, there is no way to configure the driver to do what is wanted. For these cases, we implemented an extension mechanism.
The extension mechanism allows the user to define an action for any axis or button that invokes an executable, script, batch file or a function from a DLL. In those actions, the savvy user can do anything he can imagine.
There is currently no support in the 3DxConfig GUI for making these definitions. The profile for the application must be edited, using notepad or some other XML editor.
A three or four step process is required.
Step 1: Using 3DxConfig->Add Profile, create and save a user profile for your application.
Step 2: Using an XML editor (notepad works fine), open that user profile (under %APPDATA%\3Dconnexion\3DxWare\Cfg) and create a ButtonAction or AxisAction that defines what will get called when input happens.
Step 3: Using 3DxConfig again, assign that ButtonAction or AxisAction to a button or axis on your device.
Step 4: If required, write the DLL function, script, batch file, etc.
A couple of examples may help:
If you want to start Outlook.exe when the user presses a 3D mouse button.
Step 2: Using notepad, create a new ButtonAction:
- Code: Select all
<ButtonAction Type="EXE">
<ID>MyStartOutlookButtonAction</ID>
<Name>Start Outlook</Name>
<Executable>Outlook.exe</Executable>
<Arg>None</Arg>
</ButtonAction>
If you like, you can add an argument instead of None in the Arg field.
Step 3: Assign "Start Outlook" to a button using 3DxConfig.
When the application using this profile is in focus, Outlook will be started when you press the button this ButtonAction is assigned to.
Another sample illustrates the way you would execute code. If for instance, you want to send a Left Mouse Button Press when you pressed down on the 3D mouse cap. I know of no way of doing this with a simple batch file or executable. Fortunately, there is a Windows API function named SendInput that allows you to inject events into the event queue of an application. You can invoke this API function by writing a small C/C++ function. If you put this function into a DLL, 3DxService can call that function when you press down on the device cap.
Step 2: Define a DLL AxisAction:
- Code: Select all
<AxisAction Type="DLL">
<ID>MySendLeftMouseButtonAxisAction</ID>
<Name>Send Left Mouse Button</Name>
<Executable>MyWinAPIUtilities.DLL</Executable>
<Function>SendLeftMouseButtonEvent</Function>
<Arg>HIDID</Arg>
</AxisAction>
In this case, the Arg HIDID tells 3DxService to pass information about the event that happened to the function. The information consists of string arguments with the axis name and the axis value.
You can either specify the full path to the DLL, put it in your PATH, or put it in the 3DxWinCore{32|64}/Win{32|64}/DLLs subdirectory.
Step 3: Assign this new AxisAction to the Up/Down (Z) axis of your device in 3DxConfig.
Step 4: Create the MyWinAPIUtilities DLL and write the SendLeftMouseButtonEvent function that calls SendInput.
I suggest you only send the mouse button press if you get a very large positive value, or you will be sending it all the time.
The function has to be exported as a non-decorated C style name or 3DxService won't be able to locate it. Send a message to apisupport-win <at> 3dconnexion.com if you want a sample to start with.
This mechanism only exists on Windows.
Have fun. Let us know what interesting things you do with the extension mechanism.

