]> git.donarmstrong.com Git - qmk_firmware.git/blob - docs/feature_debounce_algo.md
Removed check for custom_matrix. We can safely include the debounce file for compilat...
[qmk_firmware.git] / docs / feature_debounce_algo.md
1 # Debounce algorithm
2
3 QMK supports multiple debounce algorithms through its debounce API.
4
5 The underlying debounce algorithm is determined by which matrix.c file you are using.
6
7 The logic for which debounce method called is below. It checks various defines that you have set in rules.mk
8
9 ```
10 ifeq ($(strip $(DEBOUNCE_ALGO)), manual)
11     # Do nothing. do your debouncing in matrix.c
12 else ifeq ($(strip $(DEBOUNCE_ALGO)), sym_g)
13     QUANTUM_SRC += $(DEBOUNCE)/debounce_sym_g.c
14 else ifeq ($(strip $(DEBOUNCE_ALGO)), eager_pk)
15     QUANTUM_SRC += $(DEBOUNCE)/debounce_eager_pk.c
16 else # default algorithm
17     QUANTUM_SRC += $(DEBOUNCE)/debounce_sym_g.c
18 endif
19 ```
20
21 # Debounce selection
22
23 | DEBOUNCE_ALGO    | Description                                                 | What to do                    |
24 | -------------    | ---------------------------------------------------         | ----------------------------- |
25 | Not defined      | You are using the included matrix.c and debounce.c          | Nothing. Debounce_sym_g will be compiled, and used if necessary |
26 | manual           | Use your own debounce.c                                     | ```SRC += debounce.c``` add your own debounce.c and implement necessary functions |
27 | sym_g / eager_pk | You are using the included matrix.c and debounce.c          | Use an alternative debounce algorithm |
28
29 **Regarding split keyboards**: 
30 The debounce code is compatible with split keyboards.
31
32 # Use your own debouncing code
33 * Set ```DEBOUNCE_ALGO = manual```.
34 * Add ```SRC += debounce.c```
35 * Add your own ```debounce.c```. Look at included ```debounce_sym_g.c```s for sample implementations.
36 * Debouncing occurs after every raw matrix scan.
37
38 # Changing between included debouncing methods
39 You can either use your own code, by including your own debounce.c, or switch to another included one.
40 Included debounce methods are:
41 * debounce_eager_pk - debouncing per key. On any state change, response is immediate, followed by ```DEBOUNCE_DELAY``` millseconds of no further input for that key
42 * debounce_sym_g - debouncing per keyboard. On any state change, a global timer is set. When ```DEBOUNCE_DELAY``` milliseconds of no changes has occured, all input changes are pushed.
43
44