diff options
author | tmk <nobody@nowhere> | 2013-10-31 12:30:42 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-10-31 12:30:42 +0900 |
commit | eea3b699a6cf9976fc0179633feee6d079e5db78 (patch) | |
tree | 45bba06cc6b5541f7019345372e25f5a3ef1f9a7 /keyboard/onekey/keymap.c | |
parent | b9fe36f237635db8e37fc94413a7bb7c381070fc (diff) | |
parent | b6677f10e33bfa49557dfebd0226928477ede56a (diff) |
Merge branch 'onekey'
Diffstat (limited to 'keyboard/onekey/keymap.c')
-rw-r--r-- | keyboard/onekey/keymap.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/keyboard/onekey/keymap.c b/keyboard/onekey/keymap.c new file mode 100644 index 0000000000..90f195c2b7 --- /dev/null +++ b/keyboard/onekey/keymap.c @@ -0,0 +1,66 @@ +/* +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/>. +*/ +#include <stdint.h> +#include <stdbool.h> +#include <avr/pgmspace.h> +#include "keycode.h" +#include "action.h" +#include "action_macro.h" +#include "report.h" +#include "host.h" +#include "print.h" +#include "debug.h" +#include "keymap.h" + + +static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + {{KC_A}}, +}; + +/* + * Fn action definition + */ +static const uint16_t PROGMEM fn_actions[] = { +}; + + + +#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) +#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) + +/* translates key to keycode */ +uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) +{ + if (layer < KEYMAPS_SIZE) { + return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); + } else { + // fall back to layer 0 + return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]); + } +} + +/* translates Fn keycode to action */ +action_t keymap_fn_to_action(uint8_t keycode) +{ + action_t action; + if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { + action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); + } else { + action.code = ACTION_NO; + } + return action; +} |