2015-04-09 18:32:04 +02:00
|
|
|
/*
|
|
|
|
Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2020-12-26 05:56:11 +01:00
|
|
|
|
|
|
|
#pragma once
|
2015-04-09 18:32:04 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2022-01-24 23:20:08 +01:00
|
|
|
#include "progmem.h"
|
2015-04-09 18:32:04 +02:00
|
|
|
#include "keyboard.h"
|
|
|
|
#include "keycode.h"
|
|
|
|
#include "action_code.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-09-13 01:48:11 +02:00
|
|
|
#ifndef TAP_CODE_DELAY
|
|
|
|
# define TAP_CODE_DELAY 0
|
|
|
|
#endif
|
|
|
|
#ifndef TAP_HOLD_CAPS_DELAY
|
|
|
|
# define TAP_HOLD_CAPS_DELAY 80
|
|
|
|
#endif
|
|
|
|
|
2015-04-09 18:32:04 +02:00
|
|
|
/* tapping count and state */
|
|
|
|
typedef struct {
|
2019-08-30 20:19:03 +02:00
|
|
|
bool interrupted : 1;
|
|
|
|
bool reserved2 : 1;
|
|
|
|
bool reserved1 : 1;
|
|
|
|
bool reserved0 : 1;
|
|
|
|
uint8_t count : 4;
|
2015-04-09 18:32:04 +02:00
|
|
|
} tap_t;
|
|
|
|
|
|
|
|
/* Key event container for recording */
|
|
|
|
typedef struct {
|
2019-08-30 20:19:03 +02:00
|
|
|
keyevent_t event;
|
2015-04-09 18:32:04 +02:00
|
|
|
#ifndef NO_ACTION_TAPPING
|
|
|
|
tap_t tap;
|
|
|
|
#endif
|
2023-05-20 14:35:06 +02:00
|
|
|
#if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
|
2021-08-06 01:44:57 +02:00
|
|
|
uint16_t keycode;
|
|
|
|
#endif
|
2015-04-09 18:32:04 +02:00
|
|
|
} keyrecord_t;
|
|
|
|
|
|
|
|
/* Execute action per keyevent */
|
|
|
|
void action_exec(keyevent_t event);
|
|
|
|
|
|
|
|
/* action for key */
|
|
|
|
action_t action_for_key(uint8_t layer, keypos_t key);
|
2021-08-06 01:44:57 +02:00
|
|
|
action_t action_for_keycode(uint16_t keycode);
|
2015-04-09 18:32:04 +02:00
|
|
|
|
2016-03-28 16:12:50 +02:00
|
|
|
/* keyboard-specific key event (pre)processing */
|
2016-05-15 06:47:25 +02:00
|
|
|
bool process_record_quantum(keyrecord_t *record);
|
2016-03-27 17:58:26 +02:00
|
|
|
|
2015-04-09 18:32:04 +02:00
|
|
|
/* Utilities for actions. */
|
2018-09-17 19:48:02 +02:00
|
|
|
#if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
|
2016-03-13 00:18:20 +01:00
|
|
|
extern bool disable_action_cache;
|
|
|
|
#endif
|
2016-07-27 17:43:02 +02:00
|
|
|
|
|
|
|
/* Code for handling one-handed key modifiers. */
|
2018-03-11 22:07:02 +01:00
|
|
|
#ifdef SWAP_HANDS_ENABLE
|
2022-02-21 17:29:54 +01:00
|
|
|
extern bool swap_hands;
|
2021-05-10 08:21:09 +02:00
|
|
|
extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
|
2019-08-30 20:19:03 +02:00
|
|
|
# if (MATRIX_COLS <= 8)
|
|
|
|
typedef uint8_t swap_state_row_t;
|
|
|
|
# elif (MATRIX_COLS <= 16)
|
|
|
|
typedef uint16_t swap_state_row_t;
|
|
|
|
# elif (MATRIX_COLS <= 32)
|
|
|
|
typedef uint32_t swap_state_row_t;
|
|
|
|
# else
|
|
|
|
# error "MATRIX_COLS: invalid value"
|
|
|
|
# endif
|
2016-07-27 17:43:02 +02:00
|
|
|
|
2023-04-09 18:37:31 +02:00
|
|
|
/**
|
|
|
|
* @brief Enable swap hands
|
|
|
|
*/
|
|
|
|
void swap_hands_on(void);
|
|
|
|
/**
|
|
|
|
* @brief Disable swap hands
|
|
|
|
*/
|
|
|
|
void swap_hands_off(void);
|
|
|
|
/**
|
|
|
|
* @brief Toggle swap hands enable state
|
|
|
|
*/
|
|
|
|
void swap_hands_toggle(void);
|
2023-02-14 21:44:18 +01:00
|
|
|
/**
|
|
|
|
* @brief Get the swap hands enable state
|
|
|
|
*
|
|
|
|
* @return true
|
|
|
|
* @return false
|
|
|
|
*/
|
|
|
|
bool is_swap_hands_on(void);
|
2023-04-09 18:37:31 +02:00
|
|
|
|
2016-07-27 17:43:02 +02:00
|
|
|
void process_hand_swap(keyevent_t *record);
|
|
|
|
#endif
|
|
|
|
|
2016-05-15 06:47:25 +02:00
|
|
|
void process_record_nocache(keyrecord_t *record);
|
|
|
|
void process_record(keyrecord_t *record);
|
2020-03-22 14:29:05 +01:00
|
|
|
void process_record_handler(keyrecord_t *record);
|
|
|
|
void post_process_record_quantum(keyrecord_t *record);
|
2016-05-15 06:47:25 +02:00
|
|
|
void process_action(keyrecord_t *record, action_t action);
|
2015-04-09 18:32:04 +02:00
|
|
|
void register_code(uint8_t code);
|
|
|
|
void unregister_code(uint8_t code);
|
2018-12-14 18:01:58 +01:00
|
|
|
void tap_code(uint8_t code);
|
2021-02-16 21:26:52 +01:00
|
|
|
void tap_code_delay(uint8_t code, uint16_t delay);
|
2015-04-09 18:32:04 +02:00
|
|
|
void register_mods(uint8_t mods);
|
|
|
|
void unregister_mods(uint8_t mods);
|
2019-10-16 01:02:09 +02:00
|
|
|
void register_weak_mods(uint8_t mods);
|
|
|
|
void unregister_weak_mods(uint8_t mods);
|
2019-08-30 20:19:03 +02:00
|
|
|
// void set_mods(uint8_t mods);
|
2015-04-09 18:32:04 +02:00
|
|
|
void clear_keyboard(void);
|
|
|
|
void clear_keyboard_but_mods(void);
|
2018-12-28 20:07:56 +01:00
|
|
|
void clear_keyboard_but_mods_and_keys(void);
|
2015-04-09 18:32:04 +02:00
|
|
|
void layer_switch(uint8_t new_layer);
|
2021-08-06 01:44:57 +02:00
|
|
|
bool is_tap_record(keyrecord_t *record);
|
2018-04-25 12:14:27 +02:00
|
|
|
bool is_tap_action(action_t action);
|
2015-04-09 18:32:04 +02:00
|
|
|
|
2018-03-12 18:22:49 +01:00
|
|
|
#ifndef NO_ACTION_TAPPING
|
|
|
|
void process_record_tap_hint(keyrecord_t *record);
|
|
|
|
#endif
|
|
|
|
|
2022-12-15 23:38:25 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helpers
|
|
|
|
|
|
|
|
#ifdef ACTION_DEBUG
|
|
|
|
# include "debug.h"
|
|
|
|
# include "print.h"
|
|
|
|
# define ac_dprintf(...) dprintf(__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
# define ac_dprintf(...) \
|
|
|
|
do { \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
|
2015-04-09 18:32:04 +02:00
|
|
|
void debug_event(keyevent_t event);
|
|
|
|
void debug_record(keyrecord_t record);
|
|
|
|
void debug_action(action_t action);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|