How to use raw Windows C API - TalonRing/Talon-DevKit GitHub Wiki
- x86 -
Assets/TalonSDK/Plugins/x86/TalonSDK.dll
- x86_64 -
Assets/TalonSDK/Plugins/x86_64/TalonSDK.dll
#pragma once
#ifdef TALON_EXPORTS
#define TALON_API __declspec(dllexport)
#else
#define TALON_API __declspec(dllimport)
#endif
extern "C"
{
typedef void(*TalonCallback)(const char * event, const char* deviceId);
TALON_API void talon_init(TalonCallback callback, uint8_t config, uint8_t period);
TALON_API void talon_destroy();
TALON_API void talon_scan();
TALON_API void talon_connect(const char* deviceId);
TALON_API void talon_config(const char* deviceId, uint8_t config);
TALON_API float* talon_orientation(const char* deviceId);
TALON_API float* talon_accel(const char* deviceId);
TALON_API float* talon_gyro(const char* deviceId);
TALON_API float* talon_mag(const char* deviceId);
TALON_API bool talon_button(const char* deviceId, int btn);
TALON_API bool talon_tapped(const char* deviceId);
TALON_API bool talon_recentered(const char* deviceId);
TALON_API int talon_battery(const char* deviceId);
}
Create a TalonSDK instance
- config
Initial configuration for Talon Ring
* bit 0: sensor switch - 0: off, 1: on
* bit 1: sensor raw data - 0: disable, 1: enable raw sensor data
* bit 2: low power mode - 0: off, 1: on
* bit 3: sleep mode - 0: disable, 1: enable 60s
* bit 4: ring mode - 0: fist, 1: palm
* bit 5: handedness - 0: right, 1: left
* bit 6-7: n.a
- period Sensor update period
* range: 1 – 50hz
* default: 20hz
Destroy current instance
Scan nearby TalonRing devices
Connect TalonRing by device ID.
Dynamic update TalonRing config
Get TalonRing orientation
Get TalonRing accelerometer
Get TalonRing gyroscope
Get TalonRing magnetometer
Get TalonRing button state
Check if TalonRing tapped
Check if TalonRing recentered
Get TalonRing battery level
- event
"onDiscovered"
"onConnected"
"onDisconnected"
- deviceId
- TalonRing deviceId
#include "stdafx.h"
#include <string>
#include "TalonSDK.h"
void callback(const char* event, const char* deviceId)
{
if (strcmp(event, "onDiscovered") == 0)
{
talon_connect(deviceId);
}
}
int main()
{
talon_init(callback, 0x01, 20);
talon_scan();
getchar();
talon_destroy();
return 0;
}
For more about how to use the APIs, please check out C# code for reference