1
0

Merge branch 'universal_map' into develop

This commit is contained in:
tmk 2016-07-01 02:35:37 +09:00
commit f8bab8cd27
14 changed files with 903 additions and 57 deletions

View File

@ -1,43 +1,3 @@
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make coff = Convert ELF to AVR COFF.
#
# make extcoff = Convert ELF to AVR Extended COFF.
#
# make program = Download the hex file to the device.
# Please customize your programmer settings(PROGRAM_CMD)
#
# make teensy = Download the hex file to the device, using teensy_loader_cli.
# (must have teensy_loader_cli installed).
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
# make filename.s = Just compile filename.c into the assembler code only.
#
# make filename.i = Create a preprocessed source file for use in submitting
# bug reports to the GCC project.
#
# To rebuild project do "make clean" then "make all".
#----------------------------------------------------------------------------
# Target file name (without extension).
TARGET = adb_usb_lufa
@ -52,12 +12,6 @@ SRC = matrix.c \
led.c \
adb.c
ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
else
SRC := keymap_plain.c $(SRC)
endif
CONFIG_H = config.h
@ -124,6 +78,9 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
#NKRO_ENABLE = yes # USB Nkey Rollover
ADB_MOUSE_ENABLE = yes
#UNIMAP_ENABLE = yes
#ACTIONMAP_ENABLE = yes # Use 16bit actionmap instead of 8bit keymap
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
# ADB Mice need acceleration for todays much bigger screens.
OPT_DEFS += -DADB_MOUSE_MAXACC=8
@ -132,6 +89,26 @@ OPT_DEFS += -DADB_MOUSE_MAXACC=8
# Optimize size but this may cause error "relocation truncated to fit"
#EXTRALDFLAGS = -Wl,--relax
#
# Keymap file
#
ifdef UNIMAP_ENABLE
KEYMAP_FILE = unimap
else
ifdef ACTIONMAP_ENABLE
KEYMAP_FILE = actionmap
else
KEYMAP_FILE = keymap
endif
endif
ifdef KEYMAP
SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
else
SRC := $(KEYMAP_FILE)_plain.c $(SRC)
endif
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TMK_DIR)

View File

@ -0,0 +1,3 @@
UNIMAP_ENABLE = yes
KEYMAP_SECTION_ENABLE = yes
include Makefile

View File

