This commit is contained in:
sylvieee-iot 2024-05-02 21:58:54 +03:00 committed by GitHub
parent e6d62217a3
commit 0bdc7f6882
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 39 additions and 0 deletions

View file

@ -271,6 +271,10 @@ if(ENABLE_LUAJIT AND NOT ANDROID)
add_subdirectory(third_party/libuv)
target_link_libraries(AlberCore PRIVATE uv_a)
include_directories(third_party/open-bp-cpp/include)
add_subdirectory(third_party/open-bp-cpp)
target_link_libraries(AlberCore PRIVATE buttplugCpp)
endif()
if(ENABLE_QT_GUI)

View file

@ -1,7 +1,41 @@
#include "panda_sdl/frontend_sdl.hpp"
#include <string>
#include <chrono>
#include <cstdio>
#include <thread>
#include "buttplugclient.h"
void callbackFunction(const mhl::Messages msg) {
switch (msg.messageType) {
case mhl::MessageTypes::DeviceList: printf("Device List callback\n"); break;
case mhl::MessageTypes::DeviceAdded: printf("Device List callback\n"); break;
case mhl::MessageTypes::ServerInfo: printf("Server info callback\n"); break;
case mhl::MessageTypes::DeviceRemoved: printf("Device Removed callback\n"); break;
case mhl::MessageTypes::SensorReading: printf("Sensor reading callback\n"); break;
default: printf("Unknown message")
}
}
int main(int argc, char *argv[]) {
FrontendSDL app;
std::string url = "ws://127.0.0.1";
Client client(url, 12345, "test.txt");
client.connect(callbackFunction);
client.requestDeviceList();
while (1) {
client.startScan();
std::vector<DeviceClass> myDevices = client.getDevices();
if (myDevices.size() > 0) {
client.sendScalar(myDevices[0], 0.5);
}
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
client.stopScan();
break;
}
if (argc > 1) {
auto romPath = std::filesystem::current_path() / argv[1];

View file

@ -22,6 +22,7 @@ file(GLOB SRC_FILES
add_library(buttplugCpp STATIC ${SRC_FILES})
set(USE_ZLIB FALSE)
target_include_directories(buttplugCpp PUBLIC third_party/IXWebSocket/ixwebsocket)
add_subdirectory(third_party/IXWebSocket)
find_package(Threads REQUIRED)