Added spdlog
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
#include "ergodox.hpp"
|
||||
|
||||
|
||||
Ergodox::Ergodox(
|
||||
unsigned short vendor_id,
|
||||
unsigned short product_id,
|
||||
@ -102,18 +101,21 @@ bool Ergodox::try_connect() {
|
||||
|
||||
#define MAX_STR 255
|
||||
wchar_t wstr[MAX_STR];
|
||||
char nstr[MAX_STR];
|
||||
|
||||
|
||||
wprintf(L"\nConnected to device!\n");
|
||||
spdlog::info("Connected to device!");
|
||||
|
||||
// Read metadata
|
||||
wstr[0] = 0x0000;
|
||||
hid_get_manufacturer_string(handle, wstr, MAX_STR);
|
||||
wprintf(L"Manufacturer String: %ls\n", wstr);
|
||||
misc::to_narrow(wstr, nstr, MAX_STR);
|
||||
spdlog::info("Manufacturer String: {0}", nstr);
|
||||
|
||||
wstr[0] = 0x0000;
|
||||
hid_get_product_string(handle, wstr, MAX_STR);
|
||||
wprintf(L"Product String: %ls\n", wstr);
|
||||
misc::to_narrow(wstr, nstr, MAX_STR);
|
||||
spdlog::info("Product String: {0}", nstr);
|
||||
|
||||
} else {
|
||||
connected = false;
|
||||
@ -168,7 +170,7 @@ bool Ergodox::write(uint8_t cmd, const uint8_t* data, uint8_t data_len) {
|
||||
res = hid_write(handle, packet, packet_size + 1);
|
||||
|
||||
if (res < 0) {
|
||||
wprintf(L"Lost device, disconnecting.\n");
|
||||
spdlog::info("Lost device, disconnecting.");
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
@ -194,7 +196,7 @@ bool Ergodox::read() {
|
||||
if (res == 0) {
|
||||
return false;
|
||||
} else if (res < 0) {
|
||||
wprintf(L"Lost device, disconnecting.\n");
|
||||
spdlog::info("Lost device, disconnecting.");
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
@ -204,7 +206,7 @@ bool Ergodox::read() {
|
||||
// If keyboard sends a state packet, parse it.
|
||||
case CMD_SEND_STATE:
|
||||
if (animation_mode != read_buf[1]) {
|
||||
wprintf(L"Mode set to 0x%02X\n", read_buf[1]);
|
||||
spdlog::info("Mode set to {0:x}", read_buf[1]);
|
||||
animation_mode = read_buf[1];
|
||||
}
|
||||
|
||||
@ -223,7 +225,7 @@ void Ergodox::test_connection() {
|
||||
|
||||
// Block until a connection is established.
|
||||
void Ergodox::connect_loop() {
|
||||
wprintf(L"Trying to connect...\n");
|
||||
spdlog::info("Trying to connect...");
|
||||
while (!connected) {
|
||||
try_connect();
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(RECONNECT_SLEEP_MS));
|
||||
|
Reference in New Issue
Block a user