]>
git.gir.st - tmk_keyboard.git/blob - common/keymap.c
2 Copyright 2013 Jun Wako <wakojun@gmail.com>
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.
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.
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/>.
24 uint8_t default_layer
= 0;
25 uint8_t current_layer
= 0;
28 action_t
keymap_keycode_to_action(uint8_t keycode
)
32 case KC_A
... KC_EXSEL
:
33 action
.code
= ACTION_KEY(keycode
);
35 case KC_LCTRL
... KC_LGUI
:
36 action
.code
= ACTION_LMOD(keycode
);
38 case KC_RCTRL
... KC_RGUI
:
39 action
.code
= ACTION_RMOD(keycode
);
41 case KC_SYSTEM_POWER
... KC_SYSTEM_WAKE
:
42 action
.code
= ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode
));
44 case KC_AUDIO_MUTE
... KC_WWW_FAVORITES
:
45 action
.code
= ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode
));
47 case KC_MS_UP
... KC_MS_ACCEL2
:
48 action
.code
= ACTION_MOUSEKEY(keycode
);
51 action
.code
= ACTION_TRANSPARENT
;
54 action
.code
= ACTION_NO
;
60 #ifndef NO_LEGACY_KEYMAP_SUPPORT
61 /* legacy support with weak reference */
62 __attribute__ ((weak
))
63 action_t
keymap_get_action(uint8_t layer
, uint8_t row
, uint8_t col
)
65 /* convert from legacy keycode to action */
66 uint8_t keycode
= keymap_get_keycode(layer
, row
, col
);
69 case KC_FN0
... KC_FN31
:
71 uint8_t layer
= keymap_fn_layer(FN_INDEX(keycode
));
72 uint8_t key
= keymap_fn_keycode(FN_INDEX(keycode
));
74 action
.code
= ACTION_LAYER_SET_TAP_KEY(layer
, key
);
76 action
.code
= ACTION_LAYER_SET_MOMENTARY(layer
);
81 return keymap_keycode_to_action(keycode
);
86 __attribute__ ((weak
))
87 void keymap_call_function(keyrecord_t
*event
, uint8_t id
, uint8_t opt
)