Add action_tapping.[ch] for refactoring

This commit is contained in:
tmk
2013-03-29 00:56:34 +09:00
parent 366c759795
commit c69f7e1069
5 changed files with 397 additions and 369 deletions

View File

@ -2,6 +2,7 @@ COMMON_DIR = common
SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/keyboard.c \
$(COMMON_DIR)/action.c \
$(COMMON_DIR)/action_tapping.c \
$(COMMON_DIR)/action_oneshot.c \
$(COMMON_DIR)/action_macro.c \
$(COMMON_DIR)/layer_switch.c \

File diff suppressed because it is too large Load Diff

View File

@ -17,25 +17,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef ACTION_H
#define ACTION_H
#include <stdint.h>
#include <stdbool.h>
#include "keyboard.h"
#include "keycode.h"
#include "action_macro.h"
/* Struct to record event and tap count */
typedef union {
typedef struct {
keyevent_t event;
#ifndef NO_ACTION_TAPPING
/* tapping count and state */
struct {
bool interrupted :1;
bool reserved2 :1;
bool reserved1 :1;
bool reserved0 :1;
uint8_t count :4;
};
} tap_t;
typedef struct {
keyevent_t event;
tap_t tap;
} tap;
#endif
} keyrecord_t;
/* Action struct.
@ -99,9 +99,8 @@ const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t op
/* user defined special function */
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
/*
* Utilities for actions.
*/
/* Utilities for actions. */
void process_action(keyrecord_t *record);
void register_code(uint8_t code);
void unregister_code(uint8_t code);
void add_mods(uint8_t mods);
@ -112,7 +111,11 @@ void clear_keyboard_but_mods(void);
bool sending_anykey(void);
void layer_switch(uint8_t new_layer);
bool is_tap_key(key_t key);
bool waiting_buffer_has_anykey_pressed(void);
/* debug */
void debug_event(keyevent_t event);
void debug_record(keyrecord_t record);
void debug_action(action_t action);

330
common/action_tapping.c Normal file

File diff suppressed because it is too large Load Diff

40
common/action_tapping.h Normal file
View File

@ -0,0 +1,40 @@
/*
Copyright 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/>.
*/
#ifndef ACTION_TAPPING_H
#define ACTION_TAPPING_H
#ifndef NO_ACTION_TAPPING
/* period of tapping(ms) */
#ifndef TAPPING_TERM
#define TAPPING_TERM 200
#endif
/* tap count needed for toggling a feature */
#ifndef TAPPING_TOGGLE
#define TAPPING_TOGGLE 5
#endif
#define WAITING_BUFFER_SIZE 8
void action_tapping_process(keyrecord_t record);
#endif
#endif