smallestButton function
- int buttons
Returns the button of buttons
with the smallest integer.
The buttons
parameter is a bit field where each set bit represents a button.
This function returns the set bit closest to the least significant bit.
It returns zero when buttons
is zero.
Example:
assert(smallestButton(0x01) == 0x01);
assert(smallestButton(0x11) == 0x01);
assert(smallestButton(0x10) == 0x10);
assert(smallestButton(0) == 0);
See also:
- isSingleButton, which checks if a
buttons
contains exactly one button.
Implementation
int smallestButton(int buttons) => buttons & (-buttons);