Fix a dumb logic bug in debouncing code

pull/18/head
Jesse Vincent 10 years ago
parent 7dd32e82c4
commit 40111a970a

@ -6,35 +6,41 @@
boolean key_was_pressed (byte keyState) boolean key_was_pressed (byte keyState)
{ {
if ( byte((keyState >> 7)) ^ B00000001 ) { return (! key_was_not_pressed(keyState));
return false;
} else {
return true;
}
} }
boolean key_was_not_pressed (byte keyState) boolean key_was_not_pressed (byte keyState)
{ {
if ( keyState & B00001000 || keyState & B00000100) {
return false;
} else {
return true;
}
return !key_was_pressed(keyState);
} }
boolean key_is_pressed (byte keyState) boolean key_is_pressed (byte keyState)
{ {
if ( byte((keyState << 7)) ^ B10000000 ) { if ( keyState & B00000001 && keyState & B00000010 ){
return false;
} else {
return true; return true;
} else {
return false;
} }
} }
boolean key_is_not_pressed (byte keyState) boolean key_is_not_pressed (byte keyState)
{ {
return(!key_is_pressed(keyState)); return !key_is_pressed(keyState);
} }
boolean key_toggled_on(byte keyState) boolean key_toggled_on(byte keyState)

Loading…
Cancel
Save