1
1
/*
2
- Copyright 2013 Jun Wako <[email protected] >
2
+ Copyright 2013,2016 Jun Wako <[email protected] >
3
3
4
4
This program is free software: you can redistribute it and/or modify
5
5
it under the terms of the GNU General Public License as published by
@@ -23,6 +23,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
23
23
#include "wait.h"
24
24
#include "debug.h"
25
25
#include "bootloader.h"
26
+ #if defined(__AVR__ )
27
+ #include <avr/pgmspace.h>
28
+ #endif
26
29
27
30
#ifdef BOOTMAGIC_ENABLE
28
31
extern keymap_config_t keymap_config ;
@@ -32,6 +35,7 @@ static action_t keycode_to_action(uint8_t keycode);
32
35
33
36
34
37
/* converts key to action */
38
+ __attribute__ ((weak ))
35
39
action_t action_for_key (uint8_t layer , keypos_t key )
36
40
{
37
41
uint8_t keycode = keymap_key_to_keycode (layer , key );
@@ -169,6 +173,28 @@ static action_t keycode_to_action(uint8_t keycode)
169
173
* Legacy keymap support
170
174
* Consider using new keymap API instead.
171
175
*/
176
+ extern const uint8_t keymaps [][MATRIX_ROWS ][MATRIX_COLS ];
177
+ extern const uint8_t fn_layer [];
178
+ extern const uint8_t fn_keycode [];
179
+
180
+ __attribute__ ((weak ))
181
+ uint8_t keymap_get_keycode (uint8_t layer , uint8_t row , uint8_t col )
182
+ {
183
+ return pgm_read_byte (& keymaps [(layer )][(row )][(col )]);
184
+ }
185
+
186
+ __attribute__ ((weak ))
187
+ uint8_t keymap_fn_layer (uint8_t index )
188
+ {
189
+ return pgm_read_byte (& fn_layer [index ]);
190
+ }
191
+
192
+ __attribute__ ((weak ))
193
+ uint8_t keymap_fn_keycode (uint8_t index )
194
+ {
195
+ return pgm_read_byte (& fn_keycode [index ]);
196
+ }
197
+
172
198
__attribute__ ((weak ))
173
199
uint8_t keymap_key_to_keycode (uint8_t layer , keypos_t key )
174
200
{
@@ -196,4 +222,31 @@ action_t keymap_fn_to_action(uint8_t keycode)
196
222
return (action_t )ACTION_NO ;
197
223
}
198
224
}
225
+
226
+ #else
227
+
228
+ /* user keymaps should be defined somewhere */
229
+ extern const uint8_t keymaps [][MATRIX_ROWS ][MATRIX_COLS ];
230
+ extern const action_t fn_actions [];
231
+
232
+ __attribute__ ((weak ))
233
+ uint8_t keymap_key_to_keycode (uint8_t layer , keypos_t key )
234
+ {
235
+ #if defined(__AVR__ )
236
+ return pgm_read_byte (& keymaps [(layer )][(key .row )][(key .col )]);
237
+ #else
238
+ return keymaps [(layer )][(key .row )][(key .col )];
239
+ #endif
240
+ }
241
+
242
+ __attribute__ ((weak ))
243
+ action_t keymap_fn_to_action (uint8_t keycode )
244
+ {
245
+ #if defined(__AVR__ )
246
+ return (action_t )pgm_read_word (& fn_actions [FN_INDEX (keycode )]);
247
+ #else
248
+ return fn_actions [FN_INDEX (keycode )];
249
+ #endif
250
+ }
251
+
199
252
#endif
0 commit comments