Created
April 17, 2020 03:07
-
-
Save BenJuan26/5cf692e6ef1739dfeac2fec18a033cee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Get the states of the physical switches and write them to the Toggleswitch objects. | |
| // Assuming for now that all global variables referenced here are declared and initialized. | |
| void updateKeys() { | |
| if (!kpd.getKeys()) { | |
| return; | |
| } | |
| for (int i = 0; i < LIST_MAX; i++) { | |
| if (kpd.key[i].kchar == NO_KEY) { | |
| continue; | |
| } | |
| // Turn the key code (e.g. 'F') into a zero-based array index. | |
| int keyIndex = (int)kpd.key[i].kchar - keyOffset; | |
| KeyState state = kpd.key[i].kstate; | |
| if (state == PRESSED) { | |
| switches[keyIndex].currState = BUTTON_PRESSED; | |
| } else if (state == RELEASED) { | |
| switches[keyIndex].currState = BUTTON_RELEASED; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment