move keymaps to progmem. This is a fairly large memory win

pull/21/head
Jesse Vincent 8 years ago
parent 68fed1fd17
commit 771c0de247

@ -2,9 +2,13 @@
#include "HIDTables.h"
typedef struct {
uint8_t flags;
uint8_t rawKey;
typedef union {
struct {
uint8_t flags;
uint8_t rawKey;
};
uint16_t raw;
} Key;

@ -1,6 +1,6 @@
#include "key_events.h"
const Key keymaps[KEYMAPS][ROWS][COLS] = { KEYMAP_LIST };
static const Key keymaps[KEYMAPS][ROWS][COLS] PROGMEM = { KEYMAP_LIST };
void handle_synthetic_key_event(Key mappedKey, uint8_t currentState, uint8_t previousState) {
if (mappedKey.flags & IS_MOUSE_KEY && !( mappedKey.rawKey & KEY_MOUSE_WARP) ) {
@ -50,10 +50,12 @@ void handle_key_event(byte row, byte col, uint8_t currentState, uint8_t previous
//for every newly pressed button, figure out what logical key it is and send a key down event
// for every newly released button, figure out what logical key it is and send a key up event
Key mappedKey = keymaps[temporary_keymap][row][col];
if (keymaps[primary_keymap][row][col].flags & SWITCH_TO_KEYMAP) {
handle_keymap_key_event(keymaps[primary_keymap][row][col], currentState, previousState);
Key mappedKey;
mappedKey.raw= pgm_read_word(&(keymaps[temporary_keymap][row][col]));
Key baseKey;
baseKey.raw= pgm_read_word(&(keymaps[primary_keymap][row][col]));
if (baseKey.flags & SWITCH_TO_KEYMAP) {
handle_keymap_key_event(baseKey, currentState, previousState);
} else if (mappedKey.flags & SYNTHETIC_KEY) {
handle_synthetic_key_event( mappedKey, currentState, previousState);
} else if (key_is_pressed(currentState, previousState)) {

@ -9,7 +9,7 @@
#include "keymap_metadata.h"
#include "generated/keymaps.h"
extern const Key keymaps[KEYMAPS][ROWS][COLS];
//static const Key keymaps[KEYMAPS][ROWS][COLS];
extern uint8_t primary_keymap;
extern uint8_t temporary_keymap;

Loading…
Cancel
Save