@ -0,0 +1,212 @@
/*
Copyright 2016 Jun Wako <wakojun@gmail.com>
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 UNIMAP_COMMON_H
#define UNIMAP_COMMON_H
#include <stdint.h>
#include <avr/pgmspace.h>
#include "unimap.h"
/* Apple Extended Keyboard Common layout: ANSI+ISO
* ,---. .---------------. ,---------------. ,---------------. ,-----------. ,---------------.
* |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|F24|
* `---' `---------------' `---------------' `---------------' `-----------' `---------------'
* ,-----------------------------------------------------------. ,-----------. ,---------------.
* | `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backspa| |Ins|Hom|PgU| |NmL| =| /| *|
* |-----------------------------------------------------------| |-----------| |---------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD| | 7| 8| 9| -|
* |-----------------------------------------------------------| `-----------' |---------------|
* |CapsLo| A| S| D| F| G| H| J| K| L| ;| '|Return | | 4| 5| 6| +|
* |-----------------------------------------------------------| ,---. |---------------|
* |Shif|\ | Z| X| C| V| B| N| M| ,| ,| /|Shift | |Up | | 1| 2| 3| |
* |-----------------------------------------------------------| ,-----------. |-----------|Ent|
* |Ctrl |Alt |Gui | Space |Gui |Alt |Ctrl | |Lef|Dow|Rig| | 0| .| |
* `-----------------------------------------------------------' `-----------' `---------------'
* Command = Gui
* Option = Alt
* Power key = F24
*/
// http://lxr.free-electrons.com/source/drivers/macintosh/adbhid.c
// http://opensource.apple.com//source/IOHIDFamily/IOHIDFamily-701.20.10/IOHIDFamily/Cosmo_USB2ADB.c
// http://m0115.web.fc2.com/m0115.jpg
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
// Position(unimap) ADB scan code(matrix)
// ---------------------------------------------
{
UNIMAP_A, // 0x00
UNIMAP_S, // 0x01
UNIMAP_D, // 0x02
UNIMAP_F, // 0x03
UNIMAP_H, // 0x04
UNIMAP_G, // 0x05
UNIMAP_Z, // 0x06
UNIMAP_X, // 0x07
},
{
UNIMAP_C, // 0x08
UNIMAP_V, // 0x09
UNIMAP_NONUS_BSLASH, // 0x0A
UNIMAP_B, // 0x0B
UNIMAP_Q, // 0x0C
UNIMAP_W, // 0x0D
UNIMAP_E, // 0x0E
UNIMAP_R, // 0x0F
},
{
UNIMAP_Y, // 0x10
UNIMAP_T, // 0x11
UNIMAP_1, // 0x12
UNIMAP_2, // 0x13
UNIMAP_3, // 0x14
UNIMAP_4, // 0x15
UNIMAP_6, // 0x16
UNIMAP_5, // 0x17
},
{
UNIMAP_EQUAL, // 0x18
UNIMAP_9, // 0x19
UNIMAP_7, // 0x1A
UNIMAP_MINUS, // 0x1B
UNIMAP_8, // 0x1C
UNIMAP_0, // 0x1D
UNIMAP_RBRACKET, // 0x1E
UNIMAP_O, // 0x1F
},
{
UNIMAP_U, // 0x20
UNIMAP_LBRACKET, // 0x21
UNIMAP_I, // 0x22
UNIMAP_P, // 0x23
UNIMAP_ENTER, // 0x24
UNIMAP_L, // 0x25
UNIMAP_J, // 0x26
UNIMAP_QUOTE, // 0x27
},
{
UNIMAP_K, // 0x28
UNIMAP_SCOLON, // 0x29
UNIMAP_BSLASH, // 0x2A
UNIMAP_COMMA, // 0x2B
UNIMAP_SLASH, // 0x2C
UNIMAP_N, // 0x2D
UNIMAP_M, // 0x2E
UNIMAP_DOT, // 0x2F
},
{
UNIMAP_TAB, // 0x30
UNIMAP_SPACE, // 0x31
UNIMAP_GRAVE, // 0x32
UNIMAP_BSPACE, // 0x33
UNIMAP_KP_ENTER, // 0x34
UNIMAP_ESCAPE, // 0x35
UNIMAP_LCTRL, // 0x36
UNIMAP_LGUI, // 0x37
},
{
UNIMAP_LSHIFT, // 0x38
UNIMAP_CAPSLOCK, // 0x39
UNIMAP_LALT, // 0x3A
UNIMAP_LEFT, // 0x3B
UNIMAP_RIGHT, // 0x3C
UNIMAP_DOWN, // 0x3D
UNIMAP_UP, // 0x3E
UNIMAP_F23, // 0x3F FN?
},
{
UNIMAP_F17, // 0x40
UNIMAP_KP_DOT, // 0x41
UNIMAP_NO, // 0x42
UNIMAP_KP_ASTERISK, // 0x43
UNIMAP_NO, // 0x44
UNIMAP_KP_PLUS, // 0x45
UNIMAP_NO, // 0x46
UNIMAP_NUMLOCK, // 0x47
},
{
UNIMAP_NO, // 0x48
UNIMAP_NO, // 0x49
UNIMAP_NO, // 0x4A
UNIMAP_KP_SLASH, // 0x4B
UNIMAP_KP_ENTER, // 0x4C
UNIMAP_NO, // 0x4D
UNIMAP_KP_MINUS, // 0x4E
UNIMAP_F18, // 0x4F
},
{
UNIMAP_F19, // 0x50
UNIMAP_KP_EQUAL, // 0x51
UNIMAP_KP_0, // 0x52
UNIMAP_KP_1, // 0x53
UNIMAP_KP_2, // 0x54
UNIMAP_KP_3, // 0x55
UNIMAP_KP_4, // 0x56
UNIMAP_KP_5, // 0x57
},
{
UNIMAP_KP_6, // 0x58
UNIMAP_KP_7, // 0x59
UNIMAP_F20, // 0x5A
UNIMAP_KP_8, // 0x5B
UNIMAP_KP_9, // 0x5C
UNIMAP_JYEN, // 0x5D
UNIMAP_RO, // 0x5E
UNIMAP_KP_COMMA, // 0x5F
},
{
UNIMAP_F5, // 0x60
UNIMAP_F6, // 0x61
UNIMAP_F7, // 0x62
UNIMAP_F3, // 0x63
UNIMAP_F8, // 0x64
UNIMAP_F9, // 0x65
UNIMAP_MHEN, // 0x66
UNIMAP_F11, // 0x67
},
{
UNIMAP_HENK, // 0x68
UNIMAP_PSCREEN, // 0x69
UNIMAP_F16, // 0x6A
UNIMAP_SCROLLLOCK, // 0x6B
UNIMAP_NO, // 0x6C
UNIMAP_F10, // 0x6D
UNIMAP_APPLICATION, // 0x6E compose
UNIMAP_F12, // 0x6F
},
{
UNIMAP_NO, // 0x70
UNIMAP_PAUSE, // 0x71
UNIMAP_INSERT, // 0x72
UNIMAP_HOME, // 0x73
UNIMAP_PGUP, // 0x74
UNIMAP_DELETE, // 0x75
UNIMAP_F4, // 0x76
UNIMAP_END, // 0x77
},
{
UNIMAP_F2, // 0x78
UNIMAP_PGDOWN, // 0x79
UNIMAP_F1, // 0x7A
UNIMAP_RSHIFT, // 0x7B
UNIMAP_RALT, // 0x7C
UNIMAP_RCTRL, // 0x7D
UNIMAP_RGUI, // 0x7E
UNIMAP_F24, // 0x7F power key
}
};
#endif

View File

@ -0,0 +1,46 @@
/*
Copyright 2016 Jun Wako <wakojun@gmail.com>
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 "unimap_common.h"
#define AC_FN0 ACTION_LAYER_TAP_KEY(1, KC_GRV)
#define AC_FN1 ACTION_LAYER_TAP_KEY(1, KC_BSLS)
#ifdef KEYMAP_SECTION_ENABLE
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
#endif
UNIMAP(
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,
FN0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, INS, HOME,PGUP, NLCK,PSLS,PAST,PMNS,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, FN1, DEL, END, PGDN, P7, P8, P9, PPLS,
CAPS,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, P4, P5, P6, PCMM,
LSFT,NUBS,Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, P1, P2, P3, PEQL,
LCTL,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,RGUI,APP, RCTL, LEFT,DOWN,RGHT, P0, PDOT,PENT
),
UNIMAP(
F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24,
ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR,SLCK,PAUS, VOLD,VOLU,MUTE,
TRNS,F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, JYEN,DEL, INS, HOME,PGUP, NLCK,BTN2,BTN3,WH_D,
TAB, Q, W, E, R, T, Y, U, PSCR,SLCK,PAUS,UP, INS, TRNS, DEL, END, PGDN, WH_D,MS_U,WH_U,WH_U,
CAPS,VOLD,VOLU,MUTE,F, G, H, J, HOME,PGUP,LEFT,RGHT, NUHS,ENT, MS_L,MS_D,MS_R,BTN4,
LSFT,NUBS,Z, X, C, V, B, N, M, END, PGDN,DOWN, RO, RSFT, PGUP, WH_L,MS_D,WH_R,BTN1,
LCTL,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,RGUI,APP, RCTL, HOME,PGDN,END, BTN1, BTN2,BTN3
),
};

View File

@ -118,6 +118,9 @@ COMMAND_ENABLE = yes # Commands for debug and configuration
NKRO_ENABLE = yes # USB Nkey Rollover
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
#HHKB_JP = yes # HHKB JP support
#UNIMAP_ENABLE = yes
#ACTIONMAP_ENABLE = yes # Use 16bit actionmap instead of 8bit keymap
#KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor
#OPT_DEFS += -DNO_ACTION_TAPPING
#OPT_DEFS += -DNO_ACTION_LAYER
@ -127,13 +130,22 @@ NKRO_ENABLE = yes # USB Nkey Rollover
#
# Keymap file
#
ifdef UNIMAP_ENABLE
KEYMAP_FILE = unimap
else
ifdef ACTIONMAP_ENABLE
KEYMAP_FILE = actionmap
else
KEYMAP_FILE = keymap
endif
endif
ifdef KEYMAP
SRC := keymap_$(KEYMAP).c $(SRC)
SRC := $(KEYMAP_FILE)_$(KEYMAP).c $(SRC)
else
ifdef HHKB_JP
SRC := keymap_jp.c $(SRC)
SRC := $(KEYMAP_FILE)_jp.c $(SRC)
else
SRC := keymap_hhkb.c $(SRC)
SRC := $(KEYMAP_FILE)_hhkb.c $(SRC)
endif
endif

View File

@ -0,0 +1,4 @@
HHKB_JP = yes
UNIMAP_ENABLE = yes
KEYMAP_SECTION_ENABLE = yes
include Makefile

View File

@ -0,0 +1,222 @@
/*
Copyright 2016 Jun Wako <wakojun@gmail.com>
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 UNIMAP_COMMON_H
#define UNIMAP_COMMON_H
#include <stdint.h>
#include <avr/pgmspace.h>
#include "unimap.h"
/* HHKB JP
* ,-----------------------------------------------------------.
* |` |1 |2 |3 |4 |5 |6 |7 |8 |9 |0 |- |= |JPY|BS |
* |-----------------------------------------------------------|
* |Tab |Q |W |E |R |T |Y |U |I |O |P |[ |] |Enter|
* |------------------------------------------------------` |
* |Caps |A |S |D |F |G |H |J |K |L |; |' |# | |
* |-----------------------------------------------------------|
* |Shift |Z |X |C |V |B |N |M |, |. |/ |Ro |Up |Shi|
* |-----------------------------------------------------------|
* |Ctl||Esc|Gui|Alt|Mhn| |Hen|Kan|Alt|Ctl||Lef|Dow|Rig|
* `-----------------------------------------------------------'
* Esc = Grave(`)
* Control = Caps Lock
* Left Fn = Left Control
* Right Fn = Right Control
*/
// row:16 x col:8
const uint8_t PROGMEM unimap_trans[MATRIX_ROWS][MATRIX_COLS] = {
// 0
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_GRAVE,
UNIMAP_TAB,
UNIMAP_LCTRL,
UNIMAP_LSHIFT,
UNIMAP_CAPSLOCK,
UNIMAP_NO,
},
// 1
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_4,
UNIMAP_E,
UNIMAP_MHEN,
UNIMAP_C,
UNIMAP_D,
UNIMAP_NO,
},
// 2
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_3,
UNIMAP_W,
UNIMAP_LALT,
UNIMAP_X,
UNIMAP_S,
UNIMAP_NO,
},
// 3
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_1,
UNIMAP_NO,
UNIMAP_ESCAPE,
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_NO,
},
// 4
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_NO,
},
// 5
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_5,
UNIMAP_R,
UNIMAP_NO,
UNIMAP_V,
UNIMAP_F,
UNIMAP_NO,
},
// 6
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_2,
UNIMAP_Q,
UNIMAP_LGUI,
UNIMAP_Z,
UNIMAP_A,
UNIMAP_NO,
},
// 7
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_6,
UNIMAP_T,
UNIMAP_SPACE,
UNIMAP_B,
UNIMAP_G,
UNIMAP_NO,
},
// 8
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_9,
UNIMAP_I,
UNIMAP_KANA,
UNIMAP_COMMA,
UNIMAP_K,
UNIMAP_NO,
},
// 9
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_8,
UNIMAP_U,
UNIMAP_HENK,
UNIMAP_M,
UNIMAP_J,
UNIMAP_NO,
},
// A
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_7,
UNIMAP_Y,
UNIMAP_NO,
UNIMAP_N,
UNIMAP_H,
UNIMAP_NO,
},
// B
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_0,
UNIMAP_O,
UNIMAP_RALT,
UNIMAP_DOT,
UNIMAP_L,
UNIMAP_NO,
},
// C
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_BSPACE,
UNIMAP_NO,
UNIMAP_RIGHT,
UNIMAP_RSHIFT,
UNIMAP_ENTER,
UNIMAP_NO,
},
// D
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_JYEN,
UNIMAP_RBRACKET,
UNIMAP_DOWN,
UNIMAP_UP,
UNIMAP_NONUS_HASH,
UNIMAP_NO,
},
// E
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_MINUS,
UNIMAP_P,
UNIMAP_RCTRL,
UNIMAP_SLASH,
UNIMAP_SCOLON,
UNIMAP_NO,
},
// F
{
UNIMAP_NO,
UNIMAP_NO,
UNIMAP_EQUAL,
UNIMAP_LBRACKET,
UNIMAP_LEFT,
UNIMAP_RO,
UNIMAP_QUOTE,
UNIMAP_NO,
},
};
#endif

