]> git.donarmstrong.com Git - kiibohd-controller.git/commitdiff
Adding array sizes (fixing the extra key problem)
authorJacob Alexander <triplehaata@gmail.com>
Mon, 21 Mar 2011 23:49:43 +0000 (16:49 -0700)
committerJacob Alexander <triplehaata@gmail.com>
Mon, 21 Mar 2011 23:49:43 +0000 (16:49 -0700)
main.c

diff --git a/main.c b/main.c
index 28b372b4ae39443cc6aea52bc4c42869a492e9db..309aa432f2bd202edf8cc96c73145170aca40624 100644 (file)
--- a/main.c
+++ b/main.c
@@ -334,8 +334,8 @@ inline void pinSetup(void)
        PORTF = 0xFF;
 }
 
-void keyPressDetection( uint8_t *keys, uint8_t *validKeys) {
-       for ( uint8_t key = 0; key < KEYBOARD_SIZE + 1; key++ ) {
+void keyPressDetection( uint8_t *keys, uint8_t *validKeys, uint8_t numberOfKeys ) {
+       for ( uint8_t key = 0; key < numberOfKeys + 1; key++ ) {
                if ( keys[key] & (1 << 7) ) {
                        pint8( key );
                        print(" ");
@@ -431,8 +431,8 @@ int main( void )
 
                // Detect Valid Keypresses - TODO
                uint8_t validKeys = 0;
-               keyPressDetection( keyDetectArray, &validKeys );
-               keyPressDetection( keypadDetectArray, &validKeys );
+               keyPressDetection( keyDetectArray, &validKeys, KEYBOARD_SIZE );
+               keyPressDetection( keypadDetectArray, &validKeys, KEYPAD_SIZE );
                print(":\n");
 
                // TODO undo potentially old keys