SpaceControl DLL
Version 2.8.9
API documentation for the SpaceControl 3D input devices
|
These functions are used to handle with a device in a more general way as in the other sections. More...
Functions | |
ScStatus | scGetDevNum (int *devNumP, int *usedDevNumP, int *maxDevIdxP) |
Retrieves the number devNum of SpaceControl devices actually connected to the computer, the number usedDevNum of SpaceControl devices actually used by the driver and the maximal device index maxDevIdx a device may be addressed with at the moment. More... | |
ScStatus | scGetDevInfo (int devIdx, ScDevInfo *diP) |
Retrieves some information data about the device with the given index. More... | |
ScStatus | scGetDefDevPars (int devIdx, ScDevPars *dpP) |
Retrieves the default values of the device parameters. More... | |
ScStatus | scGetDevPars (int devIdx, ScDevPars *dpP) |
Retrieves the actual device parameters as listed in the *.cfg files. More... | |
ScStatus | scSetDevPars (int devIdx, ScDevPars *dpP) |
Sets and retrieves the actual device parameters as listed in the device's configuration file. More... | |
ScStatus | scSetDevParsToDefaults (int devIdx, ScDevPars *dpP) |
Sets the actual device parameters to the defaults and retrieves the new parameters. More... | |
ScStatus | scFetchStdData (int devIdx, short *xP, short *yP, short *zP, short *aP, short *bP, short *cP, int *traLmhP, int *rotLmhP, int *eventP, long *tvSecP, long *tvUsecP) |
Fetches the standard data set. More... | |
ScStatus | scTransferCallbackFunction (int devIdx, stdDataCallbackP cbP) |
This function hands over a callback function pointer to the API. More... | |
ScStatus | scGetRawData (int devIdx, unsigned char buf[RAW_DATA_LEN]) |
The opto-electronical sensor integrated into the cap consists of six LEDs illuminating six position sensitive devices (PSD) producing data between 0 and 1023. More... | |
ScStatus | scGetCfgFilename (int devIdx, char *filename) |
Retrieves the name and path of the device's actual configuration file. More... | |
ScStatus | scSaveDevPars (int devIdx, char *filePath) |
Saves the actual parameters of the device with index devIdx to the configuration file given in filePath. More... | |
ScStatus | scLoadDevPars (int devIdx, char *filePath, ScDevPars *dpP) |
Loads the parameters in the configuration file given in filePath into the device with index devIdx. More... | |
ScStatus | scPressKey (int devIdx, int key) |
Triggers the same action as is done when a key of the device is pressed, i. More... | |
ScStatus | scRelKey (int devIdx, int key) |
Triggers the same action as is done when a key of the device is released. More... | |
ScStatus | scTriggerFunction (int devIdx, int funcIdx) |
Triggers the function with index funcIdx. More... | |
ScStatus | scGetFmwUpdtState (int devIdx, int *mcuIdP, int *progressP) |
Retrieves the state of a firmware update in progress. More... | |
ScStatus | scExecCmd (int devIdx, char *cmd) |
Executes a special command. More... | |
These functions are used to handle with a device in a more general way as in the other sections.
ScStatus scExecCmd | ( | int | devIdx, |
char * | cmd | ||
) |
Executes a special command.
To avoid an extensive growing of API functions this function can be used to execute different commands. It is made for SpaceControl's internal use rather than for the common audience. A special syntax is needed for the command buffer:
The first character is the command identifier. The content of the others depends on the first one. For the time being the following command is defined only:
devIdx | the index of the device (if needed, -1 in other cases) |
cmd | the command with optional parameters |
References SC_COMMUNICATION_ERROR.
ScStatus scFetchStdData | ( | int | devIdx, |
short * | xP, | ||
short * | yP, | ||
short * | zP, | ||
short * | aP, | ||
short * | bP, | ||
short * | cP, | ||
int * | traLmhP, | ||
int * | rotLmhP, | ||
int * | eventP, | ||
long * | tvSecP, | ||
long * | tvUsecP | ||
) |
Fetches the standard data set.
The device sends the standard data without request. These data can be fetched with this command. scFetchStdData() will wait 30 ms (this can be changed with the parameter mSendDelay of structure ScAdvancedSettings) if no data is delivered and then return with ScStatus SC_COMMUNICATION_ERROR. This is no real error in that case. Since the data is not actively requested you will get SC_COMMUNICATION_ERROR also in case of a wrong device index > 0; a device index < 0 will result in SC_WRONG_DEVICE_INDEX
The standard data consist out of:
Example:
devIdx | the index of the device to be requested |
xP | pointer to the x coordinate |
yP | pointer to the y coordinate |
zP | pointer to the z coordinate |
aP | pointer to the rotation around the x-axis |
bP | pointer to the rotation around the y-axis |
cP | pointer to the rotation around the z-axis |
traLmhP | pointer to the low-, mid- and high-flags of translation |
rotLmhP | pointer to the low-, mid- and high-flags of rotation |
eventP | pointer to an event no.; events may be signaled at any time |
tvSecP | pointer to the time the message was generated by the driver: seconds elapsed since jan 01 1970 UTC |
tvUsecP | pointer to the time the message was generated by the driver: additional microseconds since *tvSecP |
References SC_OK, and SC_WRONG_DEVICE_INDEX.
ScStatus scGetCfgFilename | ( | int | devIdx, |
char * | filename | ||
) |
Retrieves the name and path of the device's actual configuration file.
The configuration file is located in the user's home directory in the folder 'SpaceController'. The folder SpaceController contains a set of folders whose names are constructed out of the serial numbers of all the devices connected to the computer in the past. Each of these folders contain a set of configuration files which are loaded alternatively dependent on the application controlled by the device.
Example:
devIdx | the index of the device to be requested |
filename | file name, e.g. /home/fs/spacecontrol/[serialNo]/last.cfg |
References MAX_FILENAME_LEN, SC_COMMUNICATION_ERROR, SC_OK, and SC_WRONG_DEVICE_INDEX.
ScStatus scGetDefDevPars | ( | int | devIdx, |
ScDevPars * | dpP | ||
) |
Retrieves the default values of the device parameters.
Example:
devIdx | index of the device the parameters are requested |
dpP | pointer to the device parameters to be retrieved |
References SC_COMMUNICATION_ERROR, SC_OK, and SC_WRONG_DEVICE_INDEX.
Retrieves some information data about the device with the given index.
Example:
devIdx | index of the device the infos are requested |
diP | pointer to the retrieved device info |
References SC_COMMUNICATION_ERROR, SC_OK, SC_WRONG_DEVICE_INDEX, ScDevInfo::setDescrptn(), ScDevInfo::setId(), and ScDevInfo::setSerialNo().
ScStatus scGetDevNum | ( | int * | devNumP, |
int * | usedDevNumP, | ||
int * | maxDevIdxP | ||
) |
Retrieves the number devNum of SpaceControl devices actually connected to the computer, the number usedDevNum of SpaceControl devices actually used by the driver and the maximal device index maxDevIdx a device may be addressed with at the moment.
All devices are stored in an array; to address a device all DLL functions need the index in this array, and the indices are in the range 0..maxDevIdx. If a device is disconnected from the computer the array element is set to NULL but not removed out of the array (this behaviour ensures that an index does not change if another device is disconnected from the computer). Therefore maxDevIdx may be greater than devNum-1.
After getting maxDevIdx one can use function scGetDevInfo() to get the description or serial number of a device to identify it for further calls.
You can plug in more than one device into your computer. But, the driver is able to receive data from more than one device only if there is a "Master" device connected. Therefore there might be a difference between the values devNum and usedDevNum: devNum is the number of devices plugged in actually, usedDevNum is the number of devices actually used. These values are the same only if there is at least one master device connected, if not usedDevNum has the value 1 or 0.
Update: From driver version 2.4.0 on a master device is not necessary any longer to use more than one device. All hints concerning master devices in this document are obsolet therefore. Example:
devNumP | number of devices connected to the computer |
usedDevNumP | number of devices used by the driver (equals devNum only if there is a master device, is 0 or 1 otherwise) |
maxDevIdxP | biggest index of a device connected to the computer |
References SC_COMMUNICATION_ERROR, and SC_OK.
ScStatus scGetDevPars | ( | int | devIdx, |
ScDevPars * | dpP | ||
) |
Retrieves the actual device parameters as listed in the *.cfg files.
Example:
devIdx | index of the device the parameters are requested |
dpP | pointer to the device parameters to be retrieved |
References SC_COMMUNICATION_ERROR, SC_OK, and SC_WRONG_DEVICE_INDEX.
ScStatus scGetFmwUpdtState | ( | int | devIdx, |
int * | mcuIdP, | ||
int * | progressP | ||
) |
Retrieves the state of a firmware update in progress.
The SpaceController contains three micro controllers (MCU):
A firmware file is a zipped file with the extension "fmw" that contains the three files KMM.hex, KSM.hex and KDM.hex. If the user initiates a firmware update via the GUI the firmware file is unzipped, and the three hex files are written into the controllers' flash memory. The actual state can be retrieved with this command. If mcuId is < 0 an error has occured. Example:
devIdx | the index of the device to be requested |
mcuIdP | the ID of the micro controller just updating ( 0: no update in progress, 1: mainboard microcontroller is updating, 2: display microcontroller is updating, 4: sensor microcontroller is updating, -1: error while updating mainboard MCU, -2: error while updating display MCU, -4: error while updating sensor MCU) |
progressP | the update sequence's progress of one of the three micro controllers in percent (-1..100, -1 means error) |
References SC_COMMUNICATION_ERROR, SC_OK, and SC_WRONG_DEVICE_INDEX.
ScStatus scGetRawData | ( | int | devIdx, |
unsigned char | buf[RAW_DATA_LEN] | ||
) |
The opto-electronical sensor integrated into the cap consists of six LEDs illuminating six position sensitive devices (PSD) producing data between 0 and 1023.
These raw data can be requested here. Using this function is not recommended, use scFetchStdData() instead. The function returns a buffer of 28 unsigned characters with the following content:
devIdx | the index of the device to be requested |
buf | data buffer containing the result |
References RAW_DATA_LEN, SC_COMMUNICATION_ERROR, SC_OK, and SC_WRONG_DEVICE_INDEX.
ScStatus scLoadDevPars | ( | int | devIdx, |
char * | filePath, | ||
ScDevPars * | dpP | ||
) |
Loads the parameters in the configuration file given in filePath into the device with index devIdx.
Example:
devIdx | the index of the device |
filePath | file name, e.g. /home/fs/my.cfg |
dpP | pointer to the device parameter structure |
References SC_COMMUNICATION_ERROR, SC_OK, and SC_WRONG_DEVICE_INDEX.
ScStatus scPressKey | ( | int | devIdx, |
int | key | ||
) |
Triggers the same action as is done when a key of the device is pressed, i.
e. a macro assigned to the key is executed.
Example:
devIdx | index of the device the key seems to be pressed |
key | the key's index (0..16) |
References MAX_KEY_IDX, SC_COMMUNICATION_ERROR, SC_KEYSTROKE_ERROR, SC_OK, SC_PARAMETER_OUT_OF_RANGE, and SC_WRONG_DEVICE_INDEX.
ScStatus scRelKey | ( | int | devIdx, |
int | key | ||
) |
Triggers the same action as is done when a key of the device is released.
Example:
devIdx | index of the device the key seems to be released |
key | the key's index (0..16) |
References MAX_KEY_IDX, SC_COMMUNICATION_ERROR, SC_KEYSTROKE_ERROR, SC_OK, SC_PARAMETER_OUT_OF_RANGE, and SC_WRONG_DEVICE_INDEX.
ScStatus scSaveDevPars | ( | int | devIdx, |
char * | filePath | ||
) |
Saves the actual parameters of the device with index devIdx to the configuration file given in filePath.
Example:
devIdx | the index of the device |
filePath | file name, e.g. /home/fs/spacecontroller/[serialNo]/last.cfg |
References SC_COMMUNICATION_ERROR.
ScStatus scSetDevPars | ( | int | devIdx, |
ScDevPars * | dpP | ||
) |
Sets and retrieves the actual device parameters as listed in the device's configuration file.
Example:
devIdx | index of the device the parameters are requested |
dpP | pointer to the device parameters to be retrieved |
References SC_COMMUNICATION_ERROR, SC_OK, SC_PARAMETER_OUT_OF_RANGE, and SC_WRONG_DEVICE_INDEX.
ScStatus scSetDevParsToDefaults | ( | int | devIdx, |
ScDevPars * | dpP | ||
) |
Sets the actual device parameters to the defaults and retrieves the new parameters.
Example:
devIdx | index of the device the parameters are to be set |
dpP | pointer to the device parameters to be retrieved |
References SC_COMMUNICATION_ERROR, SC_OK, SC_PARAMETER_OUT_OF_RANGE, and SC_WRONG_DEVICE_INDEX.
ScStatus scTransferCallbackFunction | ( | int | devIdx, |
stdDataCallbackP | cbP | ||
) |
This function hands over a callback function pointer to the API.
The callback function is called automatically as soon as a new data packet is available and gets the data packet into its parameters.
Since scFetchStdData() waits for 30 ms if no data is present you may observe a significant slow down in your application when calling it in a loop (as is necessary in most applications). This must be avoided by executing this loop in a separate thread.
If you are not used to handling threads scTransferCallbackFunction() may be an alternative: It creates two threads for you; the first one reads the data packets from the device [using scFetchStdData()] in a loop, the second one looks for new data packets and calls your callback function as soon as new data is available. This design avoids time lags even if your callback function needs more time to execute than the time between two data packets. If one or more data packets arrive before your callback function returns only the last data packet is transmitted in the next call, the other packets are ignored in this case.
Your callback function must have the following signature:
I. e. it is nearly the same as in scFetchStdData() (see documentation there), only the first parameter, the device index, is omitted. This is because you will need your own callback function for each device (if more than one is connected), and you have to assign your callback to the device explicitly by handing over the device index together with your callback function when registrating it with scTransferCallbackFunction(). In most cases you have only one device connected, and devIdx is 0.
Example:
To stop the created threads call scTransferCallbackFunction() again with the same devIdx but with NULL as function pointer.
Calling scDisconnect() will also stop the Threads.
A complete minimal sample application is shown in section 2.2 Threads.
devIdx | the index of the device the callback function gets data from |
cbP | your callback function; it is called each time new data is received from the device with index devIdx; if NULL is handed over a former transfered callback function is removed |
ScStatus scTriggerFunction | ( | int | devIdx, |
int | funcIdx | ||
) |
Triggers the function with index funcIdx.
The functions are listed in the function tree in the SpaceControl Panel's "Function Assignment" dialog, and in the configuration file for the foreground application (e. g. "C:\Users\SpaceController\Devices\<SerialNo>\common.cfg") in section [FUNCTIONS]. They start with index 0.
Example:
devIdx | index of the device (has its own configuration file, therefore has its own list of functions) |
funcIdx | the function index |
References SC_COMMUNICATION_ERROR, SC_OK, SC_PARAMETER_OUT_OF_RANGE, and SC_WRONG_DEVICE_INDEX.
Copyright (c) SpaceControl GmbH & Co. KG, Am Technologiepark 10, D-82229 Seefeld |