Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ OBJS = $(SOURCE_FULL:.cpp=.o)
PROG_OBJ = $(PROG_SOURCE_FULL:.cpp=.o)

DEFINES += _LINUX_
DEFINES += _LIBUSB_
#DEFINES += _LIBUSB_

COMPILE_FLAGS += $(addprefix -D, $(DEFINES))

CUR_PATH = $(shell echo $(PWD))
INCLUDEPATHS = $(addprefix -I$(CUR_PATH)/, $(dir $(SOURCE_FULL)) libusb )
INCLUDEPATHS = $(addprefix -I$(CUR_PATH)/, $(dir $(SOURCE_FULL)) libusb ) -I/opt/homebrew/include
LOADPATHS =
LIBS = -lusb-1.0
#LIBS = -lusb-1.0
LIBS = -lhidapi
CPP = g++


Expand Down
2 changes: 2 additions & 0 deletions src/usbhid/usbhid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.
#include <iostream>


#if 0
UsbHid::UsbHid()
{
usb_context = NULL;
Expand Down Expand Up @@ -405,3 +406,4 @@ int UsbHid::read(unsigned char *data, int length)

return actual_length;
}
#endif
12 changes: 5 additions & 7 deletions src/yk_usb_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ limitations under the License.
#ifdef _LIBUSB_
#include <usbhid.h>
#else
#include <hidapi.h>
//#include <hidapi.h>
#include <string.h>
#endif

#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>

#ifdef _LIBUSB_
// Uses libusb directly
Expand Down Expand Up @@ -153,13 +155,9 @@ int UsbDevice::sendHidReport(char *serial, unsigned char *msg, unsigned char *re

if (serial) {
// Convert to a wchar_t*
size_t origsize = strlen(serial) + 1;
size_t convertedChars = 0;

mbstowcs_s(&convertedChars, cserial, origsize, serial, _TRUNCATE);

swprintf(cserial, newsize, L"%s", serial);
}

// Open the USB device
handle = hid_open(vid, pid, serial ? cserial : NULL);

Expand Down
2 changes: 1 addition & 1 deletion src/yk_usb_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.
#ifdef _LIBUSB_
#include <usbhid.h>
#else
#include <hidapi.h>
#include <hidapi/hidapi.h>
#endif
#include <stdlib.h>

Expand Down