Skip to content

Commit

Permalink
nsyshid: add windows hid backend
Browse files Browse the repository at this point in the history
This adds a backend for nsyshid, that uses the Windows HID API to provide passthrough access to real usb devices.
  • Loading branch information
ssievert42 committed Aug 28, 2023
1 parent 3a298db commit 5307dce
Show file tree
Hide file tree
Showing 5 changed files with 484 additions and 1 deletion.
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,18 @@ endif()
option(ENABLE_CUBEB "Enabled cubeb backend" ON)

# usb hid backends
option(ENABLE_NSYSHID_LIBUSB "Enables the libusb backend for nsyshid" ON)
if (WIN32)
option(ENABLE_NSYSHID_WINDOWS_HID "Enables the native Windows HID backend for nsyshid" ON)
endif ()
# libusb and windows hid backends shouldn't be active at the same time; otherwise we'd see all devices twice!
if (NOT ENABLE_NSYSHID_WINDOWS_HID)
option(ENABLE_NSYSHID_LIBUSB "Enables the libusb backend for nsyshid" ON)
else ()
set(ENABLE_NSYSHID_LIBUSB OFF CACHE BOOL "" FORCE)
endif ()
if (ENABLE_NSYSHID_WINDOWS_HID)
add_compile_definitions(NSYSHID_ENABLE_BACKEND_WINDOWS_HID)
endif ()
if (ENABLE_NSYSHID_LIBUSB)
add_compile_definitions(NSYSHID_ENABLE_BACKEND_LIBUSB)
endif ()
Expand Down
2 changes: 2 additions & 0 deletions src/Cafe/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,8 @@ add_library(CemuCafe
OS/libs/nsyshid/Whitelist.h
OS/libs/nsyshid/BackendLibusb.cpp
OS/libs/nsyshid/BackendLibusb.h
OS/libs/nsyshid/BackendWindowsHID.cpp
OS/libs/nsyshid/BackendWindowsHID.h
OS/libs/nsyskbd/nsyskbd.cpp
OS/libs/nsyskbd/nsyskbd.h
OS/libs/nsysnet/nsysnet.cpp
Expand Down
15 changes: 15 additions & 0 deletions src/Cafe/OS/libs/nsyshid/AttachDefaultBackends.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

#endif

#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID

#include "BackendWindowsHID.h"

#endif

namespace nsyshid::backend {
void attachDefaultBackends() {
#if NSYSHID_ENABLE_BACKEND_LIBUSB
Expand All @@ -18,5 +24,14 @@ namespace nsyshid::backend {
}
}
#endif //NSYSHID_ENABLE_BACKEND_LIBUSB
#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID
// add windows hid backend
{
auto backendWindowsHID = std::make_shared<backend::windows::BackendWindowsHID>();
if (backendWindowsHID->isInitialisedOk()) {
attachBackend(backendWindowsHID);
}
}
#endif //NSYSHID_ENABLE_BACKEND_WINDOWS_HID
}
}
Loading

0 comments on commit 5307dce

Please sign in to comment.