qmk-keychron-q3-colemak-dh/common/action.h

83 lines
2.1 KiB
C
Raw Normal View History

2013-01-28 06:06:42 +01: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/>.
*/
2012-12-15 18:32:07 +01:00
#ifndef ACTION_H
#define ACTION_H
#include <stdint.h>
#include <stdbool.h>
2012-12-15 18:32:07 +01:00
#include "keyboard.h"
2013-01-31 09:50:53 +01:00
#include "keycode.h"
2013-04-04 08:16:03 +02:00
#include "action_code.h"
2013-02-25 07:30:37 +01:00
#include "action_macro.h"
2012-12-15 18:32:07 +01:00
2013-01-27 08:38:19 +01:00
2014-06-16 17:57:59 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2013-04-04 20:27:10 +02:00
/* tapping count and state */
typedef struct {
bool interrupted :1;
bool reserved2 :1;
bool reserved1 :1;
bool reserved0 :1;
uint8_t count :4;
} tap_t;
2013-04-04 08:16:03 +02:00
/* Key event container for recording */
typedef struct {
keyevent_t event;
#ifndef NO_ACTION_TAPPING
2013-04-04 20:27:10 +02:00
tap_t tap;
#endif
2013-02-01 06:48:11 +01:00
} keyrecord_t;
2013-02-13 03:47:19 +01:00
/* Execute action per keyevent */
void action_exec(keyevent_t event);
/* action for key */
2014-06-16 17:57:59 +02:00
action_t action_for_key(uint8_t layer, keypos_t key);
2013-02-13 03:47:19 +01:00
2013-02-25 07:30:37 +01:00
/* macro */
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
2013-02-25 07:30:37 +01:00
2013-02-13 03:47:19 +01:00
/* user defined special function */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
/* Utilities for actions. */
void process_action(keyrecord_t *record);
2013-01-23 15:53:51 +01:00
void register_code(uint8_t code);
void unregister_code(uint8_t code);
void register_mods(uint8_t mods);
void unregister_mods(uint8_t mods);
//void set_mods(uint8_t mods);
2013-01-23 15:53:51 +01:00
void clear_keyboard(void);
void clear_keyboard_but_mods(void);
void layer_switch(uint8_t new_layer);
2014-06-16 17:57:59 +02:00
bool is_tap_key(keypos_t key);
/* debug */
void debug_event(keyevent_t event);
void debug_record(keyrecord_t record);
void debug_action(action_t action);
2013-01-23 15:53:51 +01:00
2014-06-16 17:57:59 +02:00
#ifdef __cplusplus
}
#endif
2012-12-15 18:32:07 +01:00
#endif /* ACTION_H */