Skip to content

Commit

Permalink
core: Actionmap support
Browse files Browse the repository at this point in the history
  • Loading branch information
tmk committed Mar 3, 2016
1 parent 75ca495 commit 5e9b21d
Show file tree
Hide file tree
Showing 9 changed files with 586 additions and 73 deletions.
8 changes: 7 additions & 1 deletion tmk_core/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ SRC += $(COMMON_DIR)/host.c \
$(COMMON_DIR)/action_macro.c \
$(COMMON_DIR)/action_layer.c \
$(COMMON_DIR)/action_util.c \
$(COMMON_DIR)/keymap.c \
$(COMMON_DIR)/print.c \
$(COMMON_DIR)/debug.c \
$(COMMON_DIR)/util.c \
Expand All @@ -17,6 +16,13 @@ SRC += $(COMMON_DIR)/host.c \


# Option modules
ifdef ACTIONMAP_ENABLE
SRC += $(COMMON_DIR)/actionmap.c
OPT_DEFS += -DACTIONMAP_ENABLE
else
SRC += $(COMMON_DIR)/keymap.c
endif

ifdef BOOTMAGIC_ENABLE
SRC += $(COMMON_DIR)/bootmagic.c
SRC += $(COMMON_DIR)/avr/eeconfig.c
Expand Down
4 changes: 2 additions & 2 deletions tmk_core/common/action_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ enum layer_pram_tap_op {
OP_OFF_ON,
OP_SET_CLEAR,
};
#define ACTION_LAYER_BITOP(op, part, bits, on) (ACT_LAYER<<12 | (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
#define ACTION_LAYER_TAP(layer, key) (ACT_LAYER_TAP<<12 | (layer)<<8 | (key))
#define ACTION_LAYER_BITOP(op, part, bits, on) ACTION(ACT_LAYER, (op)<<10 | (on)<<8 | (part)<<5 | ((bits)&0x1f))
#define ACTION_LAYER_TAP(layer, key) ACTION(ACT_LAYER_TAP, (layer)<<8 | (key))
/* Default Layer */
#define ACTION_DEFAULT_LAYER_SET(layer) ACTION_DEFAULT_LAYER_BIT_SET((layer)/4, 1<<((layer)%4))
#define ACTION_DEFAULT_LAYER_TOGGLE(layer) ACTION_DEFAULT_LAYER_BIT_XOR((layer)/4, 1<<((layer)%4))
Expand Down
3 changes: 1 addition & 2 deletions tmk_core/common/action_layer.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ void layer_debug(void)

action_t layer_switch_get_action(keypos_t key)
{
action_t action;
action.code = ACTION_TRANSPARENT;
action_t action = { .code = ACTION_TRANSPARENT };

#ifndef NO_ACTION_LAYER
uint32_t layers = layer_state | default_layer_state;
Expand Down
39 changes: 39 additions & 0 deletions tmk_core/common/actionmap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2015 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/>.
*/
#include <stdint.h>
#include "action_code.h"
#include "actionmap.h"

/* Converts key to action */
__attribute__ ((weak))
action_t action_for_key(uint8_t layer, keypos_t key)
{
return (action_t)pgm_read_word(&actionmaps[(layer)][(key.row)][(key.col)]);
}

/* Macro */
__attribute__ ((weak))
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
return MACRO_NONE;
}

/* Function */
__attribute__ ((weak))
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
}
Loading

0 comments on commit 5e9b21d

Please sign in to comment.