-
-
Notifications
You must be signed in to change notification settings - Fork 40.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split split_common transport and debounce code into their own files
Can now be replaced with custom versions per keyboard using CUSTOM_TRANSPORT = yes and CUSTOM_DEBOUNCE = yes
- Loading branch information
Showing
12 changed files
with
317 additions
and
297 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
#include "matrix.h" | ||
#include "config.h" | ||
#include "timer.h" | ||
#include "quantum.h" | ||
|
||
#define ROWS_PER_HAND (MATRIX_ROWS/2) | ||
|
||
#ifndef DEBOUNCING_DELAY | ||
# define DEBOUNCING_DELAY 5 | ||
#endif | ||
|
||
#if DEBOUNCING_DELAY > 0 | ||
|
||
void debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) | ||
{ | ||
static uint16_t debouncing_time; | ||
static bool debouncing = false; | ||
|
||
if (changed) | ||
{ | ||
debouncing = true; | ||
debouncing_time = timer_read(); | ||
} | ||
|
||
if (debouncing && (timer_elapsed(debouncing_time) > DEBOUNCING_DELAY)) { | ||
for (uint8_t i = 0; i < ROWS_PER_HAND/2; i++) { | ||
cooked[i] = raw[i]; | ||
} | ||
debouncing = false; | ||
} | ||
} | ||
|
||
#else | ||
|
||
// no debounce | ||
bool debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed) | ||
{ | ||
if (changed) | ||
{ | ||
for (uint8_t i = 0; i < ROWS_PER_HAND/2; i++) { | ||
cooked[i] = raw[i]; | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
// raw is the current key state | ||
// on entry cooked is the previous debounced state | ||
// on exit cooked is the current debounced state | ||
// changed is true if raw has changed since the last call | ||
void debounce(matrix_row_t raw[], matrix_row_t cooked[], bool changed); |
This file contains 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
This file contains 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
Oops, something went wrong.