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
Original game bug: Gamepads with more than 15 buttons can't bind buttons #104
Comments
I remember that I've made a workaround and you can set it in config file. If you know what's going on - could you make a PR here ? |
Sure - what are the "rules" for making code changes there? Does the binary size have to stay constant or can it change? My patch is going to make the affected function 2 or 3 bytes shorter, unless I pad it with nops. |
A few bytes / kilobytes doesn't matter. Do you change ASM only or C code, too? |
I can change both if that helps, it's a simple change (turning a bitwise OR into an increment). |
I thought about C wrapper, but C++ for ARM can be patched too - it's auto-generated, but if it's simple, you can do it manually 🙂 After your patch, the config file might be changed, because game will read all buttons - am I correct? |
Yep, 32 buttons aka the limit of the DInput version they used. |
In this case other than the ASM repo, where else should I apply this change? |
Here if possible |
Both are done, although I've not tested either. Considering how simple this change is and that it's been field-tested via a runtime patch, I would guess it's all fine. |
Thanks, currently I don't have any device with > 15 buttons to test. |
Me neither - but on Windows, an Xbone gamepad claims to have 16 buttons (despite having less physically), triggering the issue. |
Unlikely. |
I see.
|
Thanks for the PR! |
zaps166/NFSIISE-CPP#4 can probably also be merged. |
Merged, but this code is auto-generated 😄 Also axis 6 and 7 are working, I didn't know 😅 So we have 6 working axis! |
Ah, back then I misunderstood what did you mean by "patching C code". Either way, it's all solved now. Thanks! |
Disclaimer: I don't know if this is fixed in the project currently, I was only pointed at it when I tweeted about the original game bug with gamepad bindings. It goes as follows:
for
loop with a signed int16_t acting as the "number of buttons" (sub_404360
in my executable):IDirectInputDevice::GetObjectInfo
in a loop, like so (sub_421BD0
in my executable):The problem is - since this int16 representing the button count gets populated with a button bitmask, gamepads reporting 16 or more buttons stash a value
FFFF
in that count, that then gets interpreted as-1
by the for loop. The result - gamepad buttons cannot be bound at all.I see two ways to fix it:
dword_4E7388
becomes a button count and not a button bitmask. This is the approach I'm going to take in my standalone fix.GetObjectInfo
wrappers to never return more than 15 buttons. This will ensure that the button bitmask is at most7FFF
and therefore avoid underflow. I kind of recommend against this approach, because the game will still potentially do an equivalent offor ( i = 0; i < 32767; i++ )
every time it checks button presses.The text was updated successfully, but these errors were encountered: