-
Notifications
You must be signed in to change notification settings - Fork 6
/
keymap.c
114 lines (97 loc) · 7.45 KB
/
keymap.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "action_macro.h"
#include "report.h"
#include "host.h"
#include "debug.h"
#include "keymap.h"
/*
Matrix col/row mapping
,----. ,-------------------. ,-------------------. ,-------------------. ,--------------.
| J6 | | I4 | H4 | H2 | H6 | | A7 | E6 | D2 | D4 | | B4 | B7 | B6 | B0 | | C7 | C5 | A5 |
`----' `-------------------' `-------------------' `-------------------' `--------------'
,-------------------------------------------------------------------------. ,--------------. ,-------------------.
| J4 | J7 | I7 | H7 | G7 | G4 | F4 | F7 | E7 | D7 | R7 | R4 | E4 | B2 | | L4 | O4 | Q4 | | K1 | L1 | Q1 | Q0 |
|-------------------------------------------------------------------------| |--------------| |-------------------|
| J2 | J5 | I5 | H5 | G5 | G2 | F2 | F5 | E5 | D5 | R5 | R2 | E2 | B3 | | K4 | O7 | Q7 | | K5 | L5 | Q5 | O5 |
|-------------------------------------------------------------------------| '--------------' |-------------- |
| O5 | J3 | I3 | H3 | G3 | G6 | F6 | F3 | E3 | D3 | R3 | R6 | B1 | | K2 | L2 | Q2 | |
|-------------------------------------------------------------------------| ,----. |-------------------|
| N2 | J1 | I1 | H1 | G1 | G0 | F0 | F1 | E1 | D1 | R0 | N3 | | O6 | | K3 | L3 | Q3 | O3 |
|-------------------------------------------------------------------------| ,--------------. |-------------- |
| A4 | P2 | C6 | K6 | C0 | M3 | D0 | A1 | | O0 | K0 | L0 | | L6 | Q6 | |
`-------------------------------------------------------------------------' `--------------' `-------------------'
*/
#define KEYMAP( \
KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0, KC7, KC5, KA5, \
KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KL4, KO4, KQ4, KK1, KL1, KQ1, KQ0, \
KJ2, KJ5, KI5, KH5, KG5, KG2, KF2, KF5, KE5, KD5, KR5, KR2, KE2, KB3, KK4, KO7, KQ7, KK5, KL5, KQ5, KO5, \
KI2, KJ3, KI3, KH3, KG3, KG6, KF6, KF3, KE3, KD3, KR3, KR6, KB1, KK2, KL2, KQ2, \
KN2, KI6, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, KO6, KK3, KL3, KQ3, KO3, \
KA4, KP2, KC6, KK6, KC0, KM3, KD0, KA1, KO0, KK0, KL0, KL6, KQ6 \
) \
{ \
/* Columns and rows need to be swapped in the below definition */ \
/* A B C D E F G H I J K L M N O P Q R */ \
{KC_NO, KC_##KB0, KC_##KC0, KC_##KD0, KC_NO, KC_##KF0, KC_##KG0, KC_NO, KC_NO, KC_NO, KC_##KK0, KC_##KL0, KC_NO, KC_NO, KC_##KO0, KC_NO, KC_##KQ0, KC_##KR0}, /* 0 */ \
{KC_##KA1, KC_##KB1, KC_NO, KC_##KD1, KC_##KE1, KC_##KF1, KC_##KG1, KC_##KH1, KC_##KI1, KC_##KJ1, KC_##KK1, KC_##KL1, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KQ1, KC_NO }, /* 1 */ \
{KC_NO, KC_##KB2, KC_NO, KC_##KD2, KC_##KE2, KC_##KF2, KC_##KG2, KC_##KH2, KC_##KI2, KC_##KJ2, KC_##KK2, KC_##KL2, KC_NO, KC_##KN2, KC_NO, KC_##KP2, KC_##KQ2, KC_##KR2}, /* 2 */ \
{KC_NO, KC_##KB3, KC_NO, KC_##KD3, KC_##KE3, KC_##KF3, KC_##KG3, KC_##KH3, KC_##KI3, KC_##KJ3, KC_##KK3, KC_##KL3, KC_##KM3, KC_##KN3, KC_##KO3, KC_NO, KC_##KQ3, KC_##KR3}, /* 3 */ \
{KC_##KA4, KC_##KB4, KC_NO, KC_##KD4, KC_##KE4, KC_##KF4, KC_##KG4, KC_##KH4, KC_##KI4, KC_##KJ4, KC_##KK4, KC_##KL4, KC_NO, KC_NO, KC_##KO4, KC_NO, KC_##KQ4, KC_##KR4}, /* 4 */ \
{KC_##KA5, KC_NO, KC_##KC5, KC_##KD5, KC_##KE5, KC_##KF5, KC_##KG5, KC_##KH5, KC_##KI5, KC_##KJ5, KC_##KK5, KC_##KL5, KC_NO, KC_NO, KC_##KO5, KC_NO, KC_##KQ5, KC_##KR5}, /* 5 */ \
{KC_NO, KC_##KB6, KC_##KC6, KC_NO, KC_##KE6, KC_##KF6, KC_##KG6, KC_##KH6, KC_##KI6, KC_##KJ6, KC_##KK6, KC_##KL6, KC_NO, KC_NO, KC_##KO6, KC_NO, KC_##KQ6, KC_##KR6}, /* 6 */ \
{KC_##KA7, KC_##KB7, KC_##KC7, KC_##KD7, KC_##KE7, KC_##KF7, KC_##KG7, KC_##KH7, KC_##KI7, KC_##KJ7, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KO7, KC_NO, KC_##KQ7, KC_##KR7} /* 7 */ \
}
#include "keymap_ansi_iso_jis.h"
#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key) {
if (layer < KEYMAPS_SIZE)
return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]);
else
return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]);
}
/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode) {
if (FN_INDEX(keycode) < FN_ACTIONS_SIZE)
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)])};
return (action_t)ACTION_NO;
}
//{
// /* 0 1 2 3 4 5 6 7 */
// {KC_NO, KC_##KA1, KC_NO, KC_NO, KC_##KA4, KC_##KA5, KC_NO, KC_##KA7}, /* A */
// {KC_##KB0, KC_##KB1, KC_##KB2, KC_##KB3, KC_##KB4, KC_NO, KC_##KB6, KC_##KB7}, /* B */
// {KC_##KC0, KC_NO, KC_NO, KC_NO, KC_NO, KC_##KC5, KC_##KC6, KC_##KC7}, /* C */
// {KC_##KD0, KC_##KD1, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_NO, KC_##KD7}, /* D */
// {KC_NO, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7}, /* E */
// {KC_##KF0, KC_##KF1, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7}, /* F */
// {KC_##KG0, KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7}, /* G */
// {KC_NO, KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7}, /* H */
// {KC_NO, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7}, /* I */
// {KC_NO, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7}, /* J */
// {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_NO }, /* K */
// {KC_##KL0, KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_NO }, /* L */
// {KC_NO, KC_NO, KC_NO, KC_##KM3, KC_NO, KC_NO, KC_NO, KC_NO }, /* M */
// {KC_NO, KC_NO, KC_##KN2, KC_##KN3, KC_NO, KC_NO, KC_NO, KC_NO }, /* N */
// {KC_##KO0, KC_NO, KC_NO, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_##KO7}, /* O */
// {KC_NO, KC_NO, KC_##KP2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, /* P */
// {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_##KQ5, KC_##KQ6, KC_##KQ7}, /* Q */
// {KC_##KR0, KC_NO, KC_##KR2, KC_##KR3, KC_##KR4, KC_##KR5, KC_##KR6, KC_##KR7} /* R */
//}