-
Notifications
You must be signed in to change notification settings - Fork 603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hidapi wiimote #934
Add hidapi wiimote #934
Conversation
Looks good on a quick glance. I did not test it, however. Small nitpick, we should probably not include hidapi on Windows where it's not used.
|
if (ENABLE_HIDAPI) | ||
find_package(hidapi REQUIRED) | ||
set(ENABLE_WIIMOTE ON) | ||
add_compile_definitions(HAS_HIDAPI) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please move this to src/input/CMakeLists.txt
and use target_compile_definitions(PRIVATE)
instead? It'd be a bit cleaner, in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about moving this, considering that every other find_package()
usage in the project is in the base CMakeLists.txt
. Also add_compile_definitions()
is used everywhere else in the project, rather than target_compile_definitions()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case consistency is better than supposed code clarity, it's fine to leave this as is :)
Followup: After the excitement of finally being able to get cemu to recognize wiimotes connected, I did some more thorough testing and ran into some issues. I ran into some oddball issues with certain inputs not registering when using the dolphinbar, but they are sporadic and could totally be my fault. The core functionality of a wiimote w/o accessories works fine. GDBThread 13 "MainThread" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe8ff9640 (LWP 19914)]
0x0000000001ff8f17 in hid_write (dev=0x0, data=0x7fffb400ceb0 "\025", length=2) at /home/crazy/Applications/cemu-wiimote/dependencies/vcpkg/buildtrees/hidapi/src/api-0.13.1-ad14f0e8b8.clean/linux/hid.c:1013
1013 bytes_written = write(dev->device_handle, data, length); log.txt[02:35:13.446] XMLConfig::Load > failed "/home/crazy/Applications/cemu-wiimote/bin/settings.xml" with error 2
[02:35:13.446] XMLConfig::Load > failed "/home/crazy/Applications/cemu-wiimote/bin/settings.xml" with error 2
[02:35:13.448] XMLConfig::Load > failed "/home/crazy/Applications/cemu-wiimote/bin/settings.xml" with error 2
[02:35:15.647] ------- Init Cemu 2.0 (experimental) -------
[02:35:15.647] Init Wii U memory space (base: 0x00007f1ac4000000)
[02:35:15.648] mlc01 path: /home/crazy/Applications/cemu-wiimote/bin/mlc01
[02:35:15.648] CPU: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
[02:35:15.648] RAM: 31780MB
[02:35:15.648] Used CPU extensions: SSSE3, SSE4.1, AVX, AVX2, LZCNT, MOVBE, BMI2, AES-NI, INVARIANT-TSC
Error: signal 11:
./Cemu_debug() [0x1ff8f17]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f1c12c50520]
./Cemu_debug() [0x1ff8f17]
./Cemu_debug() [0x11cb192]
./Cemu_debug() [0x11bd073]
./Cemu_debug() [0x11bb110]
./Cemu_debug() [0x11c664e]
./Cemu_debug() [0x11c6562]
./Cemu_debug() [0x11c6522]
./Cemu_debug() [0x11c64d5]
./Cemu_debug() [0x11c6339]
[02:35:15.659] IOSU_CRYPTO: No otp.bin found. Online mode cannot be used
[02:35:15.659] IOSU_CRYPTO: No Seeprom.bin found. Online mode cannot be used
/lib/x86_64-linux-gnu/libstdc++.so.6(+0xdc253) [0x7f1c11a1b253]
/lib/x86_64-linux-gnu/libc.so.6(+0x94b43) [0x7f1c12ca2b43]
/lib/x86_64-linux-gnu/libc.so.6(+0x126a00) [0x7f1c12d34a00]``` |
These two commits fixed the immediate crash, however, hidapi continues to not detect the remote if it is connected via a standard bluetooth dongle to the computer; the list appears empty. SDLController recognizes the remote fine. Connecting via a dolphinbar, cemu continues to list the remotes with no issue. |
So far, I've been unable to reproduce this. Could you compile and run Cemu with this PR, in debug mode, and check if there are any messages in the Logging Window? |
My bad, it was a dumb typo in my udev permissions. Cemu can now see the remote. Original Wii Remote (RVL-CNT-01)No accessoriesNo noticeable user issues.
This seems to have no impact. NunchuckThe joystick works, but C and Z do not. According to the Nunchuck status listed in the log, cemu believes that C and Z are held down at all times: C and Z are allways set to "True" Wii Motion PlusAttaching a wii motion plus causes cemu to spam Below is a sample from the log.
Wii Remote w/ Motion Plus Built In (RVL-CNT-01-TR)I originally chalked up the issues I was having with this remote up to documented weirdness. However, I now think this is because the aforementioned wii motion plus issues. Using this remote, I experienced the same issues with tilt and nunchuck control as I experienced with the Motion Plus accessory on the original wiimote. This is a problem because motion plus is permanently enabled on the controller. This means that on MotionPlus enabled controllers, tilt and nunchuck controls don't work right now. Below is an excerpt from the log. Refer to the time between the nunchuck info messages at the top and bottom (3.5 seconds before nunchuck works again): [14:13:36.549] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -5042.03, -1776.17, 29048.96
[14:13:36.549] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -4812.85, -1546.99, 29048.96
[14:13:36.552] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -4583.66, -1546.99, 28819.78
[14:13:36.554] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -4354.48, -1546.99, 29048.96
[14:13:36.560] WiimoteControllerProvider::read_thread: kStatus
[14:13:36.560] Extension flag is set
[14:13:36.560] Setting report type to 55
[14:13:36.567] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -4125.30, -1546.99, 29048.96
[14:13:36.570] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -4125.30, -1546.99, 29048.96
[14:13:36.577] WiimoteControllerProvider::read_thread: kRead
[14:13:36.577] Setting report type to 51
[14:13:36.577] Setting report type to 51
[14:13:36.706] unhandled input packet id 0 for wiimote
[14:13:36.730] unhandled input packet id 0 for wiimote
[14:13:36.755] unhandled input packet id 0 for wiimote
[14:13:36.781] unhandled input packet id 0 for wiimote
[14:13:36.811] unhandled input packet id 0 for wiimote
[14:13:39.750] WiimoteControllerProvider::read_thread: kStatus
[14:13:39.751] Extension flag is set
[14:13:39.751] Setting report type to 51
[14:13:39.764] WiimoteControllerProvider::read_thread: kRead
[14:13:39.765] Setting report type to 51
[14:13:39.790] unhandled input packet id 0 for wiimote
[14:13:39.818] unhandled input packet id 0 for wiimote
[14:13:39.851] WiimoteControllerProvider::read_thread: kRead
[14:13:39.851] Extension Type Received: Nunchuck
[14:13:39.851] Setting report type to 55
[14:13:39.851] Setting report type to 55
[14:13:39.922] WiimoteControllerProvider::read_thread: kRead
[14:13:39.922] Extension calibration received
[14:13:39.922] Setting report type to 55
[14:13:39.953] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -2521.01, -2005.35, 28819.78
[14:13:39.955] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -2521.01, -2005.35, 28819.78
[14:13:39.961] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -2521.01, -2005.35, 28819.78
[14:13:39.967] Nunchuck: Z=true, C=true | 0.019799627, -0.019343913 | -2521.01, -2005.35, 29048.96 |
@@ -2,7 +2,8 @@ | |||
|
|||
static constexpr uint16 WIIMOTE_VENDOR_ID = 0x057e; | |||
static constexpr uint16 WIIMOTE_PRODUCT_ID = 0x0306; | |||
static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 21; | |||
static constexpr uint16 WIIMOTE_MP_PRODUCT_ID = 0x0330; | |||
static constexpr uint16 WIIMOTE_MAX_INPUT_REPORT_LENGTH = 22; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nunchuk c and z weren't being read because I chose an incorrect read size
this also means that the nunchuck accelerometer values were inaccurate
C and Z now work on all controllers. Tilt control works on the original, non MotionPlus wiimote. As far as I can tell, most significant features of an original, non MP remote work without issue. I tested: nunchuk, all buttons, tilt control, IR pointer. Motion plus continues to cause problems.
And on a NonMP controller, with the MP accessory, I get
|
Thanks for the info. When you have a non-motionplus controller without any extensions, does it still send "unknown extension" messages? @SpaceXCheeseWheel |
No. There is an error message, same one I mentioned up here: #934 (comment), but as far as I can tell this has no significant impact from what I tested. The full series of events is
These messages are repeated in the log every 2 seconds or so, as long as the controller is connected. |
Apparently that error happens when the application tries to access the Motion Plus when it's not connected, it's harmless |
I'm gonna make this as ready for review, my original intent was to bring Wiimote support to parity with Windows. I'm planning to submit another PR in a few days to change a decent chunk of the Wiimote code, including making Motion Plus work. |
Allows Wii remotes to be used on Linux and (probably) macOS devices.