Hello,
I am working on a program to control an arduino from a ds, and I have this code that converts all of the button input bools to a byte.
Code:
//pack buttons into a byte
if(keysHeld() & KEY_A) {
amount += 1;
} else if (keysHeld() & KEY_B) {
amount += 2;
} else if (keysHeld() & KEY_Y) {
amount += 4;
} else if (keysHeld() & KEY_X) {
amount += 8;
} else if (keysHeld() & KEY_L) {
amount += 16;
} else if (keysHeld() & KEY_R) {
amount += 32;
} else if (keysHeld() & KEY_START) {
amount += 64;
} else if (keysHeld() & KEY_SELECT) {
amount += 128;
} else {
amount = 0;
}
amount is a byte.
How can i do this more elegantly?