diff --git a/.gitmodules b/.gitmodules index 42bd8d2de43c2e808ee31134de87fdb9939eb6cb..dcd1e13cb3963133257f71e43a0e54ad7b5534d1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,12 +1,6 @@ [submodule "deps/pd-lib-builder"] path = deps/pd-lib-builder url = https://github.com/pure-data/pd-lib-builder/ -[submodule "deps/libusb"] - path = deps/libusb - url = https://github.com/libusb/libusb -[submodule "deps/hidapi"] - path = deps/hidapi - url = https://github.com/libusb/hidapi [submodule "deps/USB-HID-Report-Parser"] path = deps/USB-HID-Report-Parser url = https://github.com/tschiemer/USB-HID-Report-Parser diff --git a/Makefile.linux b/Makefile.linux index 61e02df39602559e556454d07b0b88a3891e3036..dc56002737506c46eaf954999aaeb8548b8b2cbd 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -1,11 +1,11 @@ PDLIBBUILDER_DIR=${CURDIR}/deps/pd-lib-builder -LIBUSB_DIR=/usr/include/libusb-1.0 -HIDAPI_DIR=/usr/include/hidapi +LIBUSB_DIR=/usr/include +HIDAPI_DIR=/usr/include HIDMAP_DIR=${CURDIR}/deps/USB-HID-Report-Parser # using invasive detaching.... ahem. -cflags += -I${LIBUSB_DIR} -I${HIDAPI_DIR} -I${HIDMAP_DIR} -DDETACH_KERNEL_DRIVER +cflags += -I${HIDMAP_DIR} -DDETACH_KERNEL_DRIVER ldflags += -lusb-1.0 -lhidapi-libusb -L${HIDMAP_DIR} -lusbhid_map export PDDIR diff --git a/Makefile.macos b/Makefile.macos index ae5fee83a4f820a00637b6e3afda14523771b344..3fe535f1da6358ca7d38d0feb0237828b3ccafaa 100644 --- a/Makefile.macos +++ b/Makefile.macos @@ -1,22 +1,17 @@ PDLIBBUILDER_DIR=${CURDIR}/deps/pd-lib-builder -LIBUSB_DIR=${CURDIR}/deps/libusb -HIDAPI_DIR=${CURDIR}/deps/hidapi HIDMAP_DIR=${CURDIR}/deps/USB-HID-Report-Parser -cflags += -I${LIBUSB_DIR}/libusb -I${HIDAPI_DIR}/hidapi -I${HIDMAP_DIR} -ldflags += -L${LIBUSB_DIR}/libusb -lusb -L${HIDAPI_DIR}/local-install/lib #-lhidapi -L${HIDMAP_DIR} #-lusbhid_map +cflags += -I${HIDMAP_DIR} +ldflags += -lusb-1.0 -lhidapi -export PDDIR export PDLIBBUILDER_DIR -export LIBUSB_DIR -export HIDAPI_DIR export HIDMAP_DIR export cflags export ldflags -all: libusb hidapi #usbhid_map +all: $(MAKE) -C src/hid install: @@ -24,33 +19,3 @@ install: clean: $(MAKE) -C src/hid clean - $(MAKE) -C ${LIBUSB_DIR} clean - $(MAKE) -C ${HIDAPI_DIR} clean - - -### libusbb - -libusb: ${LIBUSB_DIR}/libusb/.libs/libusb-1.0.a - -${LIBUSB_DIR}/libusb/.libs/libusb-1.0.a: ${LIBUSB_DIR}/Makefile - $(MAKE) -C ${LIBUSB_DIR} - -${LIBUSB_DIR}/Makefile: ${LIBUSB_DIR}/configure - cd ${LIBUSB_DIR}; ./configure - -${LIBUSB_DIR}/configure: - cd ${LIBUSB_DIR}; ./autogen.sh - -### hidapi - -hidapi: ${HIDAPI_DIR}/local-install/libhidapi.la - -${HIDAPI_DIR}/local-install/libhidapi.la: ${HIDAPI_DIR}/Makefile - $(MAKE) -C ${HIDAPI_DIR} - $(MAKE) -C ${HIDAPI_DIR} install - -${HIDAPI_DIR}/Makefile: ${HIDAPI_DIR}/configure - cd ${HIDAPI_DIR}; ./configure --prefix=${HIDAPI_DIR}/local-install - -${HIDAPI_DIR}/configure: - cd ${HIDAPI_DIR}; ./bootstrap diff --git a/README.md b/README.md index f227a58c17402e5e1b4119ff82134406c29f8500..383fbf4ba8dec4c103437807c9c27f3c867f1ca6 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,12 @@ Tested RPi 4 (5.10.17-v7l+), in principle works but is suboptimal. ### macos -*Should* work as is.. +Install dependencies: +```bash +brew install libusb hidapi +``` +Compile: ```bash git clone --recursive https://github.com/tschiemer/hid-pd-external cd hid-pd-external/ @@ -31,8 +35,6 @@ make -f Makefile.macos && make -f Makefile.macos install ### linux (Raspberry Pi) -A bit more troublesome.. these instructions might not get you all the way, but should be a start. - *NOTE* as it is, using libusb (in this external) on linux is somewhat invasive on USB devices as kernel drivers might be detached for this to work. Using hidraw (as offered by hidapi) this seems to work without further problem, but this is something that remains to be done. diff --git a/deps/USB-HID-Report-Parser b/deps/USB-HID-Report-Parser index e3ba71789fe84e5cd841f0abfd321b846bd41975..b6637729edcd833c3c9a54970ff10017f7f1782c 160000 --- a/deps/USB-HID-Report-Parser +++ b/deps/USB-HID-Report-Parser @@ -1 +1 @@ -Subproject commit e3ba71789fe84e5cd841f0abfd321b846bd41975 +Subproject commit b6637729edcd833c3c9a54970ff10017f7f1782c diff --git a/deps/hidapi b/deps/hidapi deleted file mode 160000 index 6a01f3b4a8862b19a7ec768752ebcfc1a412f4b1..0000000000000000000000000000000000000000 --- a/deps/hidapi +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6a01f3b4a8862b19a7ec768752ebcfc1a412f4b1 diff --git a/deps/libusb b/deps/libusb deleted file mode 160000 index bda2344f5e7d460decd3968492faa7a5fb2797cd..0000000000000000000000000000000000000000 --- a/deps/libusb +++ /dev/null @@ -1 +0,0 @@ -Subproject commit bda2344f5e7d460decd3968492faa7a5fb2797cd diff --git a/src/hid/hid.c b/src/hid/hid.c index 0a620f31f782a9a71acefccd921d18c0ba5fe717..7797fc4c74f640fd89fd4d9028d314f4eabe339f 100644 --- a/src/hid/hid.c +++ b/src/hid/hid.c @@ -3,11 +3,12 @@ #include "m_pd.h" #include "usbhid_map.h" -#include <libusb.h> -#include <hidapi.h> //#include "report_item.h" //#include "report_usage.h" +#include <libusb-1.0/libusb.h> +#include <hidapi/hidapi.h> + #include <stdlib.h> #include <unistd.h> #include <string.h> @@ -391,10 +392,13 @@ static int hid_filter_device_list(libusb_device **devs, ssize_t count, hid_devic } #endif +#if !__APPLE__ r = libusb_claim_interface(handle, interface_num); if (r < 0) { error("claim_interface(): %d", r); - } else { + } else +#endif + { uint8_t report_desc[256]; r = libusb_control_transfer(handle, LIBUSB_ENDPOINT_IN | LIBUSB_RECIPIENT_INTERFACE, @@ -490,6 +494,7 @@ static int hid_filter_device_list(libusb_device **devs, ssize_t count, hid_devic // post("usage (page) = %d (%d)", report_desc[3], report_desc[1]); } } + } // claimed #ifdef DETACH_KERNEL_DRIVER