]> git.gir.st - tmk_keyboard.git/blob - tmk_core/common/unimap.c
Merge branch 'unimap'
[tmk_keyboard.git] / tmk_core / common / unimap.c
1 #include "keyboard.h"
2 #include "action.h"
3 #include "unimap.h"
4 #include "print.h"
5 #if defined(__AVR__)
6 # include <avr/pgmspace.h>
7 #endif
8
9
10 /* Keymapping with 16bit action codes */
11 extern const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS];
12
13 // table translates matrix to universal keymap
14 extern const uint8_t unimap_trans[MATRIX_ROWS][MATRIX_COLS];
15
16
17
18 // translates raw matrix to universal map
19 keypos_t unimap_translate(keypos_t key)
20 {
21 uint8_t unimap_pos =
22 #if defined(__AVR__)
23 pgm_read_byte(&unimap_trans[key.row][key.col]);
24 #else
25 unimap_trans[key.row][key.col];
26 #endif
27 return (keypos_t) {
28 .row = ((unimap_pos & 0x70) >> 4),
29 .col = (unimap_pos & 0x0F)
30 };
31 }
32
33 /* Converts key to action */
34 __attribute__ ((weak))
35 action_t action_for_key(uint8_t layer, keypos_t key)
36 {
37 keypos_t uni = unimap_translate(key);
38 if ((uni.row << 4 | uni.col) == UNIMAP_NO) return (action_t)ACTION_NO;
39 #if defined(__AVR__)
40 return (action_t)pgm_read_word(&actionmaps[(layer)][(uni.row)][(uni.col)]);
41 #else
42 return actionmaps[(layer)][(uni.row)][(uni.col)];
43 #endif
44 }
45
46 /* Macro */
47 __attribute__ ((weak))
48 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
49 {
50 return MACRO_NONE;
51 }
52
53 /* Function */
54 __attribute__ ((weak))
55 void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
56 {
57 }
Imprint / Impressum