Counting bits set in a 32 bit value

Bruno Jesus 00cpxxx at
Mon Mar 23 09:47:44 CDT 2015

Hi all, after some manual testing I noticed that the joystick
structure member dwButtonNumber is not the last button pressed but
instead the count of pressed buttons. There is a bit field of buttons
set in the structure member dwButton, to fix the number in
dwButtonNumber I guess the easiest way is to count the bits set.

I think that keeping a counter with ++/-- operations could lead to out
of sync situations if the joystick is not polled fast enough.

Is there any precedent need for this in wine? Is there an accepted
solution for it? Internet searching shows different ways like bit
counting with shift, using cpu instructions or internal compiler

Best wishes,

More information about the wine-devel mailing list