diff options
| -rw-r--r-- | keyboard/hhkb/Makefile.nodebug | 141 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.rn42 (renamed from keyboard/hhkb_rn42/Makefile) | 22 | ||||
| -rw-r--r-- | keyboard/hhkb/README.md | 17 | ||||
| -rw-r--r-- | keyboard/hhkb/config_rn42.h (renamed from keyboard/hhkb_rn42/config.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/hhkb_avr.h | 28 | ||||
| -rw-r--r-- | keyboard/hhkb/matrix.c | 27 | ||||
| -rw-r--r-- | keyboard/hhkb/not_supported/Makefile.iwrap (renamed from keyboard/hhkb/Makefile.iwrap) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/not_supported/Makefile.vusb (renamed from keyboard/hhkb/Makefile.vusb) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/not_supported/config_iwrap.h (renamed from keyboard/hhkb/config_iwrap.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/not_supported/config_vusb.h (renamed from keyboard/hhkb/config_vusb.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/not_supported/iwrap.txt (renamed from keyboard/hhkb/iwrap.txt) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/not_supported/usbconfig.h (renamed from keyboard/hhkb/usbconfig.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42.mk (renamed from keyboard/hhkb_rn42/rn42.mk) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/MEMO.txt (renamed from keyboard/hhkb_rn42/rn42/MEMO.txt) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/PowerSave.txt (renamed from keyboard/hhkb_rn42/PowerSave.txt) | 47 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/RN42.txt (renamed from keyboard/hhkb_rn42/rn42/RN42.txt) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/battery.c (renamed from keyboard/hhkb_rn42/rn42/battery.c) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/battery.h (renamed from keyboard/hhkb_rn42/rn42/battery.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/main.c (renamed from keyboard/hhkb_rn42/rn42/main.c) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/rn42.c (renamed from keyboard/hhkb_rn42/rn42/rn42.c) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/rn42.h (renamed from keyboard/hhkb_rn42/rn42/rn42.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/rn42_task.c (renamed from keyboard/hhkb_rn42/rn42/rn42_task.c) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/rn42_task.h (renamed from keyboard/hhkb_rn42/rn42/rn42_task.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/suart.S (renamed from keyboard/hhkb_rn42/rn42/suart.S) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb/rn42/suart.h (renamed from keyboard/hhkb_rn42/rn42/suart.h) | 0 | ||||
| -rw-r--r-- | keyboard/hhkb_rn42/hhkb_avr.h | 166 | ||||
| -rw-r--r-- | keyboard/hhkb_rn42/keymap_common.c | 33 | ||||
| -rw-r--r-- | keyboard/hhkb_rn42/keymap_common.h | 84 | ||||
| -rw-r--r-- | keyboard/hhkb_rn42/keymap_hasu.c | 282 | ||||
| -rw-r--r-- | keyboard/hhkb_rn42/keymap_jp.c | 50 | ||||
| -rw-r--r-- | keyboard/hhkb_rn42/led.c | 33 | ||||
| -rw-r--r-- | keyboard/hhkb_rn42/matrix.c | 190 |
32 files changed, 73 insertions, 1047 deletions
diff --git a/keyboard/hhkb/Makefile.nodebug b/keyboard/hhkb/Makefile.nodebug deleted file mode 100644 index 578ba70c4..000000000 --- a/keyboard/hhkb/Makefile.nodebug +++ /dev/null | |||
| @@ -1,141 +0,0 @@ | |||
| 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_rn42/Makefile b/keyboard/hhkb/Makefile.rn42 index 3d9a602a5..b1eacd070 100644 --- a/keyboard/hhkb_rn42/Makefile +++ b/keyboard/hhkb/Makefile.rn42 | |||
| @@ -39,7 +39,7 @@ | |||
| 39 | #---------------------------------------------------------------------------- | 39 | #---------------------------------------------------------------------------- |
| 40 | 40 | ||
| 41 | # Target file name (without extension). | 41 | # Target file name (without extension). |
| 42 | TARGET = hhkb_lufa | 42 | TARGET = hhkb_rn42 |
| 43 | 43 | ||
| 44 | # Directory common source filess exist | 44 | # Directory common source filess exist |
| 45 | TOP_DIR = ../.. | 45 | TOP_DIR = ../.. |
| @@ -53,13 +53,10 @@ SRC += keymap_common.c \ | |||
| 53 | matrix.c \ | 53 | matrix.c \ |
| 54 | led.c | 54 | led.c |
| 55 | 55 | ||
| 56 | CONFIG_H = config.h | 56 | CONFIG_H = config_rn42.h |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | # MCU name | 59 | # MCU name |
| 60 | # PJRC Teensy++ 2.0 | ||
| 61 | #MCU = at90usb1286 | ||
| 62 | # TMK Alt Controller or PJRC Teensy 2.0 | ||
| 63 | MCU = atmega32u4 | 60 | MCU = atmega32u4 |
| 64 | 61 | ||
| 65 | # Processor frequency. | 62 | # Processor frequency. |
| @@ -121,11 +118,6 @@ COMMAND_ENABLE = yes # Commands for debug and configuration | |||
| 121 | #HHKB_JP = yes # HHKB JP support | 118 | #HHKB_JP = yes # HHKB JP support |
| 122 | 119 | ||
| 123 | 120 | ||
| 124 | ifdef HHKB_JP | ||
| 125 | OPT_DEFS += -DHHKB_JP | ||
| 126 | endif | ||
| 127 | |||
| 128 | |||
| 129 | # | 121 | # |
| 130 | # Keymap file | 122 | # Keymap file |
| 131 | # | 123 | # |
| @@ -134,12 +126,17 @@ ifdef KEYMAP | |||
| 134 | else | 126 | else |
| 135 | ifdef HHKB_JP | 127 | ifdef HHKB_JP |
| 136 | SRC := keymap_jp.c $(SRC) | 128 | SRC := keymap_jp.c $(SRC) |
| 137 | else | 129 | else |
| 138 | SRC := keymap_hasu.c $(SRC) | 130 | SRC := keymap_hhkb.c $(SRC) |
| 139 | endif | 131 | endif |
| 140 | endif | 132 | endif |
| 141 | 133 | ||
| 142 | 134 | ||
| 135 | ifneq (, $(or $(findstring keymap_jp.c, $(SRC)), $(findstring yes, $(HHKB_JP)))) | ||
| 136 | OPT_DEFS += -DHHKB_JP | ||
| 137 | endif | ||
| 138 | |||
| 139 | |||
| 143 | # Search Path | 140 | # Search Path |
| 144 | VPATH += $(TARGET_DIR) | 141 | VPATH += $(TARGET_DIR) |
| 145 | VPATH += $(TOP_DIR) | 142 | VPATH += $(TOP_DIR) |
| @@ -154,4 +151,5 @@ debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION | |||
| 154 | debug-on: all | 151 | debug-on: all |
| 155 | 152 | ||
| 156 | debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT | 153 | debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT |
| 154 | debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS)) | ||
| 157 | debug-off: all | 155 | debug-off: all |
diff --git a/keyboard/hhkb/README.md b/keyboard/hhkb/README.md index f9fd16507..fcd72e194 100644 --- a/keyboard/hhkb/README.md +++ b/keyboard/hhkb/README.md | |||
| @@ -10,11 +10,17 @@ See [this thread][AltController] in geekhack.org. | |||
| 10 | [AltController]: http://geekhack.org/index.php?topic=12047.0 | 10 | [AltController]: http://geekhack.org/index.php?topic=12047.0 |
| 11 | 11 | ||
| 12 | 12 | ||
| 13 | ## Update | ||
| 14 | * Bluetooth module RN-42 is supported.(2015/01) | ||
| 15 | * V-USB and iWRAP are no longer supported now, but still it'll works with a little fix. See not_supported directory.(2015/01) | ||
| 16 | |||
| 17 | |||
| 13 | ##Features | 18 | ##Features |
| 14 | * Customizable keymap | 19 | * Customizable keymap |
| 15 | * More keymap layers(more Fn keys) | 20 | * More keymap layers(more Fn keys) |
| 16 | * Mouse keys | 21 | * Mouse keys |
| 17 | * USB NKRO | 22 | * USB NKRO |
| 23 | * Bluetooth(RN-42) | ||
| 18 | 24 | ||
| 19 | See README of [tmk_keyboard] for more. | 25 | See README of [tmk_keyboard] for more. |
| 20 | 26 | ||
| @@ -50,8 +56,9 @@ If you use other than **TMK Alt Controller Board** set proper `MCU`, `BOOTLOADER | |||
| 50 | ### Build | 56 | ### Build |
| 51 | Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like: | 57 | Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like: |
| 52 | 58 | ||
| 53 | $ make KEYMAP=[hasu|hhkb|spacefn|<name>] | 59 | $ make -f Makefile.<jp|pjrc|rn42> KEYMAP=(hasu|hhkb|spacefn|<name>) |
| 54 | $ make -f Makefile.jp KEYMAP=[jp|<name>] # for HHKB JP | 60 | |
| 61 | You can omit `-f` option when you use `Makefile`. `Makefile` is used for **Pro2 and Pro**, `Makefile.jp` fits for **JP** model and `Makefile.rn42` supports Bluetooth module **RN-42**. `Makefile.pjrc` uses **PJRC** as output protocol instead of **LUFA**. | ||
| 55 | 62 | ||
| 56 | 63 | ||
| 57 | ### Program | 64 | ### Program |
| @@ -59,13 +66,11 @@ First, push reset button on board to start bootloader. | |||
| 59 | 66 | ||
| 60 | This command programs the controller with [dfu-programmer] if the tool is installed and configured properly. | 67 | This command programs the controller with [dfu-programmer] if the tool is installed and configured properly. |
| 61 | 68 | ||
| 62 | $ make dfu | 69 | $ make -f Makefile.<variant> KEYMAP=<name> dfu |
| 63 | $ make -f Makefile.jp dfu # for HHKB JP | ||
| 64 | 70 | ||
| 65 | Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available. | 71 | Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available. |
| 66 | 72 | ||
| 67 | $ make flip | 73 | $ make -f Makefile.<variant> KEYMAP=<name> flip |
| 68 | $ make -f Makefile.jp flip # for HHKB JP | ||
| 69 | 74 | ||
| 70 | Use [Teensy Loader] if your controller is Teensy/Teensy++. | 75 | Use [Teensy Loader] if your controller is Teensy/Teensy++. |
| 71 | 76 | ||
diff --git a/keyboard/hhkb_rn42/config.h b/keyboard/hhkb/config_rn42.h index 21e73f1c5..21e73f1c5 100644 --- a/keyboard/hhkb_rn42/config.h +++ b/keyboard/hhkb/config_rn42.h | |||
diff --git a/keyboard/hhkb/hhkb_avr.h b/keyboard/hhkb/hhkb_avr.h index b7bd507b5..7ea6322c7 100644 --- a/keyboard/hhkb/hhkb_avr.h +++ b/keyboard/hhkb/hhkb_avr.h | |||
| @@ -41,17 +41,32 @@ static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); } | |||
| 41 | static inline bool KEY_STATE(void) { return (PIND & (1<<7)); } | 41 | static inline bool KEY_STATE(void) { return (PIND & (1<<7)); } |
| 42 | static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); } | 42 | static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); } |
| 43 | static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); } | 43 | static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); } |
| 44 | #ifdef HHKB_POWER_SAVING | ||
| 45 | static inline void KEY_POWER_ON(void) { | ||
| 46 | DDRB = 0xFF; PORTB = 0x40; // change pins output | ||
| 47 | DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on | ||
| 48 | /* Without this wait you will miss or get false key events. */ | ||
| 49 | _delay_ms(5); // wait for powering up | ||
| 50 | } | ||
| 51 | static inline void KEY_POWER_OFF(void) { | ||
| 52 | /* input with pull-up consumes less than without it when pin is open. */ | ||
| 53 | DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up | ||
| 54 | DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off | ||
| 55 | } | ||
| 56 | static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); } | ||
| 57 | #else | ||
| 44 | static inline void KEY_POWER_ON(void) {} | 58 | static inline void KEY_POWER_ON(void) {} |
| 45 | static inline void KEY_POWER_OFF(void) {} | 59 | static inline void KEY_POWER_OFF(void) {} |
| 60 | static inline bool KEY_POWER_STATE(void) { return true; } | ||
| 61 | #endif | ||
| 46 | static inline void KEY_INIT(void) | 62 | static inline void KEY_INIT(void) |
| 47 | { | 63 | { |
| 64 | /* row,col,prev: output */ | ||
| 48 | DDRB = 0xFF; | 65 | DDRB = 0xFF; |
| 49 | PORTB = 0x00; | 66 | PORTB = 0x40; // unable |
| 67 | /* key: input with pull-up */ | ||
| 50 | DDRD &= ~0x80; | 68 | DDRD &= ~0x80; |
| 51 | PORTD |= 0x80; | 69 | PORTD |= 0x80; |
| 52 | /* keyswitch board power on */ | ||
| 53 | DDRD |= (1<<4); | ||
| 54 | PORTD |= (1<<4); | ||
| 55 | #ifdef HHKB_JP | 70 | #ifdef HHKB_JP |
| 56 | /* row extention for HHKB JP */ | 71 | /* row extention for HHKB JP */ |
| 57 | DDRC |= (1<<6|1<<7); | 72 | DDRC |= (1<<6|1<<7); |
| @@ -59,6 +74,8 @@ static inline void KEY_INIT(void) | |||
| 59 | #endif | 74 | #endif |
| 60 | KEY_UNABLE(); | 75 | KEY_UNABLE(); |
| 61 | KEY_PREV_OFF(); | 76 | KEY_PREV_OFF(); |
| 77 | |||
| 78 | KEY_POWER_OFF(); | ||
| 62 | } | 79 | } |
| 63 | static inline void KEY_SELECT(uint8_t ROW, uint8_t COL) | 80 | static inline void KEY_SELECT(uint8_t ROW, uint8_t COL) |
| 64 | { | 81 | { |
| @@ -98,6 +115,7 @@ static inline void KEY_SELECT(uint8_t ROW, uint8_t COL) | |||
| 98 | #define KEY_PREV_OFF() (PORTE &= ~(1<<7)) | 115 | #define KEY_PREV_OFF() (PORTE &= ~(1<<7)) |
| 99 | #define KEY_POWER_ON() | 116 | #define KEY_POWER_ON() |
| 100 | #define KEY_POWER_OFF() | 117 | #define KEY_POWER_OFF() |
| 118 | #define KEY_POWER_STATE() true | ||
| 101 | 119 | ||
| 102 | 120 | ||
| 103 | #else | 121 | #else |
diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c index b0af4baa5..fb9699794 100644 --- a/keyboard/hhkb/matrix.c +++ b/keyboard/hhkb/matrix.c | |||
| @@ -27,8 +27,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 27 | #include "timer.h" | 27 | #include "timer.h" |
| 28 | #include "matrix.h" | 28 | #include "matrix.h" |
| 29 | #include "hhkb_avr.h" | 29 | #include "hhkb_avr.h" |
| 30 | #include <avr/wdt.h> | ||
| 31 | #include "suspend.h" | ||
| 32 | #include "lufa.h" | ||
| 30 | 33 | ||
| 31 | 34 | ||
| 35 | // matrix power saving | ||
| 36 | #define MATRIX_POWER_SAVE 10000 | ||
| 37 | static uint32_t matrix_last_modified = 0; | ||
| 38 | |||
| 32 | // matrix state buffer(1:on, 0:off) | 39 | // matrix state buffer(1:on, 0:off) |
| 33 | static matrix_row_t *matrix; | 40 | static matrix_row_t *matrix; |
| 34 | static matrix_row_t *matrix_prev; | 41 | static matrix_row_t *matrix_prev; |
| @@ -72,7 +79,8 @@ uint8_t matrix_scan(void) | |||
| 72 | matrix_prev = matrix; | 79 | matrix_prev = matrix; |
| 73 | matrix = tmp; | 80 | matrix = tmp; |
| 74 | 81 | ||
| 75 | KEY_POWER_ON(); | 82 | // power on |
| 83 | if (!KEY_POWER_STATE()) KEY_POWER_ON(); | ||
| 76 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | 84 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { |
| 77 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | 85 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { |
| 78 | KEY_SELECT(row, col); | 86 | KEY_SELECT(row, col); |
| @@ -126,8 +134,16 @@ uint8_t matrix_scan(void) | |||
| 126 | // This takes 25us or more to make sure KEY_STATE returns to idle state. | 134 | // This takes 25us or more to make sure KEY_STATE returns to idle state. |
| 127 | _delay_us(75); | 135 | _delay_us(75); |
| 128 | } | 136 | } |
| 137 | if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32(); | ||
| 138 | } | ||
| 139 | // power off | ||
| 140 | if (KEY_POWER_STATE() && | ||
| 141 | (USB_DeviceState == DEVICE_STATE_Suspended || | ||
| 142 | USB_DeviceState == DEVICE_STATE_Unattached ) && | ||
| 143 | timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) { | ||
| 144 | KEY_POWER_OFF(); | ||
| 145 | suspend_power_down(); | ||
| 129 | } | 146 | } |
| 130 | KEY_POWER_OFF(); | ||
| 131 | return 1; | 147 | return 1; |
| 132 | } | 148 | } |
| 133 | 149 | ||
| @@ -165,3 +181,10 @@ void matrix_print(void) | |||
| 165 | xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row))); | 181 | xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row))); |
| 166 | } | 182 | } |
| 167 | } | 183 | } |
| 184 | |||
| 185 | void matrix_power_up(void) { | ||
| 186 | KEY_POWER_ON(); | ||
| 187 | } | ||
| 188 | void matrix_power_down(void) { | ||
| 189 | KEY_POWER_OFF(); | ||
| 190 | } | ||
diff --git a/keyboard/hhkb/Makefile.iwrap b/keyboard/hhkb/not_supported/Makefile.iwrap index 2d9d82c48..2d9d82c48 100644 --- a/keyboard/hhkb/Makefile.iwrap +++ b/keyboard/hhkb/not_supported/Makefile.iwrap | |||
diff --git a/keyboard/hhkb/Makefile.vusb b/keyboard/hhkb/not_supported/Makefile.vusb index 4343b210d..4343b210d 100644 --- a/keyboard/hhkb/Makefile.vusb +++ b/keyboard/hhkb/not_supported/Makefile.vusb | |||
diff --git a/keyboard/hhkb/config_iwrap.h b/keyboard/hhkb/not_supported/config_iwrap.h index 747c75513..747c75513 100644 --- a/keyboard/hhkb/config_iwrap.h +++ b/keyboard/hhkb/not_supported/config_iwrap.h | |||
diff --git a/keyboard/hhkb/config_vusb.h b/keyboard/hhkb/not_supported/config_vusb.h index 44f7acd6c..44f7acd6c 100644 --- a/keyboard/hhkb/config_vusb.h +++ b/keyboard/hhkb/not_supported/config_vusb.h | |||
diff --git a/keyboard/hhkb/iwrap.txt b/keyboard/hhkb/not_supported/iwrap.txt index 20a2420a0..20a2420a0 100644 --- a/keyboard/hhkb/iwrap.txt +++ b/keyboard/hhkb/not_supported/iwrap.txt | |||
diff --git a/keyboard/hhkb/usbconfig.h b/keyboard/hhkb/not_supported/usbconfig.h index c3aad34be..c3aad34be 100644 --- a/keyboard/hhkb/usbconfig.h +++ b/keyboard/hhkb/not_supported/usbconfig.h | |||
diff --git a/keyboard/hhkb_rn42/rn42.mk b/keyboard/hhkb/rn42.mk index fd6f7db1a..fd6f7db1a 100644 --- a/keyboard/hhkb_rn42/rn42.mk +++ b/keyboard/hhkb/rn42.mk | |||
diff --git a/keyboard/hhkb_rn42/rn42/MEMO.txt b/keyboard/hhkb/rn42/MEMO.txt index f772c4cb5..f772c4cb5 100644 --- a/keyboard/hhkb_rn42/rn42/MEMO.txt +++ b/keyboard/hhkb/rn42/MEMO.txt | |||
diff --git a/keyboard/hhkb_rn42/PowerSave.txt b/keyboard/hhkb/rn42/PowerSave.txt index 9aa89f441..8aea1c6dd 100644 --- a/keyboard/hhkb_rn42/PowerSave.txt +++ b/keyboard/hhkb/rn42/PowerSave.txt | |||
| @@ -1,11 +1,9 @@ | |||
| 1 | RN-42 | 1 | Power Saving |
| 2 | ===== | 2 | ============ |
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | 12/11 | 5 | MCU+HHKB Power Comsumption |
| 6 | Power Comsumption | 6 | -------------------------- |
| 7 | MCU+HHKB | ||
| 8 | -------- | ||
| 9 | Battery drive: | 7 | Battery drive: |
| 10 | idle 18.9mA | 8 | idle 18.9mA |
| 11 | active 35.8mA | 9 | active 35.8mA |
| @@ -76,40 +74,3 @@ S%,1000 status led and connection control don't work | |||
| 76 | GPIO5: status LED | 74 | GPIO5: status LED |
| 77 | GPIO6: Connection control | 75 | GPIO6: Connection control |
| 78 | GPIO2: linked status | 76 | GPIO2: linked status |
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | Ver 6.15 04/26/2013 | ||
| 85 | (c) Roving Networks | ||
| 86 | ***Settings*** | ||
| 87 | BTA=00066667BBE9 | ||
| 88 | BTName=tmkBT-BBE9 | ||
| 89 | Baudrt(SW4)=115K | ||
| 90 | Mode =DTR | ||
| 91 | Authen=1 | ||
| 92 | Bonded=0 | ||
| 93 | Rem=001BDC06415B | ||
| 94 | ***ADVANCED Settings*** | ||
| 95 | SrvName= keyboard/mouse | ||
| 96 | SrvClass=0000 | ||
| 97 | DevClass=1F00 | ||
| 98 | InqWindw=0012 | ||
| 99 | PagWindw=0012 | ||
| 100 | CfgTimer=255 | ||
| 101 | StatuStr=NULL | ||
| 102 | HidFlags=3c | ||
| 103 | DTRtimer=8 | ||
| 104 | KeySwapr=0 | ||
| 105 | ***OTHER Settings*** | ||
| 106 | Profile= HID | ||
| 107 | CfgChar= $ | ||
| 108 | SniffEna=8010 | ||
| 109 | LowPower=0 S|, | ||
| 110 | TX Power=fff4 SY, | ||
| 111 | IOPorts= 0 | ||
| 112 | IOValues=0 | ||
| 113 | Sleeptmr=0 | ||
| 114 | DebugMod=0 | ||
| 115 | RoleSwch=0 | ||
diff --git a/keyboard/hhkb_rn42/rn42/RN42.txt b/keyboard/hhkb/rn42/RN42.txt index ace30da4e..ace30da4e 100644 --- a/keyboard/hhkb_rn42/rn42/RN42.txt +++ b/keyboard/hhkb/rn42/RN42.txt | |||
diff --git a/keyboard/hhkb_rn42/rn42/battery.c b/keyboard/hhkb/rn42/battery.c index 7e868c964..7e868c964 100644 --- a/keyboard/hhkb_rn42/rn42/battery.c +++ b/keyboard/hhkb/rn42/battery.c | |||
diff --git a/keyboard/hhkb_rn42/rn42/battery.h b/keyboard/hhkb/rn42/battery.h index 180d4dcfa..180d4dcfa 100644 --- a/keyboard/hhkb_rn42/rn42/battery.h +++ b/keyboard/hhkb/rn42/battery.h | |||
diff --git a/keyboard/hhkb_rn42/rn42/main.c b/keyboard/hhkb/rn42/main.c index 83d995038..83d995038 100644 --- a/keyboard/hhkb_rn42/rn42/main.c +++ b/keyboard/hhkb/rn42/main.c | |||
diff --git a/keyboard/hhkb_rn42/rn42/rn42.c b/keyboard/hhkb/rn42/rn42.c index 756285d7b..756285d7b 100644 --- a/keyboard/hhkb_rn42/rn42/rn42.c +++ b/keyboard/hhkb/rn42/rn42.c | |||
diff --git a/keyboard/hhkb_rn42/rn42/rn42.h b/keyboard/hhkb/rn42/rn42.h index db6916fe8..db6916fe8 100644 --- a/keyboard/hhkb_rn42/rn42/rn42.h +++ b/keyboard/hhkb/rn42/rn42.h | |||
diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.c b/keyboard/hhkb/rn42/rn42_task.c index 5107fef48..5107fef48 100644 --- a/keyboard/hhkb_rn42/rn42/rn42_task.c +++ b/keyboard/hhkb/rn42/rn42_task.c | |||
diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.h b/keyboard/hhkb/rn42/rn42_task.h index 8f6c3ab64..8f6c3ab64 100644 --- a/keyboard/hhkb_rn42/rn42/rn42_task.h +++ b/keyboard/hhkb/rn42/rn42_task.h | |||
diff --git a/keyboard/hhkb_rn42/rn42/suart.S b/keyboard/hhkb/rn42/suart.S index 9fa545292..9fa545292 100644 --- a/keyboard/hhkb_rn42/rn42/suart.S +++ b/keyboard/hhkb/rn42/suart.S | |||
diff --git a/keyboard/hhkb_rn42/rn42/suart.h b/keyboard/hhkb/rn42/suart.h index 72725b998..72725b998 100644 --- a/keyboard/hhkb_rn42/rn42/suart.h +++ b/keyboard/hhkb/rn42/suart.h | |||
diff --git a/keyboard/hhkb_rn42/hhkb_avr.h b/keyboard/hhkb_rn42/hhkb_avr.h deleted file mode 100644 index 0321977d1..000000000 --- a/keyboard/hhkb_rn42/hhkb_avr.h +++ /dev/null | |||
| @@ -1,166 +0,0 @@ | |||
| 1 | #ifndef HHKB_AVR_H | ||
| 2 | #define HHKB_AVR_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <avr/io.h> | ||
| 7 | #include <avr/interrupt.h> | ||
| 8 | #include <util/delay.h> | ||
| 9 | |||
| 10 | |||
| 11 | // Timer resolution check | ||
| 12 | #if (1000000/TIMER_RAW_FREQ > 20) | ||
| 13 | # error "Timer resolution(>20us) is not enough for HHKB matrix scan tweak on V-USB." | ||
| 14 | #endif | ||
| 15 | |||
| 16 | |||
| 17 | /* | ||
| 18 | * HHKB Matrix I/O | ||
| 19 | * | ||
| 20 | * row: HC4051[A,B,C] selects scan row0-7 | ||
| 21 | * row-ext: [En0,En1] row extention for JP | ||
| 22 | * col: LS145[A,B,C,D] selects scan col0-7 and enable(D) | ||
| 23 | * key: on: 0/off: 1 | ||
| 24 | * prev: hysteresis control: assert(1) when previous key state is on | ||
| 25 | */ | ||
| 26 | |||
| 27 | |||
| 28 | #if defined(__AVR_ATmega32U4__) | ||
| 29 | /* | ||
| 30 | * For TMK HHKB alt controller(ATMega32U4) | ||
| 31 | * | ||
| 32 | * row: PB0-2 | ||
| 33 | * col: PB3-5,6 | ||
| 34 | * key: PD7(pull-uped) | ||
| 35 | * prev: PB7 | ||
| 36 | * power: PD4(L:off/H:on) | ||
| 37 | * row-ext: PC6,7 for HHKB JP(active low) | ||
| 38 | */ | ||
| 39 | static inline void KEY_ENABLE(void) { (PORTB &= ~(1<<6)); } | ||
| 40 | static inline void KEY_UNABLE(void) { (PORTB |= (1<<6)); } | ||
| 41 | static inline bool KEY_STATE(void) { return (PIND & (1<<7)); } | ||
| 42 | static inline void KEY_PREV_ON(void) { (PORTB |= (1<<7)); } | ||
| 43 | static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); } | ||
| 44 | #ifdef HHKB_POWER_SAVING | ||
| 45 | static inline void KEY_POWER_ON(void) { | ||
| 46 | DDRB = 0xFF; PORTB = 0x40; // change pins output | ||
| 47 | DDRD |= (1<<4); PORTD |= (1<<4); // MOS FET switch on | ||
| 48 | /* Without this wait you will miss or get false key events. */ | ||
| 49 | _delay_ms(5); // wait for powering up | ||
| 50 | } | ||
| 51 | static inline void KEY_POWER_OFF(void) { | ||
| 52 | /* input with pull-up consumes less than without it when pin is open. */ | ||
| 53 | DDRB = 0x00; PORTB = 0xFF; // change pins input with pull-up | ||
| 54 | DDRD |= (1<<4); PORTD &= ~(1<<4); // MOS FET switch off | ||
| 55 | } | ||
| 56 | static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); } | ||
| 57 | #else | ||
| 58 | static inline void KEY_POWER_ON(void) {} | ||
| 59 | static inline void KEY_POWER_OFF(void) {} | ||
| 60 | static inline bool KEY_POWER_STATE(void) { return true; } | ||
| 61 | #endif | ||
| 62 | static inline void KEY_INIT(void) | ||
| 63 | { | ||
| 64 | /* row,col,prev: output */ | ||
| 65 | DDRB = 0xFF; | ||
| 66 | PORTB = 0x40; // unable | ||
| 67 | /* key: input with pull-up */ | ||
| 68 | DDRD &= ~0x80; | ||
| 69 | PORTD |= 0x80; | ||
| 70 | #ifdef HHKB_JP | ||
| 71 | /* row extention for HHKB JP */ | ||
| 72 | DDRC |= (1<<6|1<<7); | ||
| 73 | PORTC |= (1<<6|1<<7); | ||
| 74 | #endif | ||
| 75 | KEY_UNABLE(); | ||
| 76 | KEY_PREV_OFF(); | ||
| 77 | |||
| 78 | KEY_POWER_OFF(); | ||
| 79 | } | ||
| 80 | static inline void KEY_SELECT(uint8_t ROW, uint8_t COL) | ||
| 81 | { | ||
| 82 | PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07); | ||
| 83 | #ifdef HHKB_JP | ||
| 84 | if ((ROW) & 0x08) PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<6); | ||
| 85 | else PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<7); | ||
| 86 | #endif | ||
| 87 | } | ||
| 88 | |||
| 89 | |||
| 90 | #elif defined(__AVR_AT90USB1286__) | ||
| 91 | /* | ||
| 92 | * For Teensy++(AT90USB1286) | ||
| 93 | * | ||
| 94 | * HHKB pro HHKB pro2 | ||
| 95 | * row: PB0-2 (6-8) (5-7) | ||
| 96 | * col: PB3-5,6 (9-12) (8-11) | ||
| 97 | * key: PE6(pull-uped) (4) (3) | ||
| 98 | * prev: PE7 (5) (4) | ||
| 99 | * | ||
| 100 | * TODO: convert into 'staitc inline' function | ||
| 101 | */ | ||
| 102 | #define KEY_INIT() do { \ | ||
| 103 | DDRB |= 0x7F; \ | ||
| 104 | DDRE |= (1<<7); \ | ||
| 105 | DDRE &= ~(1<<6); \ | ||
| 106 | PORTE |= (1<<6); \ | ||
| 107 | } while (0) | ||
| 108 | #define KEY_SELECT(ROW, COL) (PORTB = (PORTB & 0xC0) | \ | ||
| 109 | (((COL) & 0x07)<<3) | \ | ||
| 110 | ((ROW) & 0x07)) | ||
| 111 | #define KEY_ENABLE() (PORTB &= ~(1<<6)) | ||
| 112 | #define KEY_UNABLE() (PORTB |= (1<<6)) | ||
| 113 | #define KEY_STATE() (PINE & (1<<6)) | ||
| 114 | #define KEY_PREV_ON() (PORTE |= (1<<7)) | ||
| 115 | #define KEY_PREV_OFF() (PORTE &= ~(1<<7)) | ||
| 116 | #define KEY_POWER_ON() | ||
| 117 | #define KEY_POWER_OFF() | ||
| 118 | |||
| 119 | |||
| 120 | #else | ||
| 121 | # error "define code for matrix scan" | ||
| 122 | #endif | ||
| 123 | |||
| 124 | |||
| 125 | #if 0 | ||
| 126 | // For ATMega328P with V-USB | ||
| 127 | // | ||
| 128 | // #elif defined(__AVR_ATmega328P__) | ||
| 129 | // Ports for V-USB | ||
| 130 | // key: PB0(pull-uped) | ||
| 131 | // prev: PB1 | ||
| 132 | // row: PB2-4 | ||
| 133 | // col: PC0-2,3 | ||
| 134 | // power: PB5(Low:on/Hi-z:off) | ||
| 135 | #define KEY_INIT() do { \ | ||
| 136 | DDRB |= 0x3E; \ | ||
| 137 | DDRB &= ~(1<<0); \ | ||
| 138 | PORTB |= 1<<0; \ | ||
| 139 | DDRC |= 0x0F; \ | ||
| 140 | KEY_UNABLE(); \ | ||
| 141 | KEY_PREV_OFF(); \ | ||
| 142 | } while (0) | ||
| 143 | #define KEY_SELECT(ROW, COL) do { \ | ||
| 144 | PORTB = (PORTB & 0xE3) | ((ROW) & 0x07)<<2; \ | ||
| 145 | PORTC = (PORTC & 0xF8) | ((COL) & 0x07); \ | ||
| 146 | } while (0) | ||
| 147 | #define KEY_ENABLE() (PORTC &= ~(1<<3)) | ||
| 148 | #define KEY_UNABLE() (PORTC |= (1<<3)) | ||
| 149 | #define KEY_STATE() (PINB & (1<<0)) | ||
| 150 | #define KEY_PREV_ON() (PORTB |= (1<<1)) | ||
| 151 | #define KEY_PREV_OFF() (PORTB &= ~(1<<1)) | ||
| 152 | // Power supply switching | ||
| 153 | #define KEY_POWER_ON() do { \ | ||
| 154 | KEY_INIT(); \ | ||
| 155 | PORTB &= ~(1<<5); \ | ||
| 156 | _delay_ms(1); \ | ||
| 157 | } while (0) | ||
| 158 | #define KEY_POWER_OFF() do { \ | ||
| 159 | DDRB &= ~0x3F; \ | ||
| 160 | PORTB &= ~0x3F; \ | ||
| 161 | DDRC &= ~0x0F; \ | ||
| 162 | PORTC &= ~0x0F; \ | ||
| 163 | } while (0) | ||
| 164 | #endif | ||
| 165 | |||
| 166 | #endif | ||
diff --git a/keyboard/hhkb_rn42/keymap_common.c b/keyboard/hhkb_rn42/keymap_common.c deleted file mode 100644 index e938fb627..000000000 --- a/keyboard/hhkb_rn42/keymap_common.c +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 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, keypos_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_rn42/keymap_common.h b/keyboard/hhkb_rn42/keymap_common.h deleted file mode 100644 index 3622665f3..000000000 --- a/keyboard/hhkb_rn42/keymap_common.h +++ /dev/null | |||
| @@ -1,84 +0,0 @@ | |||
| 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 | |||
| 58 | #define KEYMAP_JP( \ | ||
| 59 | K02, K32, K62, K22, K12, K52, K72, KA2, K92, K82, KB2, KE2, KF2, KD2, KC2, \ | ||
| 60 | K03, K63, K23, K13, K53, K73, KA3, K93, K83, KB3, KE3, KF3, KD3, \ | ||
| 61 | K06, K66, K26, K16, K56, K76, KA6, K96, K86, KB6, KE6, KF6, KD6, KC6, \ | ||
| 62 | K05, K65, K25, K15, K55, K75, KA5, K95, K85, KB5, KE5, KF5, KD5, KC5, \ | ||
| 63 | K04, K34, K64, K24, K14, K74, K94, K84, KB4, KE4, KF4, KD4, KC4 \ | ||
| 64 | ) \ | ||
| 65 | { \ | ||
| 66 | { KC_NO, KC_NO, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_NO }, \ | ||
| 67 | { KC_NO, KC_NO, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO }, \ | ||
| 68 | { KC_NO, KC_NO, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO }, \ | ||
| 69 | { KC_NO, KC_NO, KC_##K32, KC_NO, KC_##K34, KC_NO, KC_NO, KC_NO }, \ | ||
| 70 | { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ | ||
| 71 | { KC_NO, KC_NO, KC_##K52, KC_##K53, KC_NO, KC_##K55, KC_##K56, KC_NO }, \ | ||
| 72 | { KC_NO, KC_NO, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO }, \ | ||
| 73 | { KC_NO, KC_NO, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO }, \ | ||
| 74 | { KC_NO, KC_NO, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO }, \ | ||
| 75 | { KC_NO, KC_NO, KC_##K92, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO }, \ | ||
| 76 | { KC_NO, KC_NO, KC_##KA2, KC_##KA3, KC_NO, KC_##KA5, KC_##KA6, KC_NO }, \ | ||
| 77 | { KC_NO, KC_NO, KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_NO }, \ | ||
| 78 | { KC_NO, KC_NO, KC_##KC2, KC_NO, KC_##KC4, KC_##KC5, KC_##KC6, KC_NO }, \ | ||
| 79 | { KC_NO, KC_NO, KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_##KD6, KC_NO }, \ | ||
| 80 | { KC_NO, KC_NO, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_NO }, \ | ||
| 81 | { KC_NO, KC_NO, KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_NO } \ | ||
| 82 | } | ||
| 83 | |||
| 84 | #endif | ||
diff --git a/keyboard/hhkb_rn42/keymap_hasu.c b/keyboard/hhkb_rn42/keymap_hasu.c deleted file mode 100644 index 433f9cb27..000000000 --- a/keyboard/hhkb_rn42/keymap_hasu.c +++ /dev/null | |||
| @@ -1,282 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Hasu: my personal keymap | ||
| 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|Fn3| '|Fn6 | | ||
| 19 | * |-----------------------------------------------------------| | ||
| 20 | * |Fn7 | Z| X| C| V| B| N| M| ,| .|Fn2|Shift |Fn1| | ||
| 21 | * `-----------------------------------------------------------' | ||
| 22 | * |Gui|Alt | Fn4 |Fn5 |Gui| | ||
| 23 | * `-------------------------------------------' | ||
| 24 | */ | ||
| 25 | [0] = \ | ||
| 26 | KEYMAP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, BSLS,GRV, \ | ||
| 27 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC,BSPC, \ | ||
| 28 | LCTL,A, S, D, F, G, H, J, K, L, FN3, QUOT,FN6, \ | ||
| 29 | FN7, Z, X, C, V, B, N, M, COMM,DOT, FN2, RSFT,FN1, \ | ||
| 30 | LGUI,LALT, FN4, FN5, RGUI), | ||
| 31 | |||
| 32 | /* Layer 1: HHKB mode[HHKB Fn] | ||
| 33 | * ,-----------------------------------------------------------. | ||
| 34 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 35 | * |-----------------------------------------------------------| | ||
| 36 | * |Caps | | | | | | | |Psc|Slk|Pus|Up | |Backs| | ||
| 37 | * |-----------------------------------------------------------| | ||
| 38 | * |Contro|VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig|Enter | | ||
| 39 | * |-----------------------------------------------------------| | ||
| 40 | * |Shift | | | | | | +| -|End|PgD|Dow|Shift | | | ||
| 41 | * `-----------------------------------------------------------' | ||
| 42 | * |Gui|Alt | Space |Alt |Gui| | ||
| 43 | * `-------------------------------------------' | ||
| 44 | */ | ||
| 45 | [1] = \ | ||
| 46 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 47 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,PAUS, UP, NO, BSPC, \ | ||
| 48 | LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ | ||
| 49 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \ | ||
| 50 | LGUI,LALT, TRNS, RALT,RGUI), | ||
| 51 | |||
| 52 | /* Layer 2: Vi mode[Slash] | ||
| 53 | * ,-----------------------------------------------------------. | ||
| 54 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 55 | * |-----------------------------------------------------------| | ||
| 56 | * |Tab |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd| | | |Backs| | ||
| 57 | * |-----------------------------------------------------------| | ||
| 58 | * |Contro| |Lef|Dow|Rig| |Lef|Dow|Up |Rig| | |Return | | ||
| 59 | * |-----------------------------------------------------------| | ||
| 60 | * |Shift | | | | | |Hom|PgD|PgUlEnd|Fn0|Shift | | | ||
| 61 | * `-----------------------------------------------------------' | ||
| 62 | * |Gui|Alt | Space |Alt |Gui| | ||
| 63 | * `-------------------------------------------' | ||
| 64 | */ | ||
| 65 | [2] = \ | ||
| 66 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 67 | TAB, HOME,PGDN,UP, PGUP,END, HOME,PGDN,PGUP,END, NO, NO, NO, BSPC, \ | ||
| 68 | LCTL,NO, LEFT,DOWN,RGHT,NO, LEFT,DOWN,UP, RGHT,NO, NO, ENT, \ | ||
| 69 | LSFT,NO, NO, NO, NO, NO, HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \ | ||
| 70 | LGUI,LALT, SPC, RALT,RGUI), | ||
| 71 | |||
| 72 | /* Layer 3: Mouse mode(IJKL)[Semicolon] | ||
| 73 | * ,-----------------------------------------------------------. | ||
| 74 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 75 | * |-----------------------------------------------------------| | ||
| 76 | * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| | ||
| 77 | * |-----------------------------------------------------------| | ||
| 78 | * |Contro| | | | | |Mb2|McL|McD|McR|Fn | |Return | | ||
| 79 | * |-----------------------------------------------------------| | ||
| 80 | * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | | ||
| 81 | * `-----------------------------------------------------------' | ||
| 82 | * |Gui |Alt | Mb1 |Fn |Fn | | ||
| 83 | * `--------------------------------------------' | ||
| 84 | * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 85 | */ | ||
| 86 | [3] = \ | ||
| 87 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 88 | FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ | ||
| 89 | LCTL,ACL0,ACL1,ACL2,ACL2,NO, NO, MS_L,MS_D,MS_R,FN3, NO, ENT, \ | ||
| 90 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ | ||
| 91 | LGUI,LALT, BTN1, TRNS,TRNS), | ||
| 92 | |||
| 93 | /* Layer 4: Mouse mode(IJKL)[Space] | ||
| 94 | * ,-----------------------------------------------------------. | ||
| 95 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 96 | * |-----------------------------------------------------------| | ||
| 97 | * |Tab | | | | | |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T| | ||
| 98 | * |-----------------------------------------------------------| | ||
| 99 | * |Contro| | | | | |Mb2|McL|McD|McR|Mb1| |Return | | ||
| 100 | * |-----------------------------------------------------------| | ||
| 101 | * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | | ||
| 102 | * `-----------------------------------------------------------' | ||
| 103 | * |Gui |Alt | Mb1 |Fn |Fn | | ||
| 104 | * `--------------------------------------------' | ||
| 105 | * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 106 | */ | ||
| 107 | [4] = \ | ||
| 108 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 109 | FN8, NO, NO, NO, NO, NO, NO, WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \ | ||
| 110 | LCTL,VOLD,VOLU,MUTE,NO, NO, NO, MS_L,MS_D,MS_R,BTN1,NO, ENT, \ | ||
| 111 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,TRNS, \ | ||
| 112 | LGUI,LALT, TRNS, TRNS,TRNS), | ||
| 113 | |||
| 114 | #if 0 | ||
| 115 | /* Layer 3: Mouse mode(HJKL)[Semicolon] | ||
| 116 | * ,-----------------------------------------------------------. | ||
| 117 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 118 | * |-----------------------------------------------------------| | ||
| 119 | * |Tab | | | | | |MwL|MwD|MwU|MwR| | | |Backs| | ||
| 120 | * |-----------------------------------------------------------| | ||
| 121 | * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return | | ||
| 122 | * |-----------------------------------------------------------| | ||
| 123 | * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | | ||
| 124 | * `-----------------------------------------------------------' | ||
| 125 | * |Gui |Alt | Mb1 |Alt |Fn0| | ||
| 126 | * `--------------------------------------------' | ||
| 127 | * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 128 | */ | ||
| 129 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 130 | TAB, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, NO, NO, BSPC, \ | ||
| 131 | LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \ | ||
| 132 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \ | ||
| 133 | LGUI,LALT, BTN1, RALT,TRNS), | ||
| 134 | |||
| 135 | /* Layer4: Mouse mode(HJKL)[Space] | ||
| 136 | * ,-----------------------------------------------------------. | ||
| 137 | * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 138 | * |-----------------------------------------------------------| | ||
| 139 | * |Tab | | | | | |MwL|MwD|MwU|MwR| |Wbk|Wfr|Alt-T| | ||
| 140 | * |-----------------------------------------------------------| | ||
| 141 | * |Contro| | | | | |McL|McD|McU|McR|Fn0| |Return | | ||
| 142 | * |-----------------------------------------------------------| | ||
| 143 | * |Shift | | | | |Mb3|Mb2|Mb1|Mb4|Mb5| |Shift | | | ||
| 144 | * `-----------------------------------------------------------' | ||
| 145 | * |Gui |Alt | Fn0 |Alt |Fn0| | ||
| 146 | * `--------------------------------------------' | ||
| 147 | * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel | ||
| 148 | */ | ||
| 149 | KEYMAP(GRV, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 150 | FN8, NO, NO, NO, NO, NO, NO, WH_D,WH_U,RGHT,NO, FN9, FN10,FN8, \ | ||
| 151 | LCTL,NO, ACL0,ACL1,ACL2,NO, MS_L,MS_D,MS_U,MS_R,BTN1,NO, ENT, \ | ||
| 152 | LSFT,NO, NO, NO, NO, BTN3,BTN2,BTN1,FN9, FN10,NO, RSFT,NO, \ | ||
| 153 | LGUI,LALT, TRNS, RALT,RGUI), | ||
| 154 | #endif | ||
| 155 | #if 0 | ||
| 156 | /* Layer x: Matias half-qwerty keyboard style[Space] | ||
| 157 | * ,-----------------------------------------------------------. | ||
| 158 | * | -| 0| 9| 8| 7| 6| 5| 4| 3| 2| 1| | | |Esc| | ||
| 159 | * |-----------------------------------------------------------| | ||
| 160 | * |Backs| P| O| I| U| Y| T| R| E| W| Q| | |Tab | | ||
| 161 | * |-----------------------------------------------------------| | ||
| 162 | * |Contro| ;| L| K| J| H| G| F| D| S| A|Con|Control | | ||
| 163 | * |-----------------------------------------------------------| | ||
| 164 | * |Shift | /| .| ,| M| N| B| V| C| X| Z|Shift | | | ||
| 165 | * `-----------------------------------------------------------' | ||
| 166 | * |Gui |Alt | Fn0 |Alt |Gui| | ||
| 167 | * `--------------------------------------------' | ||
| 168 | */ | ||
| 169 | KEYMAP(MINS,0, 9, 8, 7, 6, 5, 4, 3, 2, 1, NO, NO, NO, ESC, \ | ||
| 170 | BSPC,P, O, I, U, Y, T, R, E, W, Q, NO, NO, TAB, \ | ||
| 171 | LCTL,SCLN,L, K, J, H, G, F, D, S, A, RCTL,RCTL, \ | ||
| 172 | LSFT,SLSH,DOT, COMM,M, N, B, V, C, X, Z, RSFT,NO, \ | ||
| 173 | LGUI,LALT, TRNS, RALT,RGUI), | ||
| 174 | #endif | ||
| 175 | }; | ||
| 176 | |||
| 177 | |||
| 178 | |||
| 179 | /* id for user defined functions */ | ||
| 180 | enum function_id { | ||
| 181 | LSHIFT_LPAREN, | ||
| 182 | }; | ||
| 183 | |||
| 184 | enum macro_id { | ||
| 185 | HELLO, | ||
| 186 | VOLUP, | ||
| 187 | ALT_TAB, | ||
| 188 | }; | ||
| 189 | |||
| 190 | |||
| 191 | /* | ||
| 192 | * Fn action definition | ||
| 193 | */ | ||
| 194 | #ifdef KEYMAP_SECTION_ENABLE | ||
| 195 | const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { | ||
| 196 | #else | ||
| 197 | const uint16_t fn_actions[] PROGMEM = { | ||
| 198 | #endif | ||
| 199 | [0] = ACTION_DEFAULT_LAYER_SET(0), // Default layer(not used) | ||
| 200 | [1] = ACTION_LAYER_TAP_TOGGLE(1), // HHKB layer(toggle with 5 taps) | ||
| 201 | [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH), // Cursor layer with Slash* | ||
| 202 | [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN), // Mousekey layer with Semicolon* | ||
| 203 | [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC), // Mousekey layer with Space | ||
| 204 | [5] = ACTION_LAYER_MOMENTARY(4), // Mousekey layer(IJKL) | ||
| 205 | [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT), // RControl with tap Enter | ||
| 206 | [7] = ACTION_MODS_ONESHOT(MOD_LSFT), // Oneshot Shift | ||
| 207 | [8] = ACTION_MACRO(ALT_TAB), // Application switching | ||
| 208 | [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT), | ||
| 209 | [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT), | ||
| 210 | |||
| 211 | // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC), // LControl with tap Backspace | ||
| 212 | // [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC), // LControl with tap Esc | ||
| 213 | // [x] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN), // Function: LShift with tap '(' | ||
| 214 | // [x] = ACTION_MACRO(HELLO), // Macro: say hello | ||
| 215 | // [x] = ACTION_MACRO(VOLUP), // Macro: media key | ||
| 216 | }; | ||
| 217 | |||
| 218 | |||
| 219 | /* | ||
| 220 | * Macro definition | ||
| 221 | */ | ||
| 222 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 223 | { | ||
| 224 | switch (id) { | ||
| 225 | case HELLO: | ||
| 226 | return (record->event.pressed ? | ||
| 227 | MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) : | ||
| 228 | MACRO_NONE ); | ||
| 229 | case VOLUP: | ||
| 230 | return (record->event.pressed ? | ||
| 231 | MACRO( D(VOLU), U(VOLU), END ) : | ||
| 232 | MACRO_NONE ); | ||
| 233 | case ALT_TAB: | ||
| 234 | return (record->event.pressed ? | ||
| 235 | MACRO( D(LALT), D(TAB), END ) : | ||
| 236 | MACRO( U(TAB), END )); | ||
| 237 | } | ||
| 238 | return MACRO_NONE; | ||
| 239 | } | ||
| 240 | |||
| 241 | |||
| 242 | |||
| 243 | /* | ||
| 244 | * user defined action function | ||
| 245 | */ | ||
| 246 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) | ||
| 247 | { | ||
| 248 | if (record->event.pressed) dprint("P"); else dprint("R"); | ||
| 249 | dprintf("%d", record->tap.count); | ||
| 250 | if (record->tap.interrupted) dprint("i"); | ||
| 251 | dprint("\n"); | ||
| 252 | |||
| 253 | switch (id) { | ||
| 254 | case LSHIFT_LPAREN: | ||
| 255 | // Shift parentheses example: LShft + tap '(' | ||
| 256 | // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses | ||
| 257 | // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899 | ||
| 258 | if (record->event.pressed) { | ||
| 259 | if (record->tap.count > 0 && !record->tap.interrupted) { | ||
| 260 | if (record->tap.interrupted) { | ||
| 261 | dprint("tap interrupted\n"); | ||
| 262 | register_mods(MOD_BIT(KC_LSHIFT)); | ||
| 263 | } | ||
| 264 | } else { | ||
| 265 | register_mods(MOD_BIT(KC_LSHIFT)); | ||
| 266 | } | ||
| 267 | } else { | ||
| 268 | if (record->tap.count > 0 && !(record->tap.interrupted)) { | ||
| 269 | add_weak_mods(MOD_BIT(KC_LSHIFT)); | ||
| 270 | send_keyboard_report(); | ||
| 271 | register_code(KC_9); | ||
| 272 | unregister_code(KC_9); | ||
| 273 | del_weak_mods(MOD_BIT(KC_LSHIFT)); | ||
| 274 | send_keyboard_report(); | ||
| 275 | record->tap.count = 0; // ad hoc: cancel tap | ||
| 276 | } else { | ||
| 277 | unregister_mods(MOD_BIT(KC_LSHIFT)); | ||
| 278 | } | ||
| 279 | } | ||
| 280 | break; | ||
| 281 | } | ||
| 282 | } | ||
diff --git a/keyboard/hhkb_rn42/keymap_jp.c b/keyboard/hhkb_rn42/keymap_jp.c deleted file mode 100644 index 48d0ee70b..000000000 --- a/keyboard/hhkb_rn42/keymap_jp.c +++ /dev/null | |||
| @@ -1,50 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * HHKB JP 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 | KEYMAP_JP(ESC, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS,EQL, JYEN,BSPC, \ | ||
| 14 | TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC,RBRC, \ | ||
| 15 | LCTL,A, S, D, F, G, H, J, K, L, SCLN,QUOT,BSLS,ENT, \ | ||
| 16 | LSFT,Z, X, C, V, B, N, M, COMM,DOT, SLSH,RO, UP, RSFT, \ | ||
| 17 | FN0, ZKHK,LGUI,LALT,MHEN, SPC, HENK,KANA,RALT,FN0, LEFT,DOWN,RGHT), | ||
| 18 | |||
| 19 | /* Layer 1: HHKB mode (HHKB Fn) | ||
| 20 | * ,-----------------------------------------------------------. | ||
| 21 | * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del| | ||
| 22 | * |-----------------------------------------------------------| | ||
| 23 | * |Caps | | | | | | | |Psc|Slk|Pus|Up | | | | ||
| 24 | * |------------------------------------------------------` | | ||
| 25 | * | |VoD|VoU|Mut| | | *| /|Hom|PgU|Lef|Rig| | | | ||
| 26 | * |-----------------------------------------------------------| | ||
| 27 | * | | | | | | | +| -|End|PgD|Dow| | | | | ||
| 28 | * |-----------------------------------------------------------| | ||
| 29 | * | || | | | | | | | | || | | | | ||
| 30 | * `-----------------------------------------------------------' | ||
| 31 | */ | ||
| 32 | KEYMAP_JP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, INS, DEL, \ | ||
| 33 | CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, \ | ||
| 34 | TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS,PENT, \ | ||
| 35 | TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS,TRNS, \ | ||
| 36 | TRNS,TRNS,TRNS,TRNS,TRNS, TRNS, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS), | ||
| 37 | }; | ||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | /* | ||
| 42 | * Fn action definition | ||
| 43 | */ | ||
| 44 | #ifdef KEYMAP_SECTION_ENABLE | ||
| 45 | const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { | ||
| 46 | #else | ||
| 47 | const uint16_t fn_actions[] PROGMEM = { | ||
| 48 | #endif | ||
| 49 | [0] = ACTION_LAYER_MOMENTARY(1), | ||
| 50 | }; | ||
diff --git a/keyboard/hhkb_rn42/led.c b/keyboard/hhkb_rn42/led.c deleted file mode 100644 index 8a08fe27f..000000000 --- a/keyboard/hhkb_rn42/led.c +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 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 | #include <avr/io.h> | ||
| 19 | #include "stdint.h" | ||
| 20 | #include "led.h" | ||
| 21 | |||
| 22 | |||
| 23 | /* HHKB has no LEDs */ | ||
| 24 | void led_set(uint8_t usb_led) | ||
| 25 | { | ||
| 26 | if (usb_led & (1<<USB_LED_CAPS_LOCK)) { | ||
| 27 | DDRD |= (1<<6); | ||
| 28 | PORTD |= (1<<6); | ||
| 29 | } else { | ||
| 30 | DDRD |= (1<<6); | ||
| 31 | PORTD &= ~(1<<6); | ||
| 32 | } | ||
| 33 | } | ||
diff --git a/keyboard/hhkb_rn42/matrix.c b/keyboard/hhkb_rn42/matrix.c deleted file mode 100644 index fb9699794..000000000 --- a/keyboard/hhkb_rn42/matrix.c +++ /dev/null | |||
| @@ -1,190 +0,0 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2011 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 | /* | ||
| 19 | * scan matrix | ||
| 20 | */ | ||
| 21 | #include <stdint.h> | ||
| 22 | #include <stdbool.h> | ||
| 23 | #include <util/delay.h> | ||
| 24 | #include "print.h" | ||
| 25 | #include "debug.h" | ||
| 26 | #include "util.h" | ||
| 27 | #include "timer.h" | ||
| 28 | #include "matrix.h" | ||
| 29 | #include "hhkb_avr.h" | ||
| 30 | #include <avr/wdt.h> | ||
| 31 | #include "suspend.h" | ||
| 32 | #include "lufa.h" | ||
| 33 | |||
| 34 | |||
| 35 | // matrix power saving | ||
| 36 | #define MATRIX_POWER_SAVE 10000 | ||
| 37 | static uint32_t matrix_last_modified = 0; | ||
| 38 | |||
| 39 | // matrix state buffer(1:on, 0:off) | ||
| 40 | static matrix_row_t *matrix; | ||
| 41 | static matrix_row_t *matrix_prev; | ||
| 42 | static matrix_row_t _matrix0[MATRIX_ROWS]; | ||
| 43 | static matrix_row_t _matrix1[MATRIX_ROWS]; | ||
| 44 | |||
| 45 | |||
| 46 | inline | ||
| 47 | uint8_t matrix_rows(void) | ||
| 48 | { | ||
| 49 | return MATRIX_ROWS; | ||
| 50 | } | ||
| 51 | |||
| 52 | inline | ||
| 53 | uint8_t matrix_cols(void) | ||
| 54 | { | ||
| 55 | return MATRIX_COLS; | ||
| 56 | } | ||
| 57 | |||
| 58 | void matrix_init(void) | ||
| 59 | { | ||
| 60 | #ifdef DEBUG | ||
| 61 | debug_enable = true; | ||
| 62 | debug_keyboard = true; | ||
| 63 | #endif | ||
| 64 | |||
| 65 | KEY_INIT(); | ||
| 66 | |||
| 67 | // initialize matrix state: all keys off | ||
| 68 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; | ||
| 69 | for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; | ||
| 70 | matrix = _matrix0; | ||
| 71 | matrix_prev = _matrix1; | ||
| 72 | } | ||
| 73 | |||
| 74 | uint8_t matrix_scan(void) | ||
| 75 | { | ||
| 76 | uint8_t *tmp; | ||
| 77 | |||
| 78 | tmp = matrix_prev; | ||
| 79 | matrix_prev = matrix; | ||
| 80 | matrix = tmp; | ||
| 81 | |||
| 82 | // power on | ||
| 83 | if (!KEY_POWER_STATE()) KEY_POWER_ON(); | ||
| 84 | for (uint8_t row = 0; row < MATRIX_ROWS; row++) { | ||
| 85 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | ||
| 86 | KEY_SELECT(row, col); | ||
| 87 | _delay_us(5); | ||
| 88 | |||
| 89 | // Not sure this is needed. This just emulates HHKB controller's behaviour. | ||
| 90 | if (matrix_prev[row] & (1<<col)) { | ||
| 91 | KEY_PREV_ON(); | ||
| 92 | } | ||
| 93 | _delay_us(10); | ||
| 94 | |||
| 95 | // NOTE: KEY_STATE is valid only in 20us after KEY_ENABLE. | ||
| 96 | // If V-USB interrupts in this section we could lose 40us or so | ||
| 97 | // and would read invalid value from KEY_STATE. | ||
| 98 | uint8_t last = TIMER_RAW; | ||
| 99 | |||
| 100 | KEY_ENABLE(); | ||
| 101 | |||
| 102 | // Wait for KEY_STATE outputs its value. | ||
| 103 | // 1us was ok on one HHKB, but not worked on another. | ||
| 104 | // no wait doesn't work on Teensy++ with pro(1us works) | ||
| 105 | // no wait does work on tmk PCB(8MHz) with pro2 | ||
| 106 | // 1us wait does work on both of above | ||
| 107 | // 1us wait doesn't work on tmk(16MHz) | ||
| 108 | // 5us wait does work on tmk(16MHz) | ||
| 109 | // 5us wait does work on tmk(16MHz/2) | ||
| 110 | // 5us wait does work on tmk(8MHz) | ||
| 111 | // 10us wait does work on Teensy++ with pro | ||
| 112 | // 10us wait does work on 328p+iwrap with pro | ||
| 113 | // 10us wait doesn't work on tmk PCB(8MHz) with pro2(very lagged scan) | ||
| 114 | _delay_us(5); | ||
| 115 | |||
| 116 | if (KEY_STATE()) { | ||
| 117 | matrix[row] &= ~(1<<col); | ||
| 118 | } else { | ||
| 119 | matrix[row] |= (1<<col); | ||
| 120 | } | ||
| 121 | |||
| 122 | // Ignore if this code region execution time elapses more than 20us. | ||
| 123 | // MEMO: 20[us] * (TIMER_RAW_FREQ / 1000000)[count per us] | ||
| 124 | // MEMO: then change above using this rule: a/(b/c) = a*1/(b/c) = a*(c/b) | ||
| 125 | if (TIMER_DIFF_RAW(TIMER_RAW, last) > 20/(1000000/TIMER_RAW_FREQ)) { | ||
| 126 | matrix[row] = matrix_prev[row]; | ||
| 127 | } | ||
| 128 | |||
| 129 | _delay_us(5); | ||
| 130 | KEY_PREV_OFF(); | ||
| 131 | KEY_UNABLE(); | ||
| 132 | |||
| 133 | // NOTE: KEY_STATE keep its state in 20us after KEY_ENABLE. | ||
| 134 | // This takes 25us or more to make sure KEY_STATE returns to idle state. | ||
| 135 | _delay_us(75); | ||
| 136 | } | ||
| 137 | if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32(); | ||
| 138 | } | ||
| 139 | // power off | ||
| 140 | if (KEY_POWER_STATE() && | ||
| 141 | (USB_DeviceState == DEVICE_STATE_Suspended || | ||
| 142 | USB_DeviceState == DEVICE_STATE_Unattached ) && | ||
| 143 | timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) { | ||
| 144 | KEY_POWER_OFF(); | ||
| 145 | suspend_power_down(); | ||
| 146 | } | ||
| 147 | return 1; | ||
| 148 | } | ||
| 149 | |||
| 150 | bool matrix_is_modified(void) | ||
| 151 | { | ||
| 152 | for (uint8_t i = 0; i < MATRIX_ROWS; i++) { | ||
| 153 | if (matrix[i] != matrix_prev[i]) | ||
| 154 | return true; | ||
| 155 | } | ||
| 156 | return false; | ||
| 157 | } | ||
| 158 | |||
| 159 | inline | ||
| 160 | bool matrix_has_ghost(void) | ||
| 161 | { | ||
| 162 | return false; | ||
| 163 | } | ||
| 164 | |||
| 165 | inline | ||
| 166 | bool matrix_is_on(uint8_t row, uint8_t col) | ||
| 167 | { | ||
| 168 | return (matrix[row] & (1<<col)); | ||
| 169 | } | ||
| 170 | |||
| 171 | inline | ||
| 172 | matrix_row_t matrix_get_row(uint8_t row) | ||
| 173 | { | ||
| 174 | return matrix[row]; | ||
| 175 | } | ||
| 176 | |||
| 177 | void matrix_print(void) | ||
| 178 | { | ||
| 179 | print("\nr/c 01234567\n"); | ||
| 180 | for (uint8_t row = 0; row < matrix_rows(); row++) { | ||
| 181 | xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row))); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | void matrix_power_up(void) { | ||
| 186 | KEY_POWER_ON(); | ||
| 187 | } | ||
| 188 | void matrix_power_down(void) { | ||
| 189 | KEY_POWER_OFF(); | ||
| 190 | } | ||
