-
Bug
-
Resolution: Invalid
-
None
-
1.20.4, 24w05b
-
None
-
Plausible
-
(Unassigned)
The bug
When handling control bindings, Minecraft uses a signed integer for mouse buttons, which conflicts with the official USB Human Interface Devices documentation for input buttons, in which only 0x0000 to 0xFFFF (0 to 65535) are defined: https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf
As a result, it is possible for Minecraft to store and display controls which are assigned to mouse buttons 65536 and above, all the way to 2147483647. It can also display controls bound to negative mouse buttons (-1 to -2147483648), which do not exist either.
How to reproduce
- Have a control bound to a mouse button below 0 or above 65535. (This would normally be impossible as per MC-266231, however before 17w43a attempting to bind a control to mouse button 6 would result in it instead being bound to mouse button 10, and the game can be updated to 1.19 and then repeatedly closed and reopened in 1.19 to increase this value due to
MC-254355, which should eventually result in it exceeding 65535. Alternatively, just edit options.txt.) - Reload the game and then check the Key Binds menu
Expected results
Whatever control was bound to the illegal mouse button should be set to "Not Bound". This is what happens normally when an illegal key binding is encountered.
Actual results
The game interprets these illegal mouse buttons as completely valid.
How to fix
Instead of handling mouse buttons using a signed integer, an unsigned short should be used instead, as it perfectly contains all valid mouse button input values.
Further notes
It should be noted that "Button 0" is also a reserved control, so even though it's an acceptable value for an unsigned short, it may be advisable for Minecraft to consider it invalid as with the aforementioned extreme cases.