Settings API

All UPDD driver and device settings are held in a single settings store, as described in How UPDD settings work. UPDD client programs can read and change these settings using the API functions described in this document, which apply to UPDD V6 and V7 on all platforms.

UPDD settings are "sparsely populated", meaning that in many cases there is no value and the software uses an implied default. Generally this does not cause any issue, as settings in use generally have a value, but where they do not, the default definition is rather loose: defaults are hard coded in the UPDD software, and the published settings documentation is for reference only. In practice, for settings that give a blank value a sensible default should be assumed.

The settings APIs implemented in October 2018 allow for getting all possible settings as opposed to those currently defined.

A device handle of 0 addresses the global (nodevice) settings.

Reading and writing settings

A set of functions to set and retrieve UPDD settings:

TBBOOL TBAPI TBApiGetSetting(HTBDEVICE aHandle, const TBCHAR* aName, TBCHAR* aSZ, int lBuff);
TBBOOL TBAPI TBApiGetSettingAsInt(HTBDEVICE aHandle, const TBCHAR* aName, int32_t* val);
TBBOOL TBAPI TBApiSetSetting(HTBDEVICE aHandle, const TBCHAR* aName, const TBCHAR* aSZ, TBBOOL aDeviceSpecific);
TBBOOL TBAPI TBApiSetSettingFromInt(HTBDEVICE aHandle, const TBCHAR* aName, int32_t val, TBBOOL aDeviceSpecific);

// remove a setting
TBBOOL TBAPI TBApiRemove(HTBDEVICE aHandle, const TBCHAR* aName);

// get the length of buffer needed to hold any setting as a NULL terminated string
TBBOOL TBAPI TBApiGetSettingSize(HTBDEVICE aHandle, const TBCHAR* aName, int* lBuff);
TBBOOL TBAPI TBApiGetControllerSettingSize(HTBDEVICE aHandle, const TBCHAR* aName, int* lBuff);

Calls to the set functions are effective immediately.

Controller defaults

These variants work on the default settings of a controller type rather than a specific installed instance of the controller:

// this variant retrieves the default setting for the controller type as opposed to a specific installed instance of the controller
TBBOOL TBAPI TBApiGetControllerSetting(int aControllerHandle, const TBCHAR* aName, TBCHAR* aSZ, int lBuff);

// set the default value of a setting for a specified controller handle
// controller handle can be "*" for all controllers
// any non-default value is cleared, i.e. this value becomes effective for any device instances of this controller type
TBBOOL TBAPI TBApiSetDefault(const TBCHAR* aController, const TBCHAR*  aSetting, const TBCHAR* aValue);

Listing settings

TBApiGetSettings gets the names of all settings matching a pattern. TBApiGetSettingByIndex is an alternative means to retrieve settings, and values, that is more performant than TBApiGetSetting and its variants.

// get the names of all settings matching a pattern
//  aIncludeUnused: if true (1) indicates that all known matching names are to be returned as opposed to those currently used in the package
//  if a null value is passed for aSZ, the return value addressed by lBuff will be set to the required buffer size
// the list of names is returned as a multi line string (separated by '\n' characters)
TBBOOL TBAPI TBApiGetSettings(HTBDEVICE aHandle, TBBOOL aIncludeUnused, const TBCHAR* aPattern, TBCHAR* aSZ, int* lBuff);

// an alternate means to retrieve settings
// this implementation is more performant than TBApiGetSetting and its variants
// all values that match aPattern are retrieved in one call to the driver when aIndex == 0
// the internal storage is released when aIndex >= number of values
// so it is important to always start with aIndex=0
// due to the cached storage this function is NOT thread safe
// a previous cache allocation will be deleted if aIndex == 0
// when aIndex == number of values TRUE is returned and an empty string is given in aName and aValue
// in the event that the buffers passed are too small for a name or value FALSE is returned
// and TBApiGetLastError will give "Error: Insufficient buffer size"
TBBOOL TBAPI TBApiGetSettingByIndex(HTBDEVICE aHandle, const TBCHAR* aPattern, uint16_t aIndex, TBCHAR* aName, int lName, TBCHAR* aValue, int lValue);

For example, to print all nodevice settings starting with "m":

char name[256];
char value[1024];
for (unsigned n = 0; ; n++)
{
  if (!TBApiGetSettingByIndex(0, "m*", n,  name, sizeof(name), value, sizeof(value)))
  {
    char msg[1024];
    TBApiGetLastError(msg, sizeof(msg));
    cerr << msg << endl;
    break;
  }
  if (!strlen(name))
  {
    break;
  }
  cout << name << ": " << value << endl;
}

Setting help text

Get the help text associated with a named setting:

//  if a null value is passed for aSZ, the return value addressed by lBuff will be set to the required buffer size
TBBOOL TBAPI TBApiGetSettingHelp(const TBCHAR* aName, TBCHAR* aSZ, int* lBuff);

Exporting and importing settings

Settings can be exported to a file and imported from it:

// export settings
// aDevices is a comma separated list of device handles to support OR * for all real (non zero) devices OR ** for all devices + NODEVICE
// aNames is a comma separated list of setting names to export; can use standard wildcard characters * or ?
// aTargetFileName is the path to the export file
// aFailIfExists if true and the target file exists the API call will fail (return false)
TBBOOL TBAPI TBApiExportSettings(const TBCHAR* aDevices, const TBCHAR* aNames, const TBCHAR* aTargetFileName, TBBOOL aFailIfExists);

// import settings previously exported by TBApiExportSettings
// aSourceFileName is the path to the import file
TBBOOL TBAPI TBApiImportSettings(const TBCHAR* aSourceFileName);

Bootstrap settings and reset

TBApiGetBootstrapSetting reads a setting from the bootstrap file updd.ini, given the section and setting name. It is available before a driver connection is available.

TBApiResetSettings resets settings to their original values, excluding reserved values such as registration, device binding, internal (private.*) values and device counts.

void TBAPI TBApiGetBootstrapSetting(const TBCHAR* aSection, const TBCHAR* aName, TBCHAR* aSZ, int lBuff);
TBBOOL TBAPI TBApiResetSettings();

Sharing touch: active_touch_interface

The device setting active_touch_interface indicates the system interface associated with this device.

This setting is blank by default, so that the driver automatically uses one of the touch interfaces it supports to post touch data.

If you are writing an application that wants to handle the touch for this device, change this value to an arbitrary value, unknown to the driver, so that the driver will not post touch data received from the device into the operating system.

If your application is going to change this setting, observe these rules:

  1. Only set this value if it is blank, or currently set to a value the current program might set, or this is an explicit request from a user action (changing a setting in a dialog, for example).
  2. Set this value to a relevant value (e.g. xxxx) if the current program intends to pass touch actions to the operating system (but observe rule 1).
  3. Set this value to a relevant value (e.g. xxxx-disabled) if the current program can pass touch actions to the operating system but this option is not currently enabled (but observe rule 1).
  4. Only pass touch events to the operating system if the value of this setting is that in rule 2.

Observing these rules allows multiple programs to co-exist.