Skip to content

Commit

Permalink
Add kvm keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
jiexi committed Dec 5, 2022
1 parent 7bafd67 commit feddd93
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 3 deletions.
7 changes: 4 additions & 3 deletions keyboard/hhkb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# 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,
# 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.
Expand Down Expand Up @@ -112,7 +112,8 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
# comment out to disable the options.
#
#BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration
MOUSEKEY_ENABLE ?= yes # Mouse keys
#Disabled because of KVM
MOUSEKEY_ENABLE ?= no # Mouse keys
EXTRAKEY_ENABLE ?= yes # Audio control and System control
CONSOLE_ENABLE ?= yes # Console for debug
COMMAND_ENABLE ?= yes # Commands for debug and configuration
Expand Down Expand Up @@ -144,7 +145,7 @@ ifdef KEYMAP
else
ifeq (yes,$(strip $(HHKB_JP)))
SRC := $(KEYMAP_FILE)_jp.c $(SRC)
else
else
SRC := $(KEYMAP_FILE)_hhkb.c $(SRC)
endif
endif
Expand Down
167 changes: 167 additions & 0 deletions keyboard/hhkb/keymap_jp_jiexi_kvm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
/*
* HHKB JP Layout
*/
#include "keymap_common.h"


#ifdef KEYMAP_SECTION_ENABLE
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = {
#else
const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
#endif
/* Layer 0: Default Layer
* ,-----------------------------------------------------------.
* |` | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| BS|
* |-----------------------------------------------------------|
* |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| |
* |------------------------------------------------------` ENT|
* |Esc | A| S| D| F| G| H| J| K| L| ;| '|Fn2| |
* |-----------------------------------------------------------|
* |LShift | Z| X| C| V| B| N| M| ,| .| /|Fn4| Up|RST|
* |-----------------------------------------------------------|
* |Fn0||Ctl|Gui|Alt|Spc| Space |Spc|Alt|Gui|Ctl||Lft|Dwn|Rgt|
* `-----------------------------------------------------------'
*/
KEYMAP_JP(GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,BSPC, \
TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, \
ESC, A, S, D, F, G, H, J, K, L, SCLN,QUOT, FN2,ENT, \
LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,FN4, UP, RSFT, \
FN0, LCTL,LGUI,LALT, SPC, SPC, SPC,RALT,RGUI,RCTL, LEFT,DOWN,RGHT),

/* Layer 1: Extended mode (HHKB Fn)
* ,-----------------------------------------------------------.
* |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
* |-----------------------------------------------------------|
* | |Mut|VoD|VoU| | | | | | |Psc|Slk|Pus| |
* |------------------------------------------------------` |
* |Caps |Ply|Stp|Prv|Nxt| | | | | |Ins|Hom|PgU| |
* |-----------------------------------------------------------|
* | |BiD|BiU| | | | | | |Del|End|PgD|PgU| |
* |-----------------------------------------------------------|
* |Fn0|| | | | | | | | | ||Hom|PgD|End|
* `-----------------------------------------------------------'
*/
KEYMAP_JP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \
TRNS,MUTE,VOLD,VOLU, NO, NO, NO, NO, NO, NO,PSCR,SLCK,PAUS, \
CAPS,MPLY,MSTP,MPRV,MNXT, NO, NO, NO, NO, NO,INS,HOME,PGUP,TRNS, \
TRNS,BRTD,BRTI, NO, NO, NO, NO, NO, NO, DEL, END,PGDN,PGUP,TRNS, \
FN0 ,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,HOME,PGDN, END),

