Skip to content

Instantly share code, notes, and snippets.

@JoshuaGrams
Created August 23, 2017 17:08
Show Gist options
  • Save JoshuaGrams/5ae4c740ccf07dc4cba6d9ebe9700b2f to your computer and use it in GitHub Desktop.
Save JoshuaGrams/5ae4c740ccf07dc4cba6d9ebe9700b2f to your computer and use it in GitHub Desktop.
First-up chord algorithm
Chord prev_keys = NONE, can_trigger = ALL;
void process_sample(Chord keys) {
Chord released = prev_keys & ~keys;
if(released & can_trigger) {
send_chord(prev_keys);
// These keys do not fire a chord the next time they are released.
can_trigger = ~keys;
}
prev_keys = keys;
// Keys which have been released can now fire a chord again.
can_trigger |= ~keys;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment