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 Sep 18, 2023
1 parent c9ee3c1 commit 7483c86
Show file tree
Hide file tree
Showing 6 changed files with 553 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
16 changes: 16 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()
Expand All @@ -21,5 +27,15 @@ 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
}
} // namespace nsyshid::backend
Loading

0 comments on commit 7483c86

Please sign in to comment.