1. Prerequisites
- Download the DLL/headers zip file: C++ v1.5.1 SDK
Note: The C++ API is a collection of DLL and headers for 64-bit and 32-bit Windows 10. If you require a more in-depth Visual Studio project example this is something that we can make available. The instructions below give directions on how a developer can integrate our files with 2 different methods of DLL integration and use the Data Glove API functions.
2. Dynamically Loading the Data Glove API DLL
Since many environments have their own unique functions for loading a DLL built on Windows, the implementation of dynamically loading a DLL can change slightly from environment to environment, but the same basic steps are required in each case.
Step 1: Load the Data Glove API DLL with a given filepath
Here are a few examples of loading a dll in different environment APIs:
- Unreal Engine: FPlatformProcess::GetDllHandle(filepath);
- Qt: QLibrary lib = new QLibrary(filepath)
- Windows: win32 API: LoadLibraryA(filepath)
Step 2: Create some function definitions and declare them
Based on the DataGloveAPI.h header file, a function definition can be created by copying the parameters and return type. Here are some functions to give you an idea of what to do:
Typedefs for API:
- typedef void (*DataGloveIO) (void*);
- typedef DataGloveIO* (*CreateDataGloveIO) (byte handType, const char* name);
- typedef byte (*DestroyDataGloveIO) (DataGloveIO* dgIO);
- typedef float* (*GetSensors) (DataGloveIO* dgIO);
- typedef short* (*GetIMU) (DataGloveIO* dgIO);
- typedef float (*GetBatteryLevel) (DataGloveIO* dgIO);
- typedef byte (*GetConnectionState) (DataGloveIO* dgIO);
- typedef byte (*GetHandType) (DataGloveIO* dgIO);
- typedef byte* (*GetDeviceInfo) (DataGloveIO* dgIO, byte infoKey);
- typedef void (*Calibrate) (DataGloveIO* dgIO, byte calibrationKey, byte slot);
- typedef void (*Haptics) (DataGloveIO* dgIO, byte functionKey, float* params);
- typedef byte (*UploadFile) (DataGloveIO* dgIO, const char* filename, byte uploadSlot);
- typedef void (*EnterBootloader) (DataGloveIO* dgIO);
- typedef void (*SetGloveID) (DataGloveIO* dgIO, byte a1, byte a2, byte a3, byte a4);
- typedef byte* (*GetFullReport) (DataGloveIO* dgIO);
- typedef byte* (*HomeIMU) (DataGloveIO* dgIO);
Declarations:
- CreateDataGloveIO createDataGloveIO;
- DestroyDataGloveIO destroyDataGloveIO;
- GetSensors getSensors_DLL;
- GetIMU getIMU_DLL;
- GetBatteryLevel getBatteryLevel;
- GetConnectionState getConnectionState;
- GetConnectionState getHandType;
- GetDeviceInfo getDeviceInfo;
- Calibrate calibrate;
- Haptics haptics;
- UploadFile uploadFile_DLL;
- EnterBootloader enterBootloader;
- SetGloveID setGloveID;
- GetFullReport getFullReport;
- HomeIMU homeIMU;
Step 3: Link the functions from the DLL with the declared variables
Again, each environment has its own unique way of finding a function, so here’s an example from Qt and Unreal.
Qt:
createDataGloveIO = CreateDataGloveIO(lib->resolve(“Forte_CreateDataGloveIO”));
getSensors_DLL = GetSensors(lib->resolve(“Forte_GetSensors”));
Unreal:
createDataGloveIO = CreateDataGloveIO(FPlatformProcess::GetDllExport(dllHandle, *FString(“Forte_CreateDataGloveIO”)));
getSensors_DLL = GetSensors(FPlatformProcess::GetDllExport(dllHandle,
Step 4: Call the functions
DataGloveIO* dataGloveIO = createDataGloveIO(2, name);
float* sensorsDLL = getSensors_DLL(dataGloveIO);
3. Statically Linking the Data Glove API DLL
TBA