https://bugs.winehq.org/show_bug.cgi?id=57759
Bug ID: 57759 Summary: Project64K Smash Edition does not read raphnet controller adapter input correctly Product: Wine Version: 10.0 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: braye@fastmail.com Distribution: ---
PJ64KSE packages a version of the raphnet PJ64 raw input plugin, which uses the hidapi library to read directly from a corresponding raphnet Nintendo 64 controller to USB adapter. The plugin uses hidapi to send and receive feature reports from the device.
When getting feature reports, hidapi uses DeviceIoControl with IOCTL_HID_GET_FEATURE and GetOverlappedResult to get the feature report from the specified device. This ioctl takes an int pointer which will contain the length of the data returned from the device when finished. The hidapi source code indicates that when numbered reports aren't used, the int pointer will only count the data returned from the device, sans the report number byte. hidapi adds 1 to this pointer if this is the case.
The device in question does not have numbered feature reports, so this is always the case.
This means that when the plugin code is run under wine, the int pointer is off-by-one. It reports that 65 bytes were returned, even though the buffer passed to the ioctl is 64 bytes and contains 64 bytes of data. Therefore, the plugin code does not read the input of the device as expected, since it checks this value and errors. If the plugin is patched to subtract 1 from the length variable before checking, the plugin works as expected.
P64KSE: https://github.com/smash64-dev/project64k-legacy/releases/tag/v2.5.2 pj64raphnetraw plugin: https://github.com/raphnet/pj64raphnetraw