diff options
author | tmk <nobody@nowhere> | 2013-08-05 16:22:08 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-08-05 16:23:17 +0900 |
commit | b6677f10e33bfa49557dfebd0226928477ede56a (patch) | |
tree | 1716eca59ab7edc0b4084559db18e2822d67117a /keyboard/onekey/keymap.c | |
parent | 60103a12b2ca0a572da1e72eb46bff19c499fc95 (diff) |
Add files for onekey(issue #56)
- https://github.com/tmk/tmk_keyboard/issues/56
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; +} |