C++ DLL - Windows
Introduction
This DLL allows Windows devices to connect to Lovense toys and send control commands using C/C++/C#.
The latest version of the current dll is V1.0, click to view version records, Download Link: LovenseBLE_Lib.dll
Compatibility
Windows Version: >= Win10
A Bluetooth adapter is required.
Functions Exposed from DLL
1. _CheckBLEStatus()
Checks the current BLE status of the computer. Triggers the CheckBLECallback (if registered via _RegisterCheckBLECallback).
2. _StartBLEScan()
Starts scanning. If a toy is detected, it triggers the ToyAddCallback (if registered via _RegisterToyAddCallback).
3. _StopBLEScan()
Stops scanning. Once stopped, it triggers the NotifyCallback (if registered via _RegisterNotifyCallback).
4. _Quit()
Releases Bluetooth resources. Recommended to call this when the program exits.
5. _RegisterNotifyCallback(NotifyCallback callback)
Registers a notification event callback. Refer to NotifyType for notification types.
6. _RegisterConnectChangedCallback(ConnectChangedCallback callback)
Registers a connection status change callback.
7. _RegisterCheckBLECallback(CheckBLECallback callback)
Registers a BLE status response callback. Refer to CheckBleResult for callback types.
8. _RegisterToyAddCallback(ToyAddCallback callback)
Registers a toy addition response callback.
9. _RegisterEventsAPICallback(EventsApiCallback callback)
Registers an EventsAPI response callback. Refer to LovenseDataReportingEventType for callback types.
10. _RegisterBatteryCallback(BatteryCallback callback)
Registers a battery level response callback.
11. _ConnectToy(wchar_t* deviceId)
Connects to a toy.
12. _DisConnectToy(wchar_t* deviceId)
Disconnects from a toy.
13. _SendCommand(wchar_t* deviceId, int commandType, int value)
Sends a command. Refer to LovenseCommandType for command types.
14. _SendCommandToSolacePro(wchar_t* deviceId, int speed, int strokeLow, int strokeHigh)
Sends a stroke command to SolacePro.
15. _OpenSolaceProEventsAPI(wchar_t* deviceId, int mode)
Opens SolacePro's EventsAPI. If registered, EventsApiCallback will respond (_RegisterEventsAPICallback).
- Modes for Solace Pro:
- 0: Reports thrusting speed and stroke range to the app in real time. The device cannot be controlled manually.
- 1: Reports thrusting speed and stroke range but can only be controlled manually.
16. _CloseSolaceProEventsAPI(wchar_t* deviceId)
Closes SolacePro's EventsAPI.
17. _OpenEventsAPI(wchar_t* deviceId)
Opens EventsAPI. If registered, EventsApiCallback will respond (_RegisterEventsAPICallback).
18. _CloseEventsAPI(wchar_t* deviceId)
Closes EventsAPI.
C/C++ Enums
enum CheckBleResult
{
BLE_ENABLE_OPEN = 0, // BLE is supported and currently enabled.
BLE_ENABLE_CLOSE = 1, // BLE is supported but currently disabled.
BLE_DISABLE = 2 // BLE is not supported.
}
enum NotifyType
{
SCAN_START = 0, // Start scanning.
SCAN_STOP = 1, // Stop scanning.
EXECUTE_SUCCESS = 2, // Execution succeeded.
EXECUTE_FAILED = 3, // Execution failed.
FAILED_SCANNING_NOW = 4, // Failed due to active scanning. Stop scanning first.
DIS_CONNECTION_SUCCESS = 5, // Disconnection successful.
DIS_CONNECTION_ERROR = 6, // Disconnection failed.
CONNECTION_SUCCESS = 7, // Connection successful.
CONNECTION_ERROR = 8, // Connection failed.
TOY_NO_CONNECT = 9, // Toy not connected.
BLE_DISABLE_OR_CLOSE = 10 // BLE unavailable or disabled.
}
enum LovenseDataReportingEventType
{
KEY_DOWN = 0,
KEY_UP = 1,
VIBRATE = 2,
ROTATE = 3,
SHAKE = 4,
MOVEMENT = 5,
DEEP = 6,
AIR_IN = 7,
AIR_OUT = 8,
AIR_CLOSE = 9,
AIR_OPEN = 10,
BATTERY = 11,
STROKE_SPEED_POSITION = 12,
SHAKE_TIMES = 13,
}
enum LovenseCommandType
{
VIBRATE = 0,
VIBRATE1 = 1,
VIBRATE2 = 2,
VIBRATE3 = 3,
ROTATE = 4,
PUMP = 5,
THRUSTING = 6,
FINGERING = 7,
SUCTION = 8,
DEPTH = 9,
POSITION = 10,
OSCILLATE = 11,
GET_BATTERY = 12
}
Guide
C# Example
Note: LovenseBLETools.GetInstance().InitSupport(supportText, Action<InitSupportCommandStatus> completed)
This method configures the supported features of each toy by reading from LovenseToySupportConfig.csv. If offline, the CSV content can be assigned directly in the code. Current latest version: 1.5
.
C++ Example
Note: Similar to the C# example. The main difference is method declarations and callbacks. Refer to the C# example and the C++ code below:
// Function pointers for DLL methods
typedef void(__cdecl* MsgCallback)(const wchar_t* msg);
typedef void(__cdecl* ConnectChangedCallback)(const wchar_t* deviceId, bool connected);
typedef void(__cdecl* CheckBLECallback)(int status);
typedef void(__cdecl* ToyAddCallback)(const wchar_t* deviceId);
typedef void(__cdecl* EventsApiCallback)(const wchar_t* deviceId, int eventType, int hardwareType, int value);
typedef void(__cdecl* BatteryCallback)(const wchar_t* deviceId, const wchar_t* battery);
typedef void(__cdecl* StartBLEScanFunc)();
typedef void(__cdecl* StopBLEScanFunc)();
typedef void(__cdecl* QuitFunc)();
typedef void(__cdecl* CheckBLEStatusFunc)();
typedef void(__cdecl* RegisterNotifyCallbackFunc)(MsgCallback);
typedef void(__cdecl* RegisterConnectChangedCallbackFunc)(ConnectChangedCallback);
typedef void(__cdecl* RegisterCheckBLECallbackFunc)(CheckBLECallback);
typedef void(__cdecl* RegisterToyAddCallbackFunc)(ToyAddCallback);
typedef void(__cdecl* RegisterEventsAPICallbackFunc)(EventsApiCallback);
typedef void(__cdecl* RegistBatteryCallbackFunc)(BatteryCallback);
typedef void(__cdecl* ConnectToyFunc)(wchar_t*);
typedef void(__cdecl* DisConnectToyFunc)(wchar_t*);
typedef void(__cdecl* SendCommandFunc)(wchar_t*, int, int);
typedef void(__cdecl* SendCommandToSolaceProFunc)(wchar_t*, int, int, int);
typedef void(__cdecl* OpenSolaceProEventsAPIFunc)(wchar_t*, int);
typedef void(__cdecl* CloseSolaceProEventsAPIFunc)(wchar_t*);
typedef void(__cdecl* OpenEventsAPIFunc)(wchar_t*);
typedef void(__cdecl* CloseEventsAPIFunc)(wchar_t*);
StartBLEScanFunc _StartBLEScan;
StopBLEScanFunc _StopBLEScan;
QuitFunc _Quit;
CheckBLEStatusFunc _CheckBLEStatus;
RegisterNotifyCallbackFunc _RegisterNotifyCallback;
RegisterConnectChangedCallbackFunc _RegisterConnectChangedCallback;
RegisterCheckBLECallbackFunc _RegisterCheckBLECallback;
RegisterToyAddCallbackFunc _RegisterToyAddCallback;
RegisterEventsAPICallbackFunc _RegisterEventsAPICallback;
RegistBatteryCallbackFunc _RegisterBattertCallback;
ConnectToyFunc _ConnectToy;
DisConnectToyFunc _DisConnectToy;
SendCommandFunc _SendCommand;
SendCommandToSolaceProFunc _SendCommandToSolacePro;
OpenSolaceProEventsAPIFunc _OpenSolaceProEventsAPI;
CloseSolaceProEventsAPIFunc _CloseSolaceProEventsAPI;
OpenEventsAPIFunc _OpenEventsAPI;
CloseEventsAPIFunc _CloseEventsAPI;
// Function initialization example
void InitExternFunc() {
HMODULE hDLL = LoadLibrary(L"LovenseBLE_Lib.dll");
if (!hDLL) {
OutputDebugString(L"Load dll failed");
return;
}
OutputDebugString(L"Load dll success");
_StartBLEScan = (StartBLEScanFunc)GetProcAddress(hDLL, "_StartBLEScan");
_StopBLEScan = (StopBLEScanFunc)GetProcAddress(hDLL, "_StopBLEScan");
_Quit = (QuitFunc)GetProcAddress(hDLL, "_Quit");
_CheckBLEStatus = (CheckBLEStatusFunc)GetProcAddress(hDLL, "_CheckBLEStatus");
_RegisterNotifyCallback = (RegisterNotifyCallbackFunc)GetProcAddress(hDLL, "_RegisterNotifyCallback");
_RegisterConnectChangedCallback = (RegisterConnectChangedCallbackFunc)GetProcAddress(hDLL, "_RegisterConnectChangedCallback");
_RegisterCheckBLECallback = (RegisterCheckBLECallbackFunc)GetProcAddress(hDLL, "_RegisterCheckBLECallback");
_RegisterToyAddCallback = (RegisterToyAddCallbackFunc)GetProcAddress(hDLL, "_RegisterToyAddCallback");
_RegisterEventsAPICallback = (RegisterEventsAPICallbackFunc)GetProcAddress(hDLL, "_RegisterEventsAPICallback");
_RegisterBattertCallback = (RegistBatteryCallbackFunc)GetProcAddress(hDLL, "_RegisterBattertCallback");
_ConnectToy = (ConnectToyFunc)GetProcAddress(hDLL, "_ConnectToy");
_DisConnectToy = (DisConnectToyFunc)GetProcAddress(hDLL, "_DisConnectToy");
_SendCommand = (SendCommandFunc)GetProcAddress(hDLL, "_SendCommand");
_SendCommandToSolacePro = (SendCommandToSolaceProFunc)GetProcAddress(hDLL, "_SendCommandToSolacePro");
_OpenSolaceProEventsAPI = (OpenSolaceProEventsAPIFunc)GetProcAddress(hDLL, "_OpenSolaceProEventsAPI");
_CloseSolaceProEventsAPI = (CloseSolaceProEventsAPIFunc)GetProcAddress(hDLL, "_CloseSolaceProEventsAPI");
_OpenEventsAPI = (OpenEventsAPIFunc)GetProcAddress(hDLL, "_OpenEventsAPI");
_CloseEventsAPI = (CloseEventsAPIFunc)GetProcAddress(hDLL, "_CloseEventsAPI");
}
// Function execute example
void OnConnectChange(const wchar_t* toyId, bool connect) {
// ...
}
void OnGetBattery(const wchar_t* toyId, const wchar_t* battery) {
// ...
}
void DoSomething() {
_RegisterConnectChangedCallback(&OnConnectChange);
_RegisterBattertCallback(&OnGetBattery);
// ...
}
Version Records
[Version 1.0] - 2025-03-26
- Supports C/C++/C# Windows BLE DLL.