Skip to content

Instantly share code, notes, and snippets.

@Arachnid
Created December 10, 2013 10:53
Show Gist options
  • Select an option

  • Save Arachnid/7888833 to your computer and use it in GitHub Desktop.

Select an option

Save Arachnid/7888833 to your computer and use it in GitHub Desktop.
uint8_t row_counts[4];
for(int row = 0; row < NUM_ROWS; row++)
for(int col = 0; col < NUM_COLUMNS; col++)
row_counts[row] += (scan[col] >> row) & 1;
for(int col = 0; col < NUM_COLUMNS; col++) {
uint8_t column_count = set_bits[scan[col]];
for(int row = 0; row < NUM_ROWS; row++) {
if(row_counts[row] > 1 && column_count > 1)
// Key may be ghosted; skip it
continue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment