1
0

x68k_usb: Convert legacy keymap into current one

This commit is contained in:
tmk 2016-04-29 15:30:32 +09:00
parent 7847d5dd9f
commit e7808f7ea4
3 changed files with 12 additions and 35 deletions

View File

@ -18,7 +18,7 @@ SRC = keymap.c \
led.c \
protocol/serial_uart.c
CONFIG_H = config_pjrc.h
CONFIG_H = config.h
# MCU name, you MUST set this to match the board you are using

View File

@ -39,9 +39,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) \
)
/* legacy keymap support */
#define USE_LEGACY_KEYMAP
/* USART configuration
* asynchronous, 2400baud, 8-data bit, non parity, 1-stop bit, no flow control

View File

@ -19,6 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
#include "action.h"
#include "util.h"
#include "keymap.h"
@ -70,30 +71,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
}
// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
static const uint8_t PROGMEM fn_layer[] = {
0, // Fn0
0, // Fn1
0, // Fn2
0, // Fn3
0, // Fn4
0, // Fn5
0, // Fn6
0 // Fn7
static const uint16_t fn_actions[] PROGMEM = {
};
// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
// See layer.c for details.
static const uint8_t PROGMEM fn_keycode[] = {
KC_NO, // Fn0
KC_NO, // Fn1
KC_NO, // Fn2
KC_NO, // Fn3
KC_NO, // Fn4
KC_NO, // Fn5
KC_NO, // Fn6
KC_NO // Fn7
};
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
}
static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@ -134,17 +117,14 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
/* translates key to keycode */
uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
{
return pgm_read_byte(&keymaps[(layer)][(row)][(col)]);
return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
}
uint8_t keymap_fn_layer(uint8_t index)
/* translates Fn keycode to action */
action_t keymap_fn_to_action(uint8_t keycode)
{
return pgm_read_byte(&fn_layer[index]);
}
uint8_t keymap_fn_keycode(uint8_t index)
{
return pgm_read_byte(&fn_keycode[index]);
return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
}