]>
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/>.
23 action_t
keymap_keycode_to_action(uint8_t keycode
)
27 case KC_A
... KC_EXSEL
:
28 action
.code
= ACTION_KEY(keycode
);
30 case KC_LCTRL
... KC_LGUI
:
31 action
.code
= ACTION_LMOD(keycode
);
33 case KC_RCTRL
... KC_RGUI
:
34 action
.code
= ACTION_RMOD(keycode
);
36 case KC_SYSTEM_POWER
... KC_SYSTEM_WAKE
:
37 action
.code
= ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode
));
39 case KC_AUDIO_MUTE
... KC_WWW_FAVORITES
:
40 action
.code
= ACTION_USAGE_CONSUMER(KEYCODE2CONSUMER(keycode
));
42 case KC_MS_UP
... KC_MS_ACCEL2
:
43 action
.code
= ACTION_MOUSEKEY(keycode
);
46 action
.code
= ACTION_TRANSPARENT
;
49 action
.code
= ACTION_NO
;
55 #ifndef NO_LEGACY_KEYMAP_SUPPORT
56 /* legacy support with weak reference */
57 __attribute__ ((weak
))
58 action_t
action_for_key(uint8_t layer
, key_t key
)
60 /* convert from legacy keycode to action */
61 uint8_t keycode
= keymap_get_keycode(layer
, key
.row
, key
.col
);
64 case KC_FN0
... KC_FN31
:
66 uint8_t layer
= keymap_fn_layer(FN_INDEX(keycode
));
67 uint8_t key
= keymap_fn_keycode(FN_INDEX(keycode
));
69 action
.code
= ACTION_LAYER_SET_TAP_KEY(layer
, key
);
71 action
.code
= ACTION_LAYER_SET_MOMENTARY(layer
);
76 return keymap_keycode_to_action(keycode
);
81 __attribute__ ((weak
))
82 void action_function(keyrecord_t
*event
, uint8_t id
, uint8_t opt
)