| 106 | } |
| 107 | |
| 108 | void processKeyValue( uint8_t keyValue ) |
| 109 | { |
| 110 | // Detect release condition |
| 111 | uint8_t release = keyValue & 0x80; |
| 112 | |
| 113 | // Finalize output buffer |
| 114 | // Mask 8th bit |
| 115 | keyValue &= 0x7F; |
| 116 | |
| 117 | // Key Release |
| 118 | if ( release ) |
| 119 | { |
| 120 | // Check for the released key, and shift the other keys lower on the buffer |
| 121 | uint8_t c; |
| 122 | for ( c = 0; c < KeyIndex_BufferUsed; c++ ) |
| 123 | { |
| 124 | // Key to release found |
| 125 | if ( KeyIndex_Buffer[c] == keyValue ) |
| 126 | { |
| 127 | // Shift keys from c position |
| 128 | for ( uint8_t k = c; k < KeyIndex_BufferUsed - 1; k++ ) |
| 129 | KeyIndex_Buffer[k] = KeyIndex_Buffer[k + 1]; |
| 130 | |
| 131 | // Decrement Buffer |
| 132 | KeyIndex_BufferUsed--; |
| 133 | |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // Error case (no key to release) |
| 139 | if ( c == KeyIndex_BufferUsed + 1 ) |
| 140 | { |
| 141 | errorLED( 1 ); |
| 142 | char tmpStr[6]; |
| 143 | hexToStr( keyValue, tmpStr ); |
| 144 | erro_dPrint( "Could not find key to release: ", tmpStr ); |
| 145 | } |
| 146 | } |
| 147 | // Press or Repeated Key |
| 148 | else |
| 149 | { |
| 150 | // Make sure the key isn't already in the buffer |
| 151 | for ( uint8_t c = 0; c < KeyIndex_BufferUsed + 1; c++ ) |
| 152 | { |
| 153 | // Key isn't in the buffer yet |
| 154 | if ( c == KeyIndex_BufferUsed ) |
| 155 | { |
| 156 | Macro_bufferAdd( keyValue ); |
| 157 | break; |
| 158 | } |
| 159 | |
| 160 | // Key already in the buffer |
| 161 | if ( KeyIndex_Buffer[c] == keyValue ) |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | } |
no test coverage detected
searching dependent graphs…