]> git.gir.st - tmk_keyboard.git/blob - common/keymap.c
Add macro feature.
[tmk_keyboard.git] / common / keymap.c
1 /*
2 Copyright 2013 Jun Wako <wakojun@gmail.com>
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 "keymap.h"
18 #include "report.h"
19 #include "keycode.h"
20
21
22 /* layer */
23 uint8_t default_layer = 0;
24 uint8_t current_layer = 0;
25
26
27 #ifndef NO_LEGACY_KEYMAP_SUPPORT
28 /* legacy support with weak reference */
29 __attribute__ ((weak))
30 action_t keymap_get_action(uint8_t layer, uint8_t row, uint8_t col)
31 {
32 /* convert from legacy keycode to action */
33 uint8_t key = keymap_get_keycode(layer, row, col);
34 action_t action;
35 switch (key) {
36 case KC_A ... KC_EXSEL:
37 action.code = ACTION_KEY(key);
38 break;
39 case KC_LCTRL ... KC_LGUI:
40 action.code = ACTION_LMOD(key);
41 break;
42 case KC_RCTRL ... KC_RGUI:
43 action.code = ACTION_RMOD(key);
44 break;
45 case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
46 action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(key));
47 break;
48 case KC_AUDIO_MUTE ... KC_WWW_FAVORITES:
49 action.code = ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(key));
50 break;
51 case KC_MS_UP ... KC_MS_ACCEL2:
52 action.code = ACTION_MOUSEKEY(key);
53 break;
54 case KC_FN0 ... KC_FN31:
55 {
56 uint8_t layer = keymap_fn_layer(FN_INDEX(key));
57 uint8_t code = keymap_fn_keycode(FN_INDEX(key));
58 action.code = ACTION_LAYER_SET_TAP_KEY(layer, code);
59 }
60 break;
61 case KC_NO ... KC_UNDEFINED:
62 default:
63 action.code = ACTION_NO;
64 break;
65 }
66 return action;
67 }
68 #endif
69
70 __attribute__ ((weak))
71 void keymap_call_function(keyrecord_t *event, uint8_t id, uint8_t opt)
72 {
73 }
Imprint / Impressum