Sfoglia il codice sorgente

Remove keymap_ex changes

core
Kai Ryu 10 anni fa
parent
commit
9b73c1e4fc
4 ha cambiato i file con 1 aggiunte e 193 eliminazioni
  1. 1
    6
      common.mk
  2. 0
    5
      common/keyboard.c
  3. 0
    114
      common/keymap_ex.c
  4. 0
    68
      common/keymap_ex.h

+ 1
- 6
common.mk Vedi File

@@ -22,7 +22,7 @@ ifdef BOOTMAGIC_ENABLE
OPT_DEFS += -DBOOTMAGIC_ENABLE
endif

ifdef MOUSEKEY_ENABLE
ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE)
SRC += $(COMMON_DIR)/mousekey.c
OPT_DEFS += -DMOUSEKEY_ENABLE
OPT_DEFS += -DMOUSE_ENABLE
@@ -69,11 +69,6 @@ ifdef KEYMAP_SECTION_ENABLE
EXTRALDFLAGS = -Wl,-L$(TOP_DIR),-Tldscript_keymap_avr5.x
endif

ifdef KEYMAP_EX_ENABLE
SRC += $(COMMON_DIR)/keymap_ex.c
OPT_DEFS += -DKEYMAP_EX_ENABLE
endif

ifdef LED_MATRIX_ENABLE
SRC += $(COMMON_DIR)/led_matrix.c
OPT_DEFS += -DLED_MATRIX_ENABLE

+ 0
- 5
common/keyboard.c Vedi File

@@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "eeconfig.h"
#include "backlight.h"
#include "breathing_led.h"
#include "keymap_ex.h"
#ifdef MOUSEKEY_ENABLE
# include "mousekey.h"
#endif
@@ -85,10 +84,6 @@ void keyboard_init(void)
#ifdef BREATHING_LED_ENABLE
breathing_led_init();
#endif

#ifdef KEYMAP_EX_ENABLE
keymap_ex_init();
#endif
}

/*

+ 0
- 114
common/keymap_ex.c Vedi File

@@ -1,114 +0,0 @@
/*
Copyright 2013 Kai Ryu <[email protected]>

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 <avr/pgmspace.h>
#include <avr/eeprom.h>
#include "eeconfig.h"
#include "keymap_ex.h"
#include "debug.h"

#ifdef KEYMAP_EX_ENABLE

void keymap_ex_init(void) {
if (!check_keymap_in_eeprom()) {
write_keymap_to_eeprom();
}
}

void keymap_ex_disable(void) {
eeprom_write_word((void*)EECONFIG_KEYMAP_CHECKSUM, eeprom_read_word((void*)EECONFIG_KEYMAP_CHECKSUM) + 1);
}

bool check_keymap_in_eeprom(void) {
uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum);
uint16_t checksum = EECONFIG_MAGIC_NUMBER;
for (uint16_t i = 0; i < KEYMAP_SIZE; i += 2) {
checksum += eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + i));
}
#ifdef DEBUG
eeprom_write_word((void*)(EECONFIG_KEYMAP_DEBUG), checksum);
#endif
return (checksum_in_eeprom == checksum);
}

void write_keymap_to_eeprom(void) {
uint16_t checksum = EECONFIG_MAGIC_NUMBER;
const uint16_t *fn_actions = fn_actions_pointer();
const uint8_t *keymaps = keymaps_pointer();
// write fn_actions
if (fn_actions != NULL) {
uint16_t fn_actions_count_in_flash = fn_actions_count();
for (uint16_t i = 0; i < FN_ACTIONS_COUNT; i++) {
uint16_t fn_action = 0;
if (i < fn_actions_count_in_flash) {
fn_action = pgm_read_word(fn_actions + i);
}
eeconfig_write_keymap_fn_action(i, fn_action);
checksum += fn_action;
}
}
// write keymaps
if (keymaps != NULL) {
uint16_t keys_count_in_flash = keys_count();
for (uint16_t i = 0; i < KEYS_COUNT; i++) {
uint8_t keymap = 0;
if (i < keys_count_in_flash) {
keymap = pgm_read_byte(keymaps + i);
}
eeconfig_write_keymap_key_by_index(i, keymap);
uint16_t keymap_word = keymap;
if (i & 1) {
keymap_word = keymap << 8;
}
checksum += keymap_word;
}
}
// write checksum
eeprom_write_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum, checksum);
}

uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col) {
//return eeprom_read_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col]);
return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col)));
}

void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key) {
//return eeprom_write_byte(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->keymaps[layer][row][col], key);
return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + KEY_OFFSET(layer, row, col)), key);
}

uint8_t eeconfig_read_keymap_key_by_index(uint16_t index) {
//return eeprom_read_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index);
return eeprom_read_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index));
}

void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key) {
//return eeprom_write_byte(((keymap_ex_t*)(EECONFIG_KEYMAP_EX)) + index, key);
return eeprom_write_byte((void*)(EECONFIG_KEYMAP_KEYMAPS + index), key);
}

uint16_t eeconfig_read_keymap_fn_action(uint8_t index) {
//return eeprom_read_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index]);
return eeprom_read_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index)));
}

void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action) {
//return eeprom_write_word(&((keymap_ex_t*)(EECONFIG_KEYMAP_EX))->fn_actions[index], fn_action);
return eeprom_write_word((void*)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTION_OFFSET(index)), fn_action);
}

#endif

+ 0
- 68
common/keymap_ex.h Vedi File

@@ -1,68 +0,0 @@
/*
Copyright 2013 Kai Ryu <[email protected]>

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/>.
*/

#ifndef KEYMAP_EX_H
#define KEYMAP_EX_H

#ifdef KEYMAP_EX_ENABLE

#include <stdint.h>
#include <stdbool.h>

#define EECONFIG_KEYMAP_EX 0x10
#ifndef FN_ACTIONS_COUNT
#define FN_ACTIONS_COUNT 32
#endif
#ifndef KEYMAPS_COUNT
#define KEYMAPS_COUNT 8
#endif

typedef struct {
uint16_t checksum;
uint16_t fn_actions[FN_ACTIONS_COUNT];
uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS];
} keymap_ex_t;

#define EECONFIG_KEYMAP_DEBUG (EECONFIG_KEYMAP_EX - sizeof(uint16_t))
#define EECONFIG_KEYMAP_CHECKSUM (EECONFIG_KEYMAP_EX)
#define EECONFIG_KEYMAP_FN_ACTIONS (EECONFIG_KEYMAP_EX + sizeof(uint16_t))
#define EECONFIG_KEYMAP_KEYMAPS (EECONFIG_KEYMAP_FN_ACTIONS + sizeof(uint16_t) * FN_ACTIONS_COUNT)

#define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS)
#define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT)
#define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index)
#define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col))

void keymap_ex_init(void);
void keymap_ex_disable(void);
bool check_keymap_in_eeprom(void);
void write_keymap_to_eeprom(void);
uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col);
void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key);
uint8_t eeconfig_read_keymap_key_by_index(uint16_t index);
void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key);
uint16_t eeconfig_read_keymap_fn_action(uint8_t index);
void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action);

const uint8_t* keymaps_pointer(void);
const uint16_t* fn_actions_pointer(void);
uint16_t keys_count(void);
uint16_t fn_actions_count(void);

#endif

#endif