You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License | ||||
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
//#include <stdbool.h> | |||||
#include <avr/pgmspace.h> | |||||
#include "keymap.h" | |||||
#include "keymap_in_eeprom.h" | |||||
#include "keymap_common.h" | #include "keymap_common.h" | ||||
static uint8_t keymaps_cache[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; | |||||
/* translates key to keycode */ | |||||
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | |||||
void keymaps_cache_init(void) | |||||
{ | { | ||||
for (uint8_t layer = 0; layer < KEYMAPS_COUNT; layer++) { | |||||
for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | |||||
for (uint8_t col = 0; col < MATRIX_COLS; col++) { | |||||
#ifndef KEYMAP_IN_EEPROM_ENABLE | #ifndef KEYMAP_IN_EEPROM_ENABLE | ||||
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); | |||||
keymaps_cache[layer][row][col] = pgm_read_byte(&keymaps[layer][row][col]); | |||||
#else | #else | ||||
return eeconfig_read_keymap_key(layer, key.row, key.col); | |||||
keymaps_cache[layer][row][col] = eeconfig_read_keymap_key(layer, row, col); | |||||
#endif | #endif | ||||
} | |||||
} | |||||
} | |||||
} | |||||
/* translates key to keycode */ | |||||
uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | |||||
{ | |||||
return keymaps_cache[layer][key.row][key.col]; | |||||
} | } | ||||
/* translates Fn keycode to action */ | /* translates Fn keycode to action */ |
#define KEYMAP_COMMON_H | #define KEYMAP_COMMON_H | ||||
#include <stdint.h> | #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 "print.h" | |||||
#include "debug.h" | |||||
#include "keymap.h" | |||||
#include "keymap_in_eeprom.h" | |||||
extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | ||||
extern const uint16_t fn_actions[]; | extern const uint16_t fn_actions[]; | ||||
void keymaps_cache_init(void); | |||||
/* TentaPad keymap definition macro | /* TentaPad keymap definition macro | ||||
*/ | */ | ||||
#define KEYMAP( \ | #define KEYMAP( \ |
along with this program. If not, see <http://www.gnu.org/licenses/>. | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include <avr/pgmspace.h> | |||||
#include "keycode.h" | |||||
#include "action_layer.h" | |||||
#include "eeconfig.h" | |||||
#include "backlight.h" | |||||
#include "keymap_common.h" | #include "keymap_common.h" | ||||
enum function_id { | enum function_id { | ||||
}; | }; | ||||
enum { | enum { | ||||
CONFIG_LAYER = 31, | |||||
CONFIG_LAYER = 8, | |||||
}; | }; | ||||
// Default | // Default | ||||
if (record->event.pressed) { | if (record->event.pressed) { | ||||
if (config_mode) { | if (config_mode) { | ||||
default_layer_set(1UL<<layer); | default_layer_set(1UL<<layer); | ||||
eeconfig_write_default_layer(1UL<<layer); | |||||
layer = (layer + 1) % 6; | layer = (layer + 1) % 6; | ||||
} | } | ||||
} | } | ||||
if (record->event.pressed) { | if (record->event.pressed) { | ||||
if (config_mode) { | if (config_mode) { | ||||
backlight_level(backlight); | backlight_level(backlight); | ||||
backlight = (backlight + 1) % BACKLIGHT_LEVEL; | |||||
backlight = (backlight + 1) % (BACKLIGHT_LEVELS + 1); | |||||
} | } | ||||
} | } | ||||
break; | break; |