45
keyboard/hhkb/unimap_jp.c Normal file
View File

@ -0,0 +1,45 @@
/*
Copyright 2016 Jun Wako <wakojun@gmail.com>
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 "unimap_common.h"
#define AC_FN0 ACTION_LAYER_MOMENTARY(1)
#ifdef KEYMAP_SECTION_ENABLE
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS] PROGMEM = {
#endif
UNIMAP(
NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,
ZKHK, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO,
ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, NO, NO, NO, NO, NO, NO, NO,
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, BSLS, NO, NO, NO, NO, NO, NO, NO,
LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT, NUHS,ENT, NO, NO, NO, NO,
LSFT,NO, Z, X, C, V, B, N, M, COMM,DOT, SLSH, RO, RSFT, UP, NO, NO, NO, NO,
FN0, LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,NO, NO, FN0, LEFT,DOWN,RGHT, NO, NO, NO
),
UNIMAP(
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,
PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,
CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP, TRNS, TRNS, TRNS,TRNS,TRNS, TRNS,TRNS,TRNS,TRNS,
TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT, TRNS,PENT, TRNS,TRNS,TRNS,TRNS,
TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN, TRNS,TRNS, PGUP, TRNS,TRNS,TRNS,TRNS,
TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, HOME,PGDN,END, TRNS, TRNS,TRNS
),
};

View File

@ -17,11 +17,16 @@ SRC += $(COMMON_DIR)/host.c \
# Option modules
ifdef ACTIONMAP_ENABLE
SRC += $(COMMON_DIR)/actionmap.c
OPT_DEFS += -DACTIONMAP_ENABLE
ifdef UNIMAP_ENABLE
SRC += $(COMMON_DIR)/unimap.c
OPT_DEFS += -DUNIMAP_ENABLE
else
SRC += $(COMMON_DIR)/keymap.c
ifdef ACTIONMAP_ENABLE
SRC += $(COMMON_DIR)/actionmap.c
OPT_DEFS += -DACTIONMAP_ENABLE
else
SRC += $(COMMON_DIR)/keymap.c
endif
endif
ifdef BOOTMAGIC_ENABLE

View File

@ -18,6 +18,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action_code.h"
#include "actionmap.h"
/* Keymapping with 16bit action codes */
extern const action_t actionmaps[][MATRIX_ROWS][MATRIX_COLS];
/* Converts key to action */
__attribute__ ((weak))
action_t action_for_key(uint8_t layer, keypos_t key)

