diff options
| author | tmk <nobody@nowhere> | 2013-11-29 08:42:40 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-11-29 09:12:28 +0900 |
| commit | fd7833388cdf8b15728d951b63e78571ba2edbc9 (patch) | |
| tree | b146719ffc79ad5f48076e1e3a77929f4e8e19b6 /keyboard/hhkb | |
| parent | d2a83dae8f69f966b47db0316f1580793a810078 (diff) | |
| download | qmk_firmware-fd7833388cdf8b15728d951b63e78571ba2edbc9.tar.gz qmk_firmware-fd7833388cdf8b15728d951b63e78571ba2edbc9.zip | |
Add new keymap framework
Diffstat (limited to 'keyboard/hhkb')
| -rw-r--r-- | keyboard/hhkb/Makefile | 8 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.nodebug | 141 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.pjrc | 8 | ||||
| -rw-r--r-- | keyboard/hhkb/keymap_common.c | 33 | ||||
| -rw-r--r-- | keyboard/hhkb/keymap_common.h | 57 | ||||
| -rw-r--r-- | keyboard/hhkb/keymap_hasu.c (renamed from keyboard/hhkb/keymap.c) | 107 | ||||
| -rw-r--r-- | keyboard/hhkb/keymap_hhkb.c | 62 |
7 files changed, 332 insertions, 84 deletions
diff --git a/keyboard/hhkb/Makefile b/keyboard/hhkb/Makefile index 94078702c..89d05ba15 100644 --- a/keyboard/hhkb/Makefile +++ b/keyboard/hhkb/Makefile | |||
| @@ -49,10 +49,16 @@ TARGET_DIR = . | |||
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | # List C source files here. (C dependencies are automatically generated.) | 51 | # List C source files here. (C dependencies are automatically generated.) |
| 52 | SRC += keymap.c \ | 52 | SRC += keymap_common.c \ |
| 53 | matrix.c \ | 53 | matrix.c \ |
| 54 | led.c | 54 | led.c |
| 55 | 55 | ||
| 56 | ifdef KEYMAP | ||
| 57 | SRC := keymap_$(KEYMAP).c $(SRC) | ||
| 58 | else | ||
| 59 | SRC := keymap_hasu.c $(SRC) | ||
| 60 | endif | ||
| 61 | |||
| 56 | CONFIG_H = config.h | 62 | CONFIG_H = config.h |
| 57 | 63 | ||
| 58 | 64 | ||
diff --git a/keyboard/hhkb/Makefile.nodebug b/keyboard/hhkb/Makefile.nodebug new file mode 100644 index 000000000..f63083f6a --- /dev/null +++ b/keyboard/hhkb/Makefile.nodebug | |||
| @@ -0,0 +1,141 @@ | |||
| 1 | #---------------------------------------------------------------------------- | ||
| 2 | # On command line: | ||
| 3 | # | ||
| 4 | # make all = Make software. | ||
| 5 | # | ||
| 6 | # make clean = Clean out built project files. | ||
| 7 | # | ||
| 8 | # make coff = Convert ELF to AVR COFF. | ||
| 9 | # | ||
| 10 | # make extcoff = Convert ELF to AVR Extended COFF. | ||
| 11 | # | ||
| 12 | # make program = Download the hex file to the device. | ||
| 13 | # Please customize your programmer settings(PROGRAM_CMD) | ||
| 14 | # | ||
| 15 | # make teensy = Download the hex file to the device, using teensy_loader_cli. | ||
| 16 | # (must have teensy_loader_cli installed). | ||
| 17 | # | ||
| 18 | # make dfu = Download the hex file to the device, using dfu-programmer (must | ||
| 19 | # have dfu-programmer installed). | ||
| 20 | # | ||
| 21 | # make flip = Download the hex file to the device, using Atmel FLIP (must | ||
| 22 | # have Atmel FLIP installed). | ||
| 23 | # | ||
| 24 | # make dfu-ee = Download the eeprom file to the device, using dfu-programmer | ||
| 25 | # (must have dfu-programmer installed). | ||
| 26 | # | ||
| 27 | # make flip-ee = Download the eeprom file to the device, using Atmel FLIP | ||
| 28 | # (must have Atmel FLIP installed). | ||
| 29 | # | ||
| 30 | # make debug = Start either simulavr or avarice as specified for debugging, | ||
| 31 | # with avr-gdb or avr-insight as the front end for debugging. | ||
| 32 | # | ||
| 33 | # make filename.s = Just compile filename.c into the assembler code only. | ||
| 34 | # | ||
| 35 | # make filename.i = Create a preprocessed source file for use in submitting | ||
| 36 | # bug reports to the GCC project. | ||
| 37 | # | ||
| 38 | # To rebuild project do "make clean" then "make all". | ||
| 39 | #---------------------------------------------------------------------------- | ||
| 40 | |||
| 41 | # Target file name (without extension). | ||
| 42 | TARGET = hhkb_lufa | ||
| 43 | |||
| 44 | # Directory common source filess exist | ||
| 45 | TOP_DIR = ../.. | ||
| 46 | |||
| 47 | # Directory keyboard dependent files exist | ||
| 48 | TARGET_DIR = . | ||
| 49 | |||
| 50 | |||
| 51 | # List C source files here. (C dependencies are automatically generated.) | ||
| 52 | SRC += keymap_common.c \ | ||
| 53 | matrix.c \ | ||
| 54 | led.c | ||
| 55 | |||
| 56 | ifdef KEYMAP | ||
| 57 | SRC := keymap_$(KEYMAP).c $(SRC) | ||
| 58 | else | ||
| 59 | SRC := keymap_hasu.c $(SRC) | ||
| 60 | endif | ||
| 61 | |||
| 62 | CONFIG_H = config.h | ||
| 63 | |||
| 64 | |||
| 65 | # MCU name | ||
| 66 | # PJRC Teensy++ 2.0 | ||
| 67 | #MCU = at90usb1286 | ||
| 68 | # TMK Alt Controller or PJRC Teensy 2.0 | ||
| 69 | MCU = atmega32u4 | ||
| 70 | |||
| 71 | # Processor frequency. | ||
| 72 | # This will define a symbol, F_CPU, in all source code files equal to the | ||
| 73 | # processor frequency in Hz. You can then use this symbol in your source code to | ||
| 74 | # calculate timings. Do NOT tack on a 'UL' at the end, this will be done | ||
| 75 | # automatically to create a 32-bit value in your source code. | ||
| 76 | # | ||
| 77 | # This will be an integer division of F_USB below, as it is sourced by | ||
| 78 | # F_USB after it has run through any CPU prescalers. Note that this value | ||
| 79 | # does not *change* the processor frequency - it should merely be updated to | ||
| 80 | # reflect the processor speed set externally so that the code can use accurate | ||
| 81 | # software delays. | ||
| 82 | F_CPU = 16000000 | ||
| 83 | |||
| 84 | |||
| 85 | # | ||
| 86 | # LUFA specific | ||
| 87 | # | ||
| 88 | # Target architecture (see library "Board Types" documentation). | ||
| 89 | ARCH = AVR8 | ||
| 90 | |||
| 91 | # Input clock frequency. | ||
| 92 | # This will define a symbol, F_USB, in all source code files equal to the | ||
| 93 | # input clock frequency (before any prescaling is performed) in Hz. This value may | ||
| 94 | # differ from F_CPU if prescaling is used on the latter, and is required as the | ||
| 95 | # raw input clock is fed directly to the PLL sections of the AVR for high speed | ||
| 96 | # clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' | ||
| 97 | # at the end, this will be done automatically to create a 32-bit value in your | ||
| 98 | # source code. | ||
| 99 | # | ||
| 100 | # If no clock division is performed on the input clock inside the AVR (via the | ||
| 101 | # CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. | ||
| 102 | F_USB = $(F_CPU) | ||
| 103 | |||
| 104 | # Interrupt driven control endpoint task | ||
| 105 | OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | ||
| 106 | |||
| 107 | |||
| 108 | # Boot Section Size in *bytes* | ||
| 109 | # Teensy halfKay 512 | ||
| 110 | # Teensy++ halfKay 1024 | ||
| 111 | # Atmel DFU loader 4096 (TMK Alt Controller) | ||
| 112 | # LUFA bootloader 4096 | ||
| 113 | # USBaspLoader 2048 | ||
| 114 | OPT_DEFS += -DBOOTLOADER_SIZE=4096 | ||
| 115 | |||
| 116 | |||
| 117 | # Build Options | ||
| 118 | # comment out to disable the options. | ||
| 119 | # | ||
| 120 | BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration | ||
| 121 | MOUSEKEY_ENABLE = yes # Mouse keys | ||
| 122 | EXTRAKEY_ENABLE = yes # Audio control and System control | ||
| 123 | #CONSOLE_ENABLE = yes # Console for debug | ||
| 124 | COMMAND_ENABLE = yes # Commands for debug and configuration | ||
| 125 | #NKRO_ENABLE = yes # USB Nkey Rollover | ||
| 126 | #KEYMAP_SECTION_ENABLE = yes # fixed address keymap for keymap editor | ||
| 127 | |||
| 128 | |||
| 129 | # Search Path | ||
| 130 | VPATH += $(TARGET_DIR) | ||
| 131 | VPATH += $(TOP_DIR) | ||
| 132 | |||
| 133 | include $(TOP_DIR)/protocol/lufa.mk | ||
| 134 | include $(TOP_DIR)/common.mk | ||
| 135 | include $(TOP_DIR)/rules.mk | ||
| 136 | |||
| 137 | debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION | ||
| 138 | debug-on: all | ||
| 139 | |||
| 140 | debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT | ||
| 141 | debug-off: all | ||
diff --git a/keyboard/hhkb/Makefile.pjrc b/keyboard/hhkb/Makefile.pjrc index 5a781dd23..b6ce9c750 100644 --- a/keyboard/hhkb/Makefile.pjrc +++ b/keyboard/hhkb/Makefile.pjrc | |||
| @@ -13,10 +13,16 @@ TOP_DIR = ../.. | |||
| 13 | TARGET_DIR = . | 13 | TARGET_DIR = . |
| 14 | 14 | ||
| 15 | # keyboard dependent files | 15 | # keyboard dependent files |
| 16 | SRC = keymap.c \ | 16 | SRC = keymap_common.c \ |
| 17 | matrix.c \ | 17 | matrix.c \ |
| 18 | led.c | 18 | led.c |
| 19 | 19 | ||
| 20 | ifdef KEYMAP | ||
| 21 | SRC := keymap_$(KEYMAP).c $(SRC) | ||
| 22 | else | ||
| 23 | SRC := keymap_hasu.c $(SRC) | ||
| 24 | endif | ||
| 25 | |||
| 20 | CONFIG_H = config.h | 26 | CONFIG_H = config.h |
| 21 | 27 | ||
| 22 | 28 | ||
diff --git a/keyboard/hhkb/keymap_common.c b/keyboard/hhkb/keymap_common.c new file mode 100644 index 000000000..67b3db85d --- /dev/null +++ b/keyboard/hhkb/keymap_common.c | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #include <stdint.h> | ||
| 18 | #include "action.h" | ||
| 19 | #include <avr/pgmspace.h> | ||
| 20 | #include "keymap_common.h" | ||
| 21 | |||
| 22 | |||
| 23 | /* translates key to keycode */ | ||
| 24 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | ||
| 25 | { | ||
| 26 | return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); | ||
| 27 | } | ||
| 28 | |||
| 29 | /* translates Fn keycode to action */ | ||
| 30 | action_t keymap_fn_to_action(uint8_t keycode) | ||
| 31 | { | ||
| 32 | return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; | ||
| 33 | } | ||
diff --git a/keyboard/hhkb/keymap_common.h b/keyboard/hhkb/keymap_common.h new file mode 100644 index 000000000..ec922a322 --- /dev/null +++ b/keyboard/hhkb/keymap_common.h | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | #ifndef KEYMAP_COMMON_H | ||
| 18 | #define KEYMAP_COMMON_H | ||
| 19 | |||
| 20 | #include <stdint.h> | ||
| 21 | #include <stdbool.h> | ||
| 22 | #include "keycode.h" | ||
| 23 | #include "action.h" | ||
| 24 | #include "action_code.h" | ||
| 25 | #include "action_layer.h" | ||
| 26 | #include "action_macro.h" | ||
| 27 | #include "action_util.h" | ||
| 28 | #include "report.h" | ||
| 29 | #include "host.h" | ||
| 30 | #include "print.h" | ||
| 31 | #include "debug.h" | ||
| 32 | #include "keymap.h" | ||
| 33 | |||
| 34 | |||
| 35 | extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; | ||
| 36 | extern const uint16_t fn_actions[]; | ||
| 37 | |||
| 38 | |||
| 39 | #define KEYMAP( \ | ||
| 40 | K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \ | ||
| 41 | K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \ | ||
| 42 | K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \ | ||
| 43 | K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \ | ||
| 44 | K35, K36, K37, K57, K56 \ | ||
| 45 | ) \ | ||
| 46 | { \ | ||
| 47 | { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ | ||
| 48 | { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ | ||
| 49 | { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ | ||
| 50 | { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ | ||
| 51 | { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \ | ||
| 52 | { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ | ||
| 53 | { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \ | ||
| 54 | { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO } \ | ||
| 55 | } | ||
| 56 | |||
| 57 | #endif | ||
diff --git a/keyboard/hhkb/keymap.c b/keyboard/hhkb/keymap_hasu.c index f2c6caf48..0297d3b74 100644 --- a/keyboard/hhkb/keymap.c +++ b/keyboard/hhkb/keymap_hasu.c | |||
| @@ -1,57 +1,13 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011,2012,2013 Jun Wako <wakojun@gmail.com> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | /* | 1 | /* |
| 19 | * Keymap for PFU HHKB Pro | 2 | * Hasu: my personal keymap |
| 20 | */ | 3 | */ |
| 21 | #include <stdint.h> | 4 | #include "keymap_common.h" |
| 22 | #include <stdbool.h> | ||
| 23 | #include <avr/pgmspace.h> | ||
| 24 | #include "keycode.h" | ||
| 25 | #include "action.h" | ||
| 26 | #include "action_macro.h" | ||
| 27 | #include "report.h" | ||
| 28 | #include "host.h" | ||
| 29 | #include "debug.h" | ||
| 30 | #include "keymap.h" | ||
| 31 | 5 | ||
| 32 | 6 | ||
| 33 | #define KEYMAP( \ | ||
| 34 | K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \ | ||
| 35 | K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \ | ||
| 36 | K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \ | ||
| 37 | K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \ | ||
| 38 | K35, K36, K37, K57, K56 \ | ||
| 39 | ) \ | ||
| 40 | { \ | ||
| 41 | { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \ | ||
| 42 | { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \ | ||
| 43 | { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ | ||
| 44 | { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \ | ||
| 45 | { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO }, \ | ||
| 46 | { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \ | ||
| 47 | { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \ | ||
| 48 | { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO } \ | ||
| 49 | } | ||
| 50 | |||
| 51 | #ifdef KEYMAP_SECTION_ENABLE | 7 | #ifdef KEYMAP_SECTION_ENABLE |
| 52 | const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { | 8 | const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { |
| 53 | #else | 9 | #else |
| 54 | static const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | 10 | const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { |
| 55 | #endif | 11 | #endif |
| 56 | /* Layer 0: Default Layer | 12 | /* Layer 0: Default Layer |
| 57 | * ,-----------------------------------------------------------. | 13 | * ,-----------------------------------------------------------. |
| @@ -69,7 +25,7 @@ static const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | |||
| 69 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ | 25 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ |
| 70 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ | 26 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ |
| 71 | LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN4, \ | 27 | LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN4, \ |
| 72 | FN5,Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ | 28 | FN5, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ |
| 73 | LGUI,LALT, FN6, RALT,RGUI), | 29 | LGUI,LALT, FN6, RALT,RGUI), |
| 74 | 30 | ||
| 75 | /* Layer 1: HHKB mode (HHKB Fn) | 31 | /* Layer 1: HHKB mode (HHKB Fn) |
| @@ -87,7 +43,7 @@ static const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | |||
| 87 | */ | 43 | */ |
| 88 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | 44 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ |
| 89 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ | 45 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ |
| 90 | LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ | 46 | LCTL,VOLD,VOLU,MUTE,NO, FN9, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ |
| 91 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ | 47 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ |
| 92 | LGUI,LALT, SPC, RALT,RGUI), | 48 | LGUI,LALT, SPC, RALT,RGUI), |
| 93 | 49 | ||
| @@ -192,7 +148,7 @@ enum macro_id { | |||
| 192 | #ifdef KEYMAP_SECTION_ENABLE | 148 | #ifdef KEYMAP_SECTION_ENABLE |
| 193 | const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { | 149 | const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { |
| 194 | #else | 150 | #else |
| 195 | static const uint16_t fn_actions[] PROGMEM = { | 151 | const uint16_t fn_actions[] PROGMEM = { |
| 196 | #endif | 152 | #endif |
| 197 | [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) | 153 | [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) |
| 198 | [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) | 154 | [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) |
| @@ -203,11 +159,12 @@ static const uint16_t fn_actions[] PROGMEM = { | |||
| 203 | [6] = ACTION_LAYER_TAP_KEY(5, KC_SPC), // Mousekey layer with Space | 159 | [6] = ACTION_LAYER_TAP_KEY(5, KC_SPC), // Mousekey layer with Space |
| 204 | [7] = ACTION_LAYER_TOGGLE(3), // Mousekey layer(toggle) | 160 | [7] = ACTION_LAYER_TOGGLE(3), // Mousekey layer(toggle) |
| 205 | [8] = ACTION_MODS_KEY(MOD_LCTL, KC_W), // Close Tab | 161 | [8] = ACTION_MODS_KEY(MOD_LCTL, KC_W), // Close Tab |
| 162 | [9] = ACTION_MODS_KEY(MOD_LSFT, KC_4), // Shift stuck test | ||
| 206 | 163 | ||
| 207 | // [8] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace | 164 | // [8] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace |
| 208 | // [9] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc | 165 | // [9] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc |
| 209 | // [11] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '(' | 166 | [11] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '(' |
| 210 | // [12] = ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // Function: RShift with tap ')' | 167 | [12] = ACTION_FUNCTION_TAP(RSHIFT_RPAREN), // Function: RShift with tap ')' |
| 211 | // [13] = ACTION_MACRO_TAP(LSHIFT_PAREN), // Macro: LShift with tap '(' | 168 | // [13] = ACTION_MACRO_TAP(LSHIFT_PAREN), // Macro: LShift with tap '(' |
| 212 | // [14] = ACTION_MACRO_TAP(RSHIFT_PAREN), // Macro: RShift with tap ')' | 169 | // [14] = ACTION_MACRO_TAP(RSHIFT_PAREN), // Macro: RShift with tap ')' |
| 213 | // [15] = ACTION_MACRO(HELLO), // Macro: say hello | 170 | // [15] = ACTION_MACRO(HELLO), // Macro: say hello |
| @@ -268,18 +225,20 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 268 | // NOTE: cant use register_code to avoid conflicting with magic key bind | 225 | // NOTE: cant use register_code to avoid conflicting with magic key bind |
| 269 | if (event.pressed) { | 226 | if (event.pressed) { |
| 270 | if (tap.count == 0 || tap.interrupted) { | 227 | if (tap.count == 0 || tap.interrupted) { |
| 271 | add_mods(MOD_BIT(KC_LSHIFT)); | 228 | //add_mods(MOD_BIT(KC_LSHIFT)); |
| 229 | layer_on(1); | ||
| 272 | } else { | 230 | } else { |
| 273 | host_add_mods(MOD_BIT(KC_LSHIFT)); | 231 | add_mods(MOD_BIT(KC_LSHIFT)); |
| 274 | host_add_key(KC_9); | 232 | add_key(KC_9); |
| 275 | host_send_keyboard_report(); | 233 | send_keyboard_report(); |
| 276 | host_del_mods(MOD_BIT(KC_LSHIFT)); | 234 | del_mods(MOD_BIT(KC_LSHIFT)); |
| 277 | host_del_key(KC_9); | 235 | del_key(KC_9); |
| 278 | host_send_keyboard_report(); | 236 | send_keyboard_report(); |
| 279 | } | 237 | } |
| 280 | } else { | 238 | } else { |
| 281 | if (tap.count == 0 || tap.interrupted) { | 239 | if (tap.count == 0 || tap.interrupted) { |
| 282 | del_mods(MOD_BIT(KC_LSHIFT)); | 240 | //del_mods(MOD_BIT(KC_LSHIFT)); |
| 241 | layer_off(1); | ||
| 283 | } | 242 | } |
| 284 | } | 243 | } |
| 285 | break; | 244 | break; |
| @@ -289,12 +248,12 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 289 | if (tap.count == 0 || tap.interrupted) { | 248 | if (tap.count == 0 || tap.interrupted) { |
| 290 | add_mods(MOD_BIT(KC_RSHIFT)); | 249 | add_mods(MOD_BIT(KC_RSHIFT)); |
| 291 | } else { | 250 | } else { |
| 292 | host_add_mods(MOD_BIT(KC_RSHIFT)); | 251 | add_mods(MOD_BIT(KC_RSHIFT)); |
| 293 | host_add_key(KC_0); | 252 | add_key(KC_0); |
| 294 | host_send_keyboard_report(); | 253 | send_keyboard_report(); |
| 295 | host_del_mods(MOD_BIT(KC_RSHIFT)); | 254 | del_mods(MOD_BIT(KC_RSHIFT)); |
| 296 | host_del_key(KC_0); | 255 | del_key(KC_0); |
| 297 | host_send_keyboard_report(); | 256 | send_keyboard_report(); |
| 298 | } | 257 | } |
| 299 | } else { | 258 | } else { |
| 300 | if (tap.count == 0 || tap.interrupted) { | 259 | if (tap.count == 0 || tap.interrupted) { |
| @@ -304,19 +263,3 @@ void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | |||
| 304 | break; | 263 | break; |
| 305 | } | 264 | } |
| 306 | } | 265 | } |
| 307 | |||
| 308 | |||
| 309 | |||
| 310 | /* translates key to keycode */ | ||
| 311 | uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) | ||
| 312 | { | ||
| 313 | return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); | ||
| 314 | } | ||
| 315 | |||
| 316 | /* translates Fn index to action */ | ||
| 317 | action_t keymap_fn_to_action(uint8_t keycode) | ||
| 318 | { | ||
| 319 | action_t action; | ||
| 320 | action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]); | ||
| 321 | return action; | ||
| 322 | } | ||
diff --git a/keyboard/hhkb/keymap_hhkb.c b/keyboard/hhkb/keymap_hhkb.c new file mode 100644 index 000000000..1df16e13f --- /dev/null +++ b/keyboard/hhkb/keymap_hhkb.c | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | /* | ||
| 2 | * HHKB Layout | ||
| 3 | */ | ||
| 4 | #include "keymap_common.h" | ||
| 5 | |||
| 6 | |||
| 7 | #ifdef KEYMAP_SECTION_ENABLE | ||
| 8 | const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { | ||
| 9 | #else | ||
| 10 | const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { | ||
| 11 | #endif | ||
| 12 | /* Layer 0: Default Layer | ||
| 13 | * ,-----------------------------------------------------------. | ||
| 14 | * |Esc| 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =| \| `| | ||
| 15 | * |-----------------------------------------------------------| | ||
| 16 | * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]|Backs| | ||
| 17 | * |-----------------------------------------------------------| | ||
| 18 | * |Contro| A| S| D| F| G| H| J| K| L| ;| '|Enter | | ||
| 19 | * |-----------------------------------------------------------| | ||
| 20 | * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift |Fn0| | ||
| 21 | * `-----------------------------------------------------------' | ||
| 22 | * |Gui|Alt | Space |Alt |Gui| | ||
| 23 | * `-------------------------------------------' | ||
| 24 | */ | ||
| 25 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ | ||
| 26 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ | ||
| 27 | LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,ENT, \ | ||
| 28 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RSFT,FN0, \ | ||
| 29 | LGUI,LALT, SPC, RALT,RGUI), | ||
| 30 | |||
| 31 | /* Layer 1: HHKB mode (HHKB Fn) | ||
| 32 | * ,-----------------------------------------------------------. | ||
| 33 | * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 34 | * |-----------------------------------------------------------| | ||
| 35 | * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| | ||
| 36 | * |-----------------------------------------------------------| | ||
| 37 | * | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | | ||
| 38 | * |-----------------------------------------------------------| | ||
| 39 | * | | | | | | | +| -|End|PgD|Dow| | | | ||
| 40 | * `-----------------------------------------------------------' | ||
| 41 | * | | | | | | | ||
| 42 | * `-------------------------------------------' | ||
| 43 | */ | ||
| 44 | KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 45 | CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC, \ | ||
| 46 | TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT, \ | ||
| 47 | TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS, \ | ||
| 48 | TRNS,TRNS, TRNS, TRNS,TRNS), | ||
| 49 | }; | ||
| 50 | |||
| 51 | |||
| 52 | |||
| 53 | /* | ||
| 54 | * Fn action definition | ||
| 55 | */ | ||
| 56 | #ifdef KEYMAP_SECTION_ENABLE | ||
| 57 | const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { | ||
| 58 | #else | ||
| 59 | const uint16_t fn_actions[] PROGMEM = { | ||
| 60 | #endif | ||
| 61 | [0] = ACTION_LAYER_MOMENTARY(1), | ||
| 62 | }; | ||
