summaryrefslogtreecommitdiffstats
path: root/quantum/process_keycode/process_repeat_key.h
blob: eddc50f254c99e470653631ee2272f289127dbf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2022-2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "quantum.h"

/**
 * @brief Process handler for remembering the last key.
 *
 * @param keycode  Keycode registered by matrix press, per keymap
 * @param record   keyrecord_t structure
 * @return true    Continue processing keycodes, and send to host
 * @return false   Stop processing keycodes, and don't send to host
 */
bool process_last_key(uint16_t keycode, keyrecord_t* record);

/**
 * @brief Optional callback defining which keys are remembered.
 *
 * @param keycode          Keycode that was just pressed
 * @param record           keyrecord_t structure
 * @param remembered_mods  Mods that will be remembered with this key
 * @return true            Key is remembered
 * @return false           Key is ignored
 *
 * Modifier and layer switch keys are always ignored. For all other keys, this
 * callback is called on every key press. Returning true means that the key is
 * remembered, false means it is ignored. By default, all non-modifier,
 * non-layer switch keys are remembered.
 *
 * The `remembered_mods` arg represents the mods that will be remembered with
 * this key. It can be modified to forget certain mods, for instance to forget
 * capitalization when repeating shifted letters:
 *
 *     // Forget Shift on letter keys.
 *     if (KC_A <= keycode && keycode <= KC_Z && (*remembered_mods & ~MOD_MASK_SHIFT) == 0) {
 *         *remembered_mods = 0;
 *     }
 */
bool remember_last_key_user(uint16_t keycode, keyrecord_t* record, uint8_t* remembered_mods);

/**
 * @brief Process handler for Repeat Key feature.
 *
 * @param keycode  Keycode registered by matrix press, per keymap
 * @param record   keyrecord_t structure
 * @return true    Continue processing keycodes, and send to host
 * @return false   Stop processing keycodes, and don't send to host
 */
bool process_repeat_key(uint16_t keycode, keyrecord_t* record);