Skip to content

Commit 5e9b21d

Browse files
committed
core: Actionmap support
1 parent 75ca495 commit 5e9b21d

File tree

9 files changed

+586
-73
lines changed

9 files changed

+586
-73
lines changed

tmk_core/common.mk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ SRC += $(COMMON_DIR)/host.c \
66
$(COMMON_DIR)/action_macro.c \
77
$(COMMON_DIR)/action_layer.c \
88
$(COMMON_DIR)/action_util.c \
9-
$(COMMON_DIR)/keymap.c \
109
$(COMMON_DIR)/print.c \
1110
$(COMMON_DIR)/debug.c \
1211
$(COMMON_DIR)/util.c \
@@ -17,6 +16,13 @@ SRC += $(COMMON_DIR)/host.c \
1716

1817

1918
# Option modules
19+
ifdef ACTIONMAP_ENABLE
20+
SRC += $(COMMON_DIR)/actionmap.c
21+
OPT_DEFS += -DACTIONMAP_ENABLE
22+
else
23+
SRC += $(COMMON_DIR)/keymap.c
24+
endif
25+
2026
ifdef BOOTMAGIC_ENABLE
2127
SRC += $(COMMON_DIR)/bootmagic.c
2228
SRC += $(COMMON_DIR)/avr/eeconfig.c

tmk_core/common/action_code.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ enum layer_pram_tap_op {
251251
OP_OFF_ON,
252252
OP_SET_CLEAR,
253253
};
254-
#define ACTION_LAYER_BITOP(op, part, bits, on) (ACT_LAYER<<12 | (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
255-
#define ACTION_LAYER_TAP(layer, key) (ACT_LAYER_TAP<<12 | (layer)<<8 | (key))
254+
#define ACTION_LAYER_BITOP(op, part, bits, on) ACTION(ACT_LAYER, (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
255+
#define ACTION_LAYER_TAP(layer, key) ACTION(ACT_LAYER_TAP, (layer)<<8 | (key))
256256
/* Default Layer */
257257
#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer)/4, 1<<((layer)%4))
258258
#define ACTION_DEFAULT_LAYER_TOGGLE(layer) ACTION_DEFAULT_LAYER_BIT_XOR((layer)/4, 1<<((layer)%4))

tmk_core/common/action_layer.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ void layer_debug(void)
114114

115115
action_t layer_switch_get_action(keypos_t key)
116116
{
117-
action_t action;
118-
action.code = ACTION_TRANSPARENT;
117+
action_t action = { .code = ACTION_TRANSPARENT };
119118

120119
#ifndef NO_ACTION_LAYER
121120
uint32_t layers = layer_state | default_layer_state;

tmk_core/common/actionmap.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright 2015 Jun Wako <[email protected]>
3+
4+
This program is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 2 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
#include <stdint.h>
18+
#include "action_code.h"
19+
#include "actionmap.h"
20+
21+
/* Converts key to action */
22+
__attribute__ ((weak))
23+
action_t action_for_key(uint8_t layer, keypos_t key)
24+
{
25+
return (action_t)pgm_read_word(&actionmaps[(layer)][(key.row)][(key.col)]);
26+
}
27+
28+
/* Macro */
29+
__attribute__ ((weak))
30+
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
31+
{
32+
return MACRO_NONE;
33+
}
34+
35+
/* Function */
36+
__attribute__ ((weak))
37+
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
38+
{
39+
}

0 commit comments

Comments
 (0)