View File

@ -24,10 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "action.h"
/* Keymapping with 16bit action codes */
extern const action_t actionmaps[][MATRIX_ROWS][MATRIX_COLS];
/* Modified key */
#define AC_c(kc) ACTION_MODS_KEY(MOD_LCTL, KC_##kc)
#define AC_s(kc) ACTION_MODS_KEY(MOD_LSFT, KC_##kc)

57
tmk_core/common/unimap.c Normal file
View File

@ -0,0 +1,57 @@
#include "keyboard.h"
#include "action.h"
#include "unimap.h"
#include "print.h"
#if defined(__AVR__)
# include <avr/pgmspace.h>
#endif
/* Keymapping with 16bit action codes */
extern const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS];
// table translates matrix to universal keymap
extern const uint8_t unimap_trans[MATRIX_ROWS][MATRIX_COLS];
// translates raw matrix to universal map
keypos_t unimap_translate(keypos_t key)
{
uint8_t unimap_pos =
#if defined(__AVR__)
pgm_read_byte(&unimap_trans[key.row][key.col]);
#else
unimap_trans[key.row][key.col];
#endif
return (keypos_t) {
.row = ((unimap_pos & 0x70) >> 4),
.col = (unimap_pos & 0x0F)
};
}
/* Converts key to action */
__attribute__ ((weak))
action_t action_for_key(uint8_t layer, keypos_t key)
{
keypos_t uni = unimap_translate(key);
if ((uni.row << 4 | uni.col) == UNIMAP_NO) return (action_t)ACTION_NO;
#if defined(__AVR__)
return (action_t)pgm_read_word(&actionmaps[(layer)][(uni.row)][(uni.col)]);
#else
return actionmaps[(layer)][(uni.row)][(uni.col)];
#endif
}
/* Macro */
__attribute__ ((weak))
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
return MACRO_NONE;
}
/* Function */
__attribute__ ((weak))
void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
{
}

211
tmk_core/common/unimap.h Normal file
View File

