aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_wpm.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/feature_wpm.md')
-rw-r--r--docs/feature_wpm.md67
1 files changed, 52 insertions, 15 deletions
diff --git a/docs/feature_wpm.md b/docs/feature_wpm.md
index 12dd08057..c8ec3a7f3 100644
--- a/docs/feature_wpm.md
+++ b/docs/feature_wpm.md
@@ -1,25 +1,62 @@
1# Word Per Minute (WPM) Calculcation 1# Word Per Minute (WPM) Calculcation
2 2
3The WPM feature uses time between keystrokes to compute a rolling average words 3The WPM feature uses time between keystrokes to compute a rolling average words per minute rate and makes this available for various uses.
4per minute rate and makes this available for various uses.
5 4
6Enable the WPM system by adding this to your `rules.mk`: 5Enable the WPM system by adding this to your `rules.mk`:
7 6
8 WPM_ENABLE = yes 7 WPM_ENABLE = yes
9 8
10For split keyboards using soft serial, the computed WPM 9For split keyboards using soft serial, the computed WPM score will be available on the master AND slave half.
11score will be available on the master AND slave half.
12 10
13## Public Functions 11## Configuration
14
15`uint8_t get_current_wpm(void);`
16This function returns the current WPM as an unsigned integer.
17 12
13|Define |Default | Description |
14|-----------------------------|--------------|------------------------------------------------------------------------------------------|
15|`WPM_SMOOTHING` |`0.0487` | Sets the smoothing to about 40 keystrokes |
16|`WPM_ESTIMATED_WORD_SIZE` |`5` | This is the value used when estimating average word size (for regression and normal use) |
17|`WPM_ALLOW_COUNT_REGRESSOIN` |_Not defined_ | If defined allows the WPM to be decreased when hitting Delete or Backspace |
18## Public Functions
18 19
19## Customized keys for WPM calc 20|Function |Description |
20 21|--------------------------|--------------------------------------------------|
21By default, the WPM score only includes letters, numbers, space and some 22|`get_current_wpm(void)` | Returns the current WPM as a value between 0-255 |
22punctuation. If you want to change the set of characters considered as part of 23|`set_current_wpm(x)` | Sets the current WPM to `x` (between 0-255) |
23the WPM calculation, you can implement `wpm_keycode_user(uint16_t keycode)` 24
24and return true for any characters you would like included in the calculation, 25## Callbacks
25or false to not count that particular keycode. 26
27By default, the WPM score only includes letters, numbers, space and some punctuation. If you want to change the set of characters considered as part of the WPM calculation, you can implement your own `bool wpm_keycode_user(uint16_t keycode)` and return true for any characters you would like included in the calculation, or false to not count that particular keycode.
28
29For instance, the default is:
30
31```c
32bool wpm_keycode_user(uint16_t keycode) {
33 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
34 keycode = keycode & 0xFF;
35 } else if (keycode > 0xFF) {
36 keycode = 0;
37 }
38 if ((keycode >= KC_A && keycode <= KC_0) || (keycode >= KC_TAB && keycode <= KC_SLASH)) {
39 return true;
40 }
41
42 return false;
43}
44```
45
46Additionally, if `WPM_ALLOW_COUNT_REGRESSION` is defined, there is the `uint8_t wpm_regress_count(uint16_t keycode)` function that allows you to decrease the WPM. This is useful if you want to be able to penalize certain keycodes (or even combinations).
47
48__attribute__((weak)) uint8_t wpm_regress_count(uint16_t keycode) {
49 bool weak_modded = (keycode >= QK_LCTL && keycode < QK_LSFT) || (keycode >= QK_RCTL && keycode < QK_RSFT);
50
51 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX) || (keycode >= QK_MODS && keycode <= QK_MODS_MAX)) {
52 keycode = keycode & 0xFF;
53 } else if (keycode > 0xFF) {
54 keycode = 0;
55 }
56 if (((get_mods() | get_oneshot_mods()) & MOD_MASK_CTRL} || weak_modded) && (keycode == KC_DEL || keycode == KC_BSPC)) {
57 return WPM_ESTIMATED_WORD_SIZE;
58 }
59 if (keycode == KC_DEL || keycode == KC_BSPC) {
60 return 1;
61 }
62}