diff options
| author | Ralf Schmitt <ralf@bunkertor.net> | 2014-08-23 17:16:16 +0200 |
|---|---|---|
| committer | Ralf Schmitt <ralf@bunkertor.net> | 2014-08-24 16:31:12 +0200 |
| commit | af19f56ec98d27ab939b024effefcbebbab8f125 (patch) | |
| tree | a36580e1181affb90423987063d423a498479584 /keyboard/lightpad/keymap.c | |
| parent | 79840c678e13f9a737f80048bc3b9c9c55e3fc77 (diff) | |
| download | qmk_firmware-af19f56ec98d27ab939b024effefcbebbab8f125.tar.gz qmk_firmware-af19f56ec98d27ab939b024effefcbebbab8f125.zip | |
Support for Lightpad keypad
Diffstat (limited to 'keyboard/lightpad/keymap.c')
| -rw-r--r-- | keyboard/lightpad/keymap.c | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/keyboard/lightpad/keymap.c b/keyboard/lightpad/keymap.c new file mode 100644 index 000000000..6d078230b --- /dev/null +++ b/keyboard/lightpad/keymap.c | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2014 Ralf Schmitt <ralf@bunkertor.net> | ||
| 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 | |||
| 18 | #include <stdint.h> | ||
| 19 | #include <stdbool.h> | ||
| 20 | #include <avr/pgmspace.h> | ||
| 21 | #include "keycode.h" | ||
| 22 | #include "action.h" | ||
| 23 | #include "action_macro.h" | ||
| 24 | #include "report.h" | ||
| 25 | #include "host.h" | ||
| 26 | #include "debug.h" | ||
| 27 | #include "keymap.h" | ||
| 28 | |||
| 29 | /* Map physical keyboard layout to matrix array */ | ||
| 30 | #define KEYMAP( \ | ||
| 31 | K5A, K5B, K5C, K5D, \ | ||
| 32 | K4A, K4B, K4C, K4D, \ | ||
| 33 | K3A, K3B, K3C, K3D, \ | ||
| 34 | K2A, K2B, K2C, \ | ||
| 35 | K1A, K1B, K1C, K1D, \ | ||
| 36 | K0A, K0B, K0C \ | ||
| 37 | ) { \ | ||
| 38 | /* 0 1 2 3 */ \ | ||
| 39 | /* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D}, \ | ||
| 40 | /* 4 */ { KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D}, \ | ||
| 41 | /* 3 */ { KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D}, \ | ||
| 42 | /* 2 */ { KC_##K2A, KC_##K2B, KC_##K2C, KC_NO}, \ | ||
| 43 | /* 1 */ { KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D}, \ | ||
| 44 | /* 0 */ { KC_##K0A, KC_##K0B, KC_##K0C, KC_NO, } \ | ||
| 45 | } | ||
| 46 | |||
| 47 | #include "keymap_lightpad.h" | ||
| 48 | |||
| 49 | #define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0])) | ||
| 50 | #define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0])) | ||
| 51 | |||
| 52 | /* translates key to keycode */ | ||
| 53 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | ||
| 54 | { | ||
| 55 | if (layer < KEYMAPS_SIZE) { | ||
| 56 | return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); | ||
| 57 | } else { | ||
| 58 | // fall back to layer 0 | ||
| 59 | return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]); | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | /* translates Fn keycode to action */ | ||
| 64 | action_t keymap_fn_to_action(uint8_t keycode) | ||
| 65 | { | ||
| 66 | action_t action; | ||
| 67 | if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) { | ||
| 68 | action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); | ||
| 69 | } else { | ||
| 70 | action.code = ACTION_NO; | ||
| 71 | } | ||
| 72 | return action; | ||
| 73 | } | ||