/* Layer 2: Movement mode (JIS BSLS)
* ,-----------------------------------------------------------.
* | |Fn6|Fn7|Fn8|Fn9| | | | | |Fn10|Fn11| | | |
* |-----------------------------------------------------------|
* | | | | |Fn12| | | | | | | | | |
* |------------------------------------------------------` |
* | |Fn14|Fn13| | | | | | | | | |Fn2| |
* |-----------------------------------------------------------|
* | |Fn16|Fn15| | | | | | | | | | | |
* |-----------------------------------------------------------|
* | || | | | | | | | | || | | |
* `-----------------------------------------------------------'
*/
KEYMAP_JP(NO ,FN6, FN7, FN8, FN9, NO, NO, NO, NO, NO, FN10,FN11, NO, NO, NO, \
NO ,NO ,NO ,NO ,FN12, NO, NO, NO, NO, NO, NO, NO, NO, \
NO ,FN14,FN13,NO , NO, NO, NO, NO, NO, NO, NO, NO,FN2, NO, \
TRNS,FN16,FN15,NO , NO, NO, NO, NO, NO, NO, NO, NO, NO,TRNS, \
NO ,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS, NO, NO, NO),

/* Layer 3: Numpad mode (JIS RO)
* ,-----------------------------------------------------------.
* | | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0|Eql|Eql| | BS|
* |-----------------------------------------------------------|
* | | | | | | | | | | | | | | |
* |------------------------------------------------------`PENT|
* | | | | | | | * | / | | | | | | |
* |-----------------------------------------------------------|
* | | | | | | | + | - | , | . | |Fn4| Up| |
* |-----------------------------------------------------------|
* | || | | | | | | | | ||Lft|Dwn|Rgt|
* `-----------------------------------------------------------'
*/
KEYMAP_JP(NO , P1, P2, P3, P4, P5, P6, P7, P8, P9, P0,PEQL,PEQL, NO,BSPC, \
NO , NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, \
NO , NO, NO, NO, NO, NO,PAST,PSLS, NO, NO, NO, NO, NO,PENT, \
TRNS, NO, NO, NO, NO, NO,PPLS,PMNS,PCMM,PDOT, NO, FN4, UP,TRNS, \
NO ,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,LEFT,DOWN,RGHT),
};



/*
* Fn action definition
*/
#ifdef KEYMAP_SECTION_ENABLE
const action_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
#else
const action_t fn_actions[] PROGMEM = {
#endif
[0] = ACTION_LAYER_MOMENTARY(1), // ACTION_LAYER_TAP_TOGGLE
[1] = ACTION_LAYER_INVERT(1, ON_RELEASE), // replaced with Fn0
[2] = ACTION_LAYER_MOMENTARY(2), // ACTION_LAYER_TAP_TOGGLE
[3] = ACTION_LAYER_INVERT(2, ON_RELEASE), // replaced with Fn2
[4] = ACTION_LAYER_MOMENTARY(3), // ACTION_LAYER_TAP_TOGGLE
[5] = ACTION_LAYER_INVERT(3, ON_RELEASE), // replaced with Fn4
[6] = ACTION_MACRO(0),
[7] = ACTION_MACRO(1),
[8] = ACTION_MACRO(2),
[9] = ACTION_MACRO(3),
[10] = ACTION_MACRO(4),
[11] = ACTION_MACRO(5),
[12] = ACTION_MACRO(6),
[13] = ACTION_MACRO(7),
[14] = ACTION_MACRO(8),
[15] = ACTION_MACRO(9),
[16] = ACTION_MACRO(10)
};

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
switch (id) {
case 0:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(1), END ) :
MACRO_NONE );
case 1:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(2), END ) :
MACRO_NONE );
case 2:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(3), END ) :
MACRO_NONE );
case 3:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(4), END ) :
MACRO_NONE );
case 4:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(F1), END ) :
MACRO_NONE );
case 5:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(F2), END ) :
MACRO_NONE );
case 6:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(F3), END ) :
MACRO_NONE );
case 7:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(F5), END ) :
MACRO_NONE );
case 8:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(A), END ) :
MACRO_NONE );
case 9:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(F7), END ) :
MACRO_NONE );
case 10:
return (record->event.pressed ?
MACRO( T(SLCK), T(SLCK), T(U), END ) :
MACRO_NONE );
}
return MACRO_NONE;
}

0 comments on commit feddd93

Please sign in to comment.