- if (matrix[i] != (uint8_t)~read_col(i)) {
- matrix[i] = (uint8_t)~read_col(i);
- if (debouncing) {
- debug("bounce!: "); debug_hex(debouncing); print("\n");
- }
- debouncing = DEBOUNCE;
- }
- }
+ if ( i == ( MATRIX_ROWS - 1 ) ) { // CHECK CAPS LOCK
+ if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { // CAPS LOCK is ON on HOST
+ if ( ~read_col(i) & (1<< 4) ) { // CAPS LOCK is still DOWN ( 0bXXX1_XXXX)
+ matrix[i] = ~read_col(i) & 0b11101111; // change CAPS LOCK as released
+ } else { // CAPS LOCK in UP
+ matrix[i] = ~read_col(i) | 0b00010000; // send fake caps lock down
+ }
+ } else { // CAPS LOCK is OFF on HOST
+ if (matrix[i] != (uint8_t)~read_col(i)) {
+ matrix[i] = (uint8_t)~read_col(i);
+ if (debouncing) {
+ debug("bounce!: "); debug_hex(debouncing); print("\n");
+ }
+ debouncing = DEBOUNCE;
+ }
+ }
+ } else {
+ if (matrix[i] != (uint8_t)~read_col(i)) {
+ matrix[i] = (uint8_t)~read_col(i);
+ if (debouncing) {
+ debug("bounce!: "); debug_hex(debouncing); print("\n");
+ }
+ debouncing = DEBOUNCE;
+ }
+ }
+ }