Skip to content

Commit

Permalink
nsyshid: add libusb backend
Browse files Browse the repository at this point in the history
This adds a backend for nsyshid, that uses libusb to provide passthrough access to real usb devices.
  • Loading branch information
ssievert42 committed Aug 31, 2023
1 parent aac3b53 commit dff33b3
Show file tree
Hide file tree
Showing 8 changed files with 738 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jobs:
- name: "Install system dependencies"
run: |
brew update
brew install llvm@15 ninja nasm molten-vk
brew install llvm@15 ninja nasm molten-vk automake libtool
- name: "Bootstrap vcpkg"
run: |
Expand Down
2 changes: 1 addition & 1 deletion BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ You can skip this section if you have an Intel Mac. Every time you compile, you

### Installing dependencies

`brew install boost git cmake llvm ninja nasm molten-vk`
`brew install boost git cmake llvm ninja nasm molten-vk automake libtool`

### Build Cemu using cmake and clang
1. `git clone --recursive https://github.com/cemu-project/Cemu`
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ if (WIN32)
endif()
option(ENABLE_CUBEB "Enabled cubeb backend" ON)

# usb hid backends
option(ENABLE_NSYSHID_LIBUSB "Enables the libusb backend for nsyshid" ON)
if (ENABLE_NSYSHID_LIBUSB)
add_compile_definitions(NSYSHID_ENABLE_BACKEND_LIBUSB)
endif ()

option(ENABLE_WXWIDGETS "Build with wxWidgets UI (Currently required)" ON)

set(THREADS_PREFER_PTHREAD_FLAG true)
Expand Down
8 changes: 8 additions & 0 deletions src/Cafe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,8 @@ add_library(CemuCafe
OS/libs/nsyshid/AttachDefaultBackends.cpp
OS/libs/nsyshid/Whitelist.cpp
OS/libs/nsyshid/Whitelist.h
OS/libs/nsyshid/BackendLibusb.cpp
OS/libs/nsyshid/BackendLibusb.h
OS/libs/nsyskbd/nsyskbd.cpp
OS/libs/nsyskbd/nsyskbd.h
OS/libs/nsysnet/nsysnet.cpp
Expand Down Expand Up @@ -528,6 +530,12 @@ if (ENABLE_WAYLAND)
target_link_libraries(CemuCafe PUBLIC Wayland::Client)
endif()

if (ENABLE_NSYSHID_LIBUSB)
find_package(libusb CONFIG REQUIRED)
target_include_directories(CemuCafe PRIVATE ${LIBUSB_INCLUDE_DIRS})
target_link_libraries(CemuCafe PRIVATE ${LIBUSB_LIBRARIES})
endif ()

if (ENABLE_WXWIDGETS)
target_link_libraries(CemuCafe PRIVATE wx::base wx::core)
endif()
Expand Down
16 changes: 15 additions & 1 deletion src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
#include "nsyshid.h"
#include "Backend.h"

#if NSYSHID_ENABLE_BACKEND_LIBUSB

#include "BackendLibusb.h"

#endif

namespace nsyshid::backend {
void attachDefaultBackends() {

#if NSYSHID_ENABLE_BACKEND_LIBUSB
// add libusb backend
{
auto backendLibusb = std::make_shared<backend::libusb::BackendLibusb>();
if (backendLibusb->isInitialisedOk()) {
attachBackend(backendLibusb);
}
}
#endif //NSYSHID_ENABLE_BACKEND_LIBUSB
}
}
Loading

0 comments on commit dff33b3

Please sign in to comment.