SpaceControl DLL
Version 2.8.9
API documentation for the SpaceControl 3D input devices
|
A SpaceController is a device like a mouse for manipulating objects on a computer screen. In difference to a mouse the SpaceController has six degrees of freedom: translation in all three axes of space (x, y, z) and rotation around all of these axes. Therefore the SpaceController is the ideal equipment for moving and rotating objects in virtual 3D environments like CAD applications or moving the camera in GoogleEarth e. g.
Necessary for operation is the SpaceControl software. Basically this is a background process (the "SC-Daemon") which fetches the data produced by the device and delivers it to the applications interested in the data. Furthermore it reads the configuration data from a file, sends the data to the device during the initializing process and configures the device when the user changes the parameters with the user interface ("SC-GUI").
To enable other applications getting data from and writing data to the SpaceController the SC-Daemon provides an application programming interface, the SC-API. You just have to include the API's header file spc_ctrlr.h into your sources and link the SC-DLL (files "spc_ctrlr_32.dll" and "spc_ctrlr_64.dll" under Windows, or the shared library files "libspcctrlr32.so" and "libspcctrlr64.so" under Linux, or the dynamic library files "libspc_ctrlr_32.dylib" and "libspc_ctrlr_64.dylib" under OS X) to your application to have access to a set of functions described in this document.
If using Microsoft's Visual Studio you will need to generate library files for linking the SC-DLL. This is done by the commands
For other compilers look into their documentation how to generate the library files.
The minimal application to see data from the device is shown here (without error checking):
The more detailed example for getting or sending data from/to the SC-Daemon follows below; you have to perform these steps:
These steps are shown in the following example (for a detailed list of all API functions see spc_ctrlr.h.):
You may get some logging output besides the couts given above. This is generated by some API's internal functions and could be configured with the spc_ctrlr_dll.ini file in your home directory.
Notice that scFetchStdData() will wait 30 ms (this delay can be configured with the user interface) and return with status SC_COMMUNICATION_ERROR if the cap is not moved or no key is pressed in this time. This is no true error in this case.
Hint: The SC-Daemon monitors the desktop and is able to send data to all connected applications or to the one in the foreground only. This mechanism is controlled by setting the first parameter of scConnect2() to true or false. If set to true the data is sent to all connected applications even if they are not in the foreground; if set to false only the foreground application will get data. And there can arise a problem because another application may be in the foreground as you might expect: If you start your program from within a console the console is the foreground process and not your application! If the parameter is set to false your application will not receive the data therefore. The same may happen if your application is started within a development environment like Visual Studio. To avoid this start your application directly via double click out of an Explorer window.
As said scFetchStdData() pauses your application for 30 ms if no data is there. This may cause a significant slow down of your application. To avoid this you should put the call into a separate thread. Since thread creation and handling differs a lot in Windows on one side and Linux and OS X on the other the sample code is not printed here; see the sample project "sc_test_thread" mentioned in section 6 below instead.
If you do not need the flexibility in creating your own thread you can let the SC-API do this for you. In this case you have to provide a callback function for each connected device which is called automatically each time a new data packet from the device is received. The device's data packet is handed over in the parameters. The minimal application using that approach is this:
When calling scTransferCallbackFunction() the API creates two threads. The first one reads the data from the device, the second one calls your callback function as soon as new data is available. This design avoids time lags if your callback function needs more time than the time between two data packets. In this case some data packets may be ignored.
Each API function returns a status code out of the enumeration ScStatus. The status codes are as follows:
When using the SpaceControl DLLs your application will become hooked on them. But it is not a good idea to link them statically to your code and deliver the DLLs with your application: Your customer may install a new SpaceControl driver software expecting newer DLLs. (We try to make newer versions as compatible as possible with older releases, but 100 percent compatibility can not be guaranteed.) Therefore it is much better to use the DLLs delivered with our driver installer.
This can be achieved by loading the DLLs dynmically using the Windows API function LoadLibrary(). Before doing this you should check if the SpaceControl driver is installed and if yes where. This can be done by checking the Windows registry key "HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\sc_daemon.exe"; its value is the SpaceControl driver's installation folder, the DLLs are located in the subfolders "libs\win32" and "libs\win64" in it.
The folders' paths are added additionally to the environment variable PATH by our installer. Windows is able to find the DLLs by itself and just linking the libraries to your code [rather than calling LoadLibrary()] will also work therefore.
Some applications are even better ingegrated: They provide their menu structure for displaying it in the SpaceControl's Control Panel and for using it to redefine the SpaceController's keys with the application's menu items (as done by our plug-ins). This is not possible with the information given here. Furthermore, the daemon must be aware of such plug-ins. If you want to integrate your application in such deepness, please, contact our support.
In the installation folder ("C:\Program Files (x86)\SpaceControl" under Windows if not changed) you will find the file "SC_SDK_samples.zip". It contains a Workspace with three sample projects, created with Visual Studio 2008 (Windows driver), Xcode 5 (OS X driver) or Netbeans 7.4 (Linux driver):
16 August 2017, Version 2.8.9:
9 March 2016, Version 2.8.3:
15 July 2015, Version 2.8.1:
5 November 2014, Version 2.7.0:
16 July 2014, Version 2.6.3:
16 January 2014, Version 2.6.1:
10 April 2013, Version 2.5.1:
12 September 2012, Version 2.3.2:
24 November 2011, Version 2.2.1:
15 July 2011, Version 2.1.2:
1 February 2011, Version 2.0.0:
5 October 2010, Version 1.4.3 beta:
20 April 2010, Version 1.4.0:
15 January 2010, Version 1.2.1:
15 June 2009, Version 1.1.1:
17 March 2009, Version 1.0.1:
Copyright (c) SpaceControl GmbH & Co. KG, Am Technologiepark 10, D-82229 Seefeld |