@ -0,0 +1,211 @@
/*
Copyright 2016 Jun Wako <wakojun@gmail.com>
*/
#ifndef _UNIMAP_H_
#define _UNIMAP_H_
#include <stdint.h>
#include <stdbool.h>
#include "action.h"
#include "action_code.h"
#include "actionmap.h"
// Universal map table: 8x16=128key
#define UNIMAP_ROWS 8
#define UNIMAP_COLS 16
/* Universal 128-key keyboard layout(8x16)
,-----------------------------------------------.
|F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
,---. |-----------------------------------------------| ,-----------. ,-----------.
|Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|
`---' `-----------------------------------------------' `-----------' `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +|
|-----------------------------------------------------------| `-----------' |---------------|
|CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Retn| | 4| 5| 6|KP,|
|-----------------------------------------------------------| ,---. |---------------|
|Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=|
|-----------------------------------------------------------| ,-----------. |---------------|
|Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent|
`-----------------------------------------------------------' `-----------' `---------------'
App: Windows Menu key
Gui: Windows key, Mac key or Meta key
VDn Vup Mut: Volume control
< #: ISO keys(in UK legend)
KP=: Keypad = for Mac
KP,: Brazilian Keypad Comma
JPY: Japanese Yen()
RO: Japanese (Ro) or Brazilian /(Slash)
MHEN: Japanese (Non Conversion) or Korean Hanja
HENK: Japanese (Conversion) or Korean Hangul/English
KANA: Japanese (Hiragana/Katakana)
https://en.wikipedia.org/wiki/Keyboard_layout#Japanese
https://en.wikipedia.org/wiki/Keyboard_layout#Hangul_.28for_Korean.29
*/
#define UNIMAP( \
K68,K69,K6A,K6B,K6C,K6D,K6E,K6F,K70,K71,K72,K73, \
K29, K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45, K46,K47,K48, K01,K02,K03, \
K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K74,K2A, K49,K4A,K4B, K53,K54,K55,K56, \
K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30, K31, K4C,K4D,K4E, K5F,K60,K61,K57, \
K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34, K32,K28, K5C,K5D,K5E,K66, \
K79,K64,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38, K75,K7D, K52, K59,K5A,K5B,K67, \
K78,K7B,K7A,K77, K2C, K76,K00,K7E,K7F,K65,K7C, K50,K51,K4F, K62, K63,K58 \
) { \
{ AC_##K00, AC_##K01, AC_##K02, AC_##K03, AC_##K04, AC_##K05, AC_##K06, AC_##K07, /* 00-07 */ \
AC_##K08, AC_##K09, AC_##K0A, AC_##K0B, AC_##K0C, AC_##K0D, AC_##K0E, AC_##K0F }, /* 08-0F */ \
{ AC_##K10, AC_##K11, AC_##K12, AC_##K13, AC_##K14, AC_##K15, AC_##K16, AC_##K17, /* 10-17 */ \
AC_##K18, AC_##K19, AC_##K1A, AC_##K1B, AC_##K1C, AC_##K1D, AC_##K1E, AC_##K1F }, /* 18-1F */ \
{ AC_##K20, AC_##K21, AC_##K22, AC_##K23, AC_##K24, AC_##K25, AC_##K26, AC_##K27, /* 20-27 */ \
AC_##K28, AC_##K29, AC_##K2A, AC_##K2B, AC_##K2C, AC_##K2D, AC_##K2E, AC_##K2F }, /* 28-2F */ \
{ AC_##K30, AC_##K31, AC_##K32, AC_##K33, AC_##K34, AC_##K35, AC_##K36, AC_##K37, /* 30-37 */ \
AC_##K38, AC_##K39, AC_##K3A, AC_##K3B, AC_##K3C, AC_##K3D, AC_##K3E, AC_##K3F }, /* 38-3F */ \
{ AC_##K40, AC_##K41, AC_##K42, AC_##K43, AC_##K44, AC_##K45, AC_##K46, AC_##K47, /* 40-47 */ \
AC_##K48, AC_##K49, AC_##K4A, AC_##K4B, AC_##K4C, AC_##K4D, AC_##K4E, AC_##K4F }, /* 48-4F */ \
{ AC_##K50, AC_##K51, AC_##K52, AC_##K53, AC_##K54, AC_##K55, AC_##K56, AC_##K57, /* 50-57 */ \
AC_##K58, AC_##K59, AC_##K5A, AC_##K5B, AC_##K5C, AC_##K5D, AC_##K5E, AC_##K5F }, /* 58-5F */ \
{ AC_##K60, AC_##K61, AC_##K62, AC_##K63, AC_##K64, AC_##K65, AC_##K66, AC_##K67, /* 60-67 */ \
AC_##K68, AC_##K69, AC_##K6A, AC_##K6B, AC_##K6C, AC_##K6D, AC_##K6E, AC_##K6F }, /* 68-6F */ \
{ AC_##K70, AC_##K71, AC_##K72, AC_##K73, AC_##K74, AC_##K75, AC_##K76, AC_##K77, /* 70-77 */ \
AC_##K78, AC_##K79, AC_##K7A, AC_##K7B, AC_##K7C, AC_##K7D, AC_##K7E, AC_##K7F } /* 78-7F */ \
}
// Universal map position codes
enum unimap_position_codes {
// logical name position(row << 4 | col)
// ------------------------------------------------
UNIMAP_KANA, // 0x00
UNIMAP_VOLUME_DOWN, // 0x01
UNIMAP_VOLUME_UP, // 0x02
UNIMAP_VOLUME_MUTE, // 0x03
UNIMAP_A, // 0x04
UNIMAP_B, // 0x05
UNIMAP_C, // 0x06
UNIMAP_D, // 0x07
UNIMAP_E, // 0x08
UNIMAP_F, // 0x09
UNIMAP_G, // 0x0A
UNIMAP_H, // 0x0B
UNIMAP_I, // 0x0C
UNIMAP_J, // 0x0D
UNIMAP_K, // 0x0E
UNIMAP_L, // 0x0F
UNIMAP_M, // 0x10
UNIMAP_N, // 0x11
UNIMAP_O, // 0x12
UNIMAP_P, // 0x13
UNIMAP_Q, // 0x14
UNIMAP_R, // 0x15
UNIMAP_S, // 0x16
UNIMAP_T, // 0x17
UNIMAP_U, // 0x18
UNIMAP_V, // 0x19
UNIMAP_W, // 0x1A
UNIMAP_X, // 0x1B
UNIMAP_Y, // 0x1C
UNIMAP_Z, // 0x1D
UNIMAP_1, // 0x1E
UNIMAP_2, // 0x1F
UNIMAP_3, // 0x20
UNIMAP_4, // 0x21
UNIMAP_5, // 0x22
UNIMAP_6, // 0x23
UNIMAP_7, // 0x24
UNIMAP_8, // 0x25
UNIMAP_9, // 0x26
UNIMAP_0, // 0x27
UNIMAP_ENTER, // 0x28
UNIMAP_ESCAPE, // 0x29
UNIMAP_BSPACE, // 0x2A
UNIMAP_TAB, // 0x2B
UNIMAP_SPACE, // 0x2C
UNIMAP_MINUS, // 0x2D
UNIMAP_EQUAL, // 0x2E
UNIMAP_LBRACKET, // 0x2F
UNIMAP_RBRACKET, // 0x30
UNIMAP_BSLASH, // 0x31
UNIMAP_NONUS_HASH, // 0x32 ISO UK hasu
UNIMAP_SCOLON, // 0x33
UNIMAP_QUOTE, // 0x34
UNIMAP_GRAVE, // 0x35
UNIMAP_COMMA, // 0x36
UNIMAP_DOT, // 0x37
UNIMAP_SLASH, // 0x38
UNIMAP_CAPSLOCK, // 0x39
UNIMAP_F1, // 0x3A
UNIMAP_F2, // 0x3B
UNIMAP_F3, // 0x3C
UNIMAP_F4, // 0x3D
UNIMAP_F5, // 0x3E
UNIMAP_F6, // 0x3F
UNIMAP_F7, // 0x40
UNIMAP_F8, // 0x41
UNIMAP_F9, // 0x42
UNIMAP_F10, // 0x43
UNIMAP_F11, // 0x44
UNIMAP_F12, // 0x45
UNIMAP_PSCREEN, // 0x46
UNIMAP_SCROLLLOCK, // 0x47
UNIMAP_PAUSE, // 0x48
UNIMAP_INSERT, // 0x49
UNIMAP_HOME, // 0x4A
UNIMAP_PGUP, // 0x4B
UNIMAP_DELETE, // 0x4C
UNIMAP_END, // 0x4D
UNIMAP_PGDOWN, // 0x4E
UNIMAP_RIGHT, // 0x4F
UNIMAP_LEFT, // 0x50
UNIMAP_DOWN, // 0x51
UNIMAP_UP, // 0x52
UNIMAP_NUMLOCK, // 0x53
UNIMAP_KP_SLASH, // 0x54
UNIMAP_KP_ASTERISK, // 0x55
UNIMAP_KP_MINUS, // 0x56
UNIMAP_KP_PLUS, // 0x57
UNIMAP_KP_ENTER, // 0x58
UNIMAP_KP_1, // 0x59
UNIMAP_KP_2, // 0x5A
UNIMAP_KP_3, // 0x5B
UNIMAP_KP_4, // 0x5C
UNIMAP_KP_5, // 0x5D
UNIMAP_KP_6, // 0x5E
UNIMAP_KP_7, // 0x5F
UNIMAP_KP_8, // 0x60
UNIMAP_KP_9, // 0x61
UNIMAP_KP_0, // 0x62
UNIMAP_KP_DOT, // 0x63
UNIMAP_NONUS_BSLASH, // 0x64 ISO UK backslash
UNIMAP_APPLICATION, // 0x65
UNIMAP_KP_COMMA, // 0x66
UNIMAP_KP_EQUAL, // 0x67
UNIMAP_F13, // 0x68
UNIMAP_F14, // 0x69
UNIMAP_F15, // 0x6A
UNIMAP_F16, // 0x6B
UNIMAP_F17, // 0x6C
UNIMAP_F18, // 0x6D
UNIMAP_F19, // 0x6E
UNIMAP_F20, // 0x6F
UNIMAP_F21, // 0x70
UNIMAP_F22, // 0x71
UNIMAP_F23, // 0x72
UNIMAP_F24, // 0x73
UNIMAP_JYEN, // 0x74
UNIMAP_RO, // 0x75
UNIMAP_HENK, // 0x76
UNIMAP_MHEN, // 0x77
UNIMAP_LCTRL, // 0x78
UNIMAP_LSHIFT, // 0x79
UNIMAP_LALT, // 0x7A
UNIMAP_LGUI, // 0x7B
UNIMAP_RCTRL, // 0x7C
UNIMAP_RSHIFT, // 0x7D
UNIMAP_RALT, // 0x7E
UNIMAP_RGUI, // 0x7F
UNIMAP_NO, // 0x80
};
#endif

51
tmk_core/doc/unimap.txt Normal file
View File

@ -0,0 +1,51 @@
Unimap
======
universal keymapping framework
using logical 128-key keyboard layout independent from physical keyboad matrix
unimap is actually an actionmap whose size is row:8xcol:16.
/* Keymapping with 16bit action codes */
extern const action_t actionmaps[][UNIMAP_ROWS][UNIMAP_COLS];
/* Universal 128-key keyboard layout(8x16)
,-----------------------------------------------.
|F13|F14|F15|F16|F17|F18|F19|F20|F21|F22|F23|F24|
,---. |-----------------------------------------------| ,-----------. ,-----------.
|Esc| |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12| |PrS|ScL|Pau| |VDn|VUp|Mut|
`---' `-----------------------------------------------' `-----------' `-----------'
,-----------------------------------------------------------. ,-----------. ,---------------.
| `| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|JPY|Bsp| |Ins|Hom|PgU| |NmL| /| *| -|
|-----------------------------------------------------------| |-----------| |---------------|
|Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | |Del|End|PgD| | 7| 8| 9| +|
|-----------------------------------------------------------| `-----------' |---------------|
|CapsL | A| S| D| F| G| H| J| K| L| ;| '| #|Retn| | 4| 5| 6|KP,|
|-----------------------------------------------------------| ,---. |---------------|
|Shft| <| Z| X| C| V| B| N| M| ,| ,| /| RO|Shift | |Up | | 1| 2| 3|KP=|
|-----------------------------------------------------------| ,-----------. |---------------|
|Ctl|Gui|Alt|MHEN| Space |HENK|KANA|Alt|Gui|App|Ctl| |Lef|Dow|Rig| | 0 | .|Ent|
`-----------------------------------------------------------' `-----------' `---------------'
App: Windows Menu key
Gui: Windows key, Mac ⌘ key or Meta key
VDn Vup Mut: Volume control
< #: ISO keys(in UK legend)
KP=: Keypad = for Mac
KP,: Brazilian Keypad Comma
JPY: Japanese Yen(¥)
RO: Japanese ろ(Ro) or Brazilian /(Slash)
MHEN: Japanese 無変換(Non Conversion) or Korean Hanja
HENK: Japanese 変換(Conversion) or Korean Hangul/English
KANA: Japanese かな(Hiragana/Katakana)
https://en.wikipedia.org/wiki/Keyboard_layout#Japanese
https://en.wikipedia.org/wiki/Keyboard_layout#Hangul_.28for_Korean.29
*/
when refering to keymapping physical matrix position needed to be translated into logical one on unimap
the translation is defined in unimap array
row and col of unimap positon is encoded as follows
position = (row << 4) | col
// table translates matrix to universal keymap
extern const uint8_t unimap_trans[MATRIX_ROWS][MATRIX_COLS];