mirror of
https://github.com/cemu-project/Cemu.git
synced 2026-07-09 17:14:47 -06:00
Fix bitwise operation for button state check
Classic buttons are shifted up by kHighestWiimote (20) before being stored, so they occupy bits 21–35 of the uint64 buttons variable. When the loop checks those bits with (1 << i), 1 is a plain 32-bit int. Shifting it by 32 or more is undefined behaviour — in practice on x86 it wraps modulo 32, so on x86 A (bit 32) → mask becomes 1 << 0 → becomes X B (bit 34) → mask becomes 1 << 2 → X Y (bit 33) → mask becomes 1 << 1 → X ZL (bit 35) → mask becomes 1 << 3 → also X X (bit 31) → mask is 1 << 31 → still within 32 bits → expectedly, X. change to 1ULL so it all works properly
This commit is contained in:
parent
6648a9c225
commit
77d5e09576
@ -232,7 +232,7 @@ ControllerState NativeWiimoteController::raw_state()
|
||||
for (int i = 0; i < std::numeric_limits<uint64>::digits; i++)
|
||||
{
|
||||
// OR with base buttons
|
||||
if((buttons & (1 << i)))
|
||||
if((buttons & (1ULL << i)))
|
||||
result.buttons.SetButtonState(i, true);
|
||||
}
|
||||
result.axis = classic.left_axis;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user