librarize some functions

pull/18/head
jesse 11 years ago
parent 5f5eac1176
commit 22372f8b0d

@ -372,6 +372,65 @@ typedef struct {
boolean key_was_pressed (byte keyState)
{
if ( byte((keyState >> 4)) ^ B00001111 ) {
return false;
} else {
return true;
}
}
boolean key_was_not_pressed (byte keyState)
{
if ( byte((keyState >> 4)) ^ B00000000 ) {
return false;
} else {
return true;
}
}
boolean key_is_pressed (byte keyState)
{
if ( byte((keyState << 4)) ^ B11110000 ) {
return false;
} else {
return true;
}
}
boolean key_is_not_pressed (byte keyState)
{
if ( byte((keyState << 4)) ^ B00000000 ) {
return false;
} else {
return true;
}
}
boolean key_toggled_on(byte keyState)
{
if (key_is_pressed(keyState) && key_was_not_pressed(keyState)) {
return true;
} else {
return false;
}
}
boolean key_toggled_off(byte keyState)
{
if (key_was_pressed(keyState) && key_is_not_pressed(keyState)) {
return true;
} else {
return false;
}
}
//Do not add code below this line

@ -110,65 +110,6 @@ void record_key_being_pressed(byte character)
}
}
boolean key_was_pressed (byte keyState)
{
if ( byte((keyState >> 4)) ^ B00001111 ) {
return false;
} else {
return true;
}
}
boolean key_was_not_pressed (byte keyState)
{
if ( byte((keyState >> 4)) ^ B00000000 ) {
return false;
} else {
return true;
}
}
boolean key_is_pressed (byte keyState)
{
if ( byte((keyState << 4)) ^ B11110000 ) {
return false;
} else {
return true;
}
}
boolean key_is_not_pressed (byte keyState)
{
if ( byte((keyState << 4)) ^ B00000000 ) {
return false;
} else {
return true;
}
}
boolean key_toggled_on(byte keyState)
{
if (key_is_pressed(keyState) && key_was_not_pressed(keyState)) {
return true;
} else {
return false;
}
}
boolean key_toggled_off(byte keyState)
{
if (key_was_pressed(keyState) && key_is_not_pressed(keyState)) {
return true;
} else {
return false;
}
}
void reset_matrix()
{
for (int col = 0; col < COLS; col++) {

Loading…
Cancel
Save