From 1a9cec9a0315c2b7dbe320a6c34646e264a99681 Mon Sep 17 00:00:00 2001
From: Oleg Kostyuk <cub.uanic@gmail.com>
Date: Thu, 20 Nov 2014 23:55:47 +0200
Subject: [PATCH 01/95] Documentation: small mistake

Originally reported as https://github.com/cub-uanic/tmk_keyboard/issues/10, all credits to @olivierpons
---
 doc/keycode.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/keycode.txt b/doc/keycode.txt
index 4137566924..760c726e3b 100644
--- a/doc/keycode.txt
+++ b/doc/keycode.txt
@@ -81,7 +81,7 @@ KC_F12                              45 Keyboard F12
 KC_PSCREEN          KC_PSCR         46 Keyboard PrintScreen1
 KC_SCKLOCK          KC_SLCK         47 Keyboard Scroll Lock11
 KC_PAUSE            KC_PAUS         48 Keyboard Pause1
-KC_INSERT           KC_INT          49 Keyboard Insert1
+KC_INSERT           KC_INS          49 Keyboard Insert1
 KC_HOME                             4A Keyboard Home1
 KC_PGUP                             4B Keyboard PageUp1
 KC_DELETE           KC_DELETE       4C Keyboard Delete Forward

From 60acd8996d559f5ab0458c2e1ea46ac9790d14b3 Mon Sep 17 00:00:00 2001
From: Brooks Swinnerton <bswinnerton@gmail.com>
Date: Sun, 30 Nov 2014 13:27:59 -0500
Subject: [PATCH 02/95] Fixing typo in console mode

---
 common/command.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/common/command.c b/common/command.c
index 971ef7f0af..380f2d8c08 100644
--- a/common/command.c
+++ b/common/command.c
@@ -302,7 +302,7 @@ static bool command_common(uint8_t code)
 #endif
             " " STR(BOOTLOADER_SIZE) "\n");
 
-            print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__) 
+            print("GCC: " STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__)
                   " AVR-LIBC: " __AVR_LIBC_VERSION_STRING__
                   " AVR_ARCH: avr" STR(__AVR_ARCH__) "\n");
             break;
@@ -541,12 +541,12 @@ static void mousekey_console_help(void)
     print("4:	select mk_time_to_max\n");
     print("5:	select mk_wheel_max_speed\n");
     print("6:	select mk_wheel_time_to_max\n");
-    print("p:	print prameters\n");
+    print("p:	print parameters\n");
     print("d:	set default values\n");
-    print("up:	increase prameters(+1)\n");
-    print("down:	decrease prameters(-1)\n");
-    print("pgup:	increase prameters(+10)\n");
-    print("pgdown:	decrease prameters(-10)\n");
+    print("up:	increase parameters(+1)\n");
+    print("down:	decrease parameters(-1)\n");
+    print("pgup:	increase parameters(+10)\n");
+    print("pgdown:	decrease parameters(-10)\n");
     print("\nspeed = delta * max_speed * (repeat / time_to_max)\n");
     print("where delta: cursor="); pdec(MOUSEKEY_MOVE_DELTA);
     print(", wheel="); pdec(MOUSEKEY_WHEEL_DELTA); print("\n");

From 9de992ba0be93a7fcc539ad0418c8ebfd3cd6281 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Wed, 10 Dec 2014 14:35:46 +0900
Subject: [PATCH 03/95] Change USB PID

---
 converter/usb_usb/Makefile |  2 +-
 converter/usb_usb/README   | 15 ++++++++++++---
 converter/usb_usb/config.h |  2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/converter/usb_usb/Makefile b/converter/usb_usb/Makefile
index 13f77ca9b7..4f983e7f68 100644
--- a/converter/usb_usb/Makefile
+++ b/converter/usb_usb/Makefile
@@ -120,7 +120,7 @@ VPATH += $(TOP_DIR)
 
 
 # program Leonardo
-PROGRAM_CMD = avrdude -p$(MCU) -cavr109 -P$(DEV) -b57600 -Uflash:w:$(TARGET).hex
+PROGRAM_CMD = avrdude -p$(MCU) -cavr109 -b57600 -Uflash:w:$(TARGET).hex -P$(DEV)
 
 
 
diff --git a/converter/usb_usb/README b/converter/usb_usb/README
index a489371107..985458ed01 100644
--- a/converter/usb_usb/README
+++ b/converter/usb_usb/README
@@ -19,13 +19,22 @@ Build firmware
     $ cd converter/usb_usb
     $ make
 
-You will get usb_usb.hex if you are lucky.
-Program your Leonardo with avrdude(or easy-going Arduino IDE):
+Program converter. Push reset button on Leonardo before run this command. Serial port name(COM17) depends your system. On Linux I got /dev/ttyACM0.
+
+    $ DEV=COM17 make program
+    or
+    $ avrdude -patmega32u4 -cavr109 -b57600 -Uflash:w:usb_usb.hex -PCOM17
 
-    $ avrdude -patmega32u4 -cavr109 -PCOM17 -b57600 -Uflash:w:usb_usb.hex
 
 
 Limitation
 ----------
 Only supports 'HID Boot protocol'.
 Not support keyboard LED yet.
+
+
+Resource
+--------
+http://deskthority.net/workshop-f7/is-remapping-a-usb-keyboard-using-teensy-possible-t2841.html
+https://github.com/felis/USB_Host_Shield_2.0
+https://github.com/arduino/Arduino/hardware/arduino/{cores,variants}
diff --git a/converter/usb_usb/config.h b/converter/usb_usb/config.h
index d614973f7e..bdc02868c8 100644
--- a/converter/usb_usb/config.h
+++ b/converter/usb_usb/config.h
@@ -20,7 +20,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 #define VENDOR_ID       0xFEED
-#define PRODUCT_ID      0xCAFE
+#define PRODUCT_ID      0x005B
 #define DEVICE_VER      0x0814
 #define MANUFACTURER    t.m.k.
 #define PRODUCT         USB to USB keyboard converter

From 0a9d9b8f9c6579a47fbb35973c747e13fb93e4b8 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Wed, 10 Dec 2014 15:10:25 +0900
Subject: [PATCH 04/95] Fix print init; print_set_sendchar in main

---
 converter/usb_usb/main.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp
index 20b7af66a2..4e655632e3 100644
--- a/converter/usb_usb/main.cpp
+++ b/converter/usb_usb/main.cpp
@@ -13,6 +13,7 @@
 #include "lufa.h"
 
 #include "timer.h"
+#include "sendchar.h"
 #include "debug.h"
 #include "keyboard.h"
 
@@ -39,6 +40,7 @@ static void LUFA_setup(void)
 
     // for Console_Task
     USB_Device_EnableSOFEvents();
+    print_set_sendchar(sendchar);
 }
 
 static void HID_setup()

From 4b69ed2280743b8e992232e6c59b46ae23906fb9 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Wed, 10 Dec 2014 15:20:32 +0900
Subject: [PATCH 05/95] Remove submodule USB_Host_Shield_2.0

---
 .gitmodules                          | 3 ---
 protocol/usb_hid/USB_Host_Shield_2.0 | 1 -
 2 files changed, 4 deletions(-)
 delete mode 160000 protocol/usb_hid/USB_Host_Shield_2.0

diff --git a/.gitmodules b/.gitmodules
index 17a20decb7..eef19ae080 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,6 +1,3 @@
-[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
-	path = protocol/usb_hid/USB_Host_Shield_2.0
-	url = git@github.com:tmk/USB_Host_Shield_2.0.git
 [submodule "protocol/lufa/LUFA-git"]
 	path = protocol/lufa/LUFA-git
 	url = https://github.com/abcminiuser/lufa.git
diff --git a/protocol/usb_hid/USB_Host_Shield_2.0 b/protocol/usb_hid/USB_Host_Shield_2.0
deleted file mode 160000
index 8bb790f83a..0000000000
--- a/protocol/usb_hid/USB_Host_Shield_2.0
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 8bb790f83af298b5f3e5516259c9d8ec27efe522

From 0a181c7eb58b79405ee91e7fca9f827678424872 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Wed, 10 Dec 2014 15:54:24 +0900
Subject: [PATCH 06/95] Add submodule legitimate USB_Host_Shield_2.0

---
 .gitmodules                          | 3 +++
 protocol/usb_hid/USB_Host_Shield_2.0 | 1 +
 2 files changed, 4 insertions(+)
 create mode 160000 protocol/usb_hid/USB_Host_Shield_2.0

diff --git a/.gitmodules b/.gitmodules
index eef19ae080..e21f449613 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
 [submodule "protocol/lufa/LUFA-git"]
 	path = protocol/lufa/LUFA-git
 	url = https://github.com/abcminiuser/lufa.git
+[submodule "protocol/usb_hid/USB_Host_Shield_2.0"]
+	path = protocol/usb_hid/USB_Host_Shield_2.0
+	url = https://github.com/felis/USB_Host_Shield_2.0.git
diff --git a/protocol/usb_hid/USB_Host_Shield_2.0 b/protocol/usb_hid/USB_Host_Shield_2.0
new file mode 160000
index 0000000000..2b4a56de3d
--- /dev/null
+++ b/protocol/usb_hid/USB_Host_Shield_2.0
@@ -0,0 +1 @@
+Subproject commit 2b4a56de3d090686f62d25ea34042759dc4352d6

From c9674d388d3b018cb1dfc0a34868642be53e913c Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Wed, 10 Dec 2014 23:52:38 +0900
Subject: [PATCH 07/95] Add USB Hub support

---
 converter/usb_usb/main.cpp | 10 ++++++++++
 protocol/usb_hid.mk        |  1 +
 2 files changed, 11 insertions(+)

diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp
index 4e655632e3..0b536b05aa 100644
--- a/converter/usb_usb/main.cpp
+++ b/converter/usb_usb/main.cpp
@@ -8,6 +8,7 @@
 #include "hid.h"
 #include "hidboot.h"
 #include "parser.h"
+#include "usbhub.h"
 
 // LUFA
 #include "lufa.h"
@@ -23,6 +24,15 @@
 static USB     usb_host;
 static HIDBoot<HID_PROTOCOL_KEYBOARD>    kbd(&usb_host);
 static KBDReportParser kbd_parser;
+static USBHub hub1(&usb_host);  // one hub is enough for HHKB pro2
+/* may be needed  for other device with more hub
+static USBHub hub2(&usb_host);
+static USBHub hub3(&usb_host);
+static USBHub hub4(&usb_host);
+static USBHub hub5(&usb_host);
+static USBHub hub6(&usb_host);
+static USBHub hub7(&usb_host);
+*/
 
 static void LUFA_setup(void)
 {
diff --git a/protocol/usb_hid.mk b/protocol/usb_hid.mk
index 6914dce809..8fda76c2e5 100644
--- a/protocol/usb_hid.mk
+++ b/protocol/usb_hid.mk
@@ -8,6 +8,7 @@ USB_HOST_SHIELD_DIR = $(USB_HID_DIR)/USB_Host_Shield_2.0
 USB_HOST_SHIELD_SRC = \
 	$(USB_HOST_SHIELD_DIR)/Usb.cpp \
 	$(USB_HOST_SHIELD_DIR)/hid.cpp \
+	$(USB_HOST_SHIELD_DIR)/usbhub.cpp \
 	$(USB_HOST_SHIELD_DIR)/parsetools.cpp \
 	$(USB_HOST_SHIELD_DIR)/message.cpp 
 

From 27795b6b191da88fbcbeefd21dd0f9eddacedcf9 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Thu, 11 Dec 2014 00:27:37 +0900
Subject: [PATCH 08/95] Change debug print config

---
 converter/usb_usb/main.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/converter/usb_usb/main.cpp b/converter/usb_usb/main.cpp
index 0b536b05aa..30fd3348a3 100644
--- a/converter/usb_usb/main.cpp
+++ b/converter/usb_usb/main.cpp
@@ -72,9 +72,11 @@ int main(void)
     LED_TX_ON;
 
     debug_enable = true;
+/*
     debug_matrix = true;
     debug_keyboard = true;
     debug_mouse = true;
+*/
 
     host_set_driver(&lufa_driver);
     keyboard_init();

From 30864ea5e48c15796cc2e3e2ba4a9b50322d82a4 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Thu, 11 Dec 2014 00:59:08 +0900
Subject: [PATCH 09/95] Update README

---
 converter/usb_usb/README | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/converter/usb_usb/README b/converter/usb_usb/README
index 985458ed01..69caabb278 100644
--- a/converter/usb_usb/README
+++ b/converter/usb_usb/README
@@ -33,8 +33,28 @@ Only supports 'HID Boot protocol'.
 Not support keyboard LED yet.
 
 
+
+Update
+------
+2014/12/11  Added Hub support(confirmed with HHKB pro2)
+
+
+
 Resource
 --------
-http://deskthority.net/workshop-f7/is-remapping-a-usb-keyboard-using-teensy-possible-t2841.html
-https://github.com/felis/USB_Host_Shield_2.0
-https://github.com/arduino/Arduino/hardware/arduino/{cores,variants}
+USB Host Sheild 2.0
+    https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino
+    https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini
+USB Host Sheild 2.0 source
+    https://github.com/felis/USB_Host_Shield_2.0
+Arduino USB Host Shield(with bootst converter)
+    http://arduino.cc/en/Main/ArduinoUSBHostShield
+Arduino source
+    https://github.com/arduino/Arduino/hardware/arduino/{cores,variants}
+Initial release of TMK USB-USB converter
+    https://geekhack.org/index.php?topic=33057.msg653549#msg653549
+    http://deskthority.net/workshop-f7/is-remapping-a-usb-keyboard-using-teensy-possible-t2841-30.html#p74854
+Arduino-based hardware keyboard remapper - Colemak forum
+    http://forum.colemak.com/viewtopic.php?id=1561
+Teensy + Host Shield
+    http://www.pjrc.com/teensy/td_libs_USBHostShield.html

From a0d6bb1818b90f341b2a5daaea3652fe19cd4184 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Thu, 11 Dec 2014 03:52:05 +0900
Subject: [PATCH 10/95] usb_usb: Add SpaceFn and hasu keymap

---
 converter/usb_usb/Makefile         |  10 +-
 converter/usb_usb/config.h         |   2 -
 converter/usb_usb/keymap.c         | 128 ++---------------------
 converter/usb_usb/keymap_common.c  |  31 ++++++
 converter/usb_usb/keymap_common.h  |  77 ++++++++++++++
 converter/usb_usb/keymap_hasu.c    | 158 +++++++++++++++++++++++++++++
 converter/usb_usb/keymap_spacefn.c |  61 +++++++++++
 7 files changed, 342 insertions(+), 125 deletions(-)
 create mode 100644 converter/usb_usb/keymap_common.c
 create mode 100644 converter/usb_usb/keymap_common.h
 create mode 100644 converter/usb_usb/keymap_hasu.c
 create mode 100644 converter/usb_usb/keymap_spacefn.c

diff --git a/converter/usb_usb/Makefile b/converter/usb_usb/Makefile
index 4f983e7f68..d6867bb002 100644
--- a/converter/usb_usb/Makefile
+++ b/converter/usb_usb/Makefile
@@ -99,16 +99,22 @@ CONSOLE_ENABLE = yes	# Console for debug
 #   Teensy halfKay   512
 #   Atmel DFU loader 4096
 #   LUFA bootloader  4096
-#OPT_DEFS += -DBOOTLOADER_SIZE=4096
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
 
 
 
 SRC =  \
-       keymap.c \
+       keymap_common.c \
        matrix.c \
        led.c \
        main.cpp
 
+ifdef KEYMAP
+    SRC := keymap_$(KEYMAP).c $(SRC)
+else
+    SRC := keymap.c $(SRC)
+endif
+
 CONFIG_H = config.h
 
 
diff --git a/converter/usb_usb/config.h b/converter/usb_usb/config.h
index bdc02868c8..c992456763 100644
--- a/converter/usb_usb/config.h
+++ b/converter/usb_usb/config.h
@@ -33,8 +33,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_ROWS 32
 #define MATRIX_COLS 8
 
-#define USE_LEGACY_KEYMAP
-
 /* key combination for command */
 #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) 
 
diff --git a/converter/usb_usb/keymap.c b/converter/usb_usb/keymap.c
index ff166fcf1f..c14a8aa553 100644
--- a/converter/usb_usb/keymap.c
+++ b/converter/usb_usb/keymap.c
@@ -15,62 +15,10 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include <avr/pgmspace.h>
-#include "keycode.h"
-#include "util.h"
-#include "keymap.h"
+#include "keymap_common.h"
 
 
-#define KEYMAP( \
-    K29,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45,     K46,K47,K48,                   \
-    K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K49,K4A,K4B,  K53,K54,K55,K56, \
-    K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30,K31, K4C,K4D,K4E,  K5F,K60,K61,     \
-    K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,    K28,               K5C,K5D,K5E,K57, \
-    KE1,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38,        KE5,     K52,      K59,K5A,K5B,     \
-    KE0,KE3,KE2,        K2C,                KE6,KE7,K65,KE4, K50,K51,K4F,  K62,    K63,K58  \
-) { \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, /* 00-07 */ \
-    { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, /* 08-0F */ \
-    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, /* 10-17 */ \
-    { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, /* 18-1F */ \
-    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, /* 20-27 */ \
-    { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, /* 28-2F */ \
-    { KC_##K30, KC_##K31, KC_NO,    KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, /* 30-37 */ \
-    { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, /* 38-3F */ \
-    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, /* 40-47 */ \
-    { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, /* 48-4F */ \
-    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, /* 50-57 */ \
-    { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, /* 58-5F */ \
-    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_NO,    KC_##K65, KC_NO,    KC_NO    }, /* 60-67 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 68-6F */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 70-77 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 78-7F */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 80-87 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 88-8F */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 90-97 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 98-9F */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* A0-A7 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* A8-AF */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* B0-B7 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* B8-BF */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* C0-C7 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* C8-CF */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* D0-D7 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* D8-DF */ \
-    { KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7 }, /* E0-E7 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* E8-EF */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* F0-F7 */ \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* F8-FF */ \
-}
-
-
-// Layers to switch by holding Fn key(0-7)
-static const uint8_t PROGMEM fn_layer[] =   { 5,       6,       5,       0,       0,       0,       0,       0     };
-
-// Codes to register by clicking Fn key(0-7)
-static const uint8_t PROGMEM fn_keycode[] = { KC_SCLN, KC_SLSH, KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO,   KC_NO };
-
-static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     /* 0: default
      * ,---.   ,---------------. ,---------------. ,---------------. ,-----------.     ,-----------.
      * |Esc|   |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|     |Pwr|Slp|Wak|
@@ -86,16 +34,14 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
      * |-----------------------------------------------------------| ,-----------. |-----------|Ent|
      * |Ctrl |Gui |Alt |         Space         |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| |      0|  .|   |
      * `-----------------------------------------------------------' `-----------' `---------------'
-     * ; = Fn0(to Layer 5)
-     * / = Fn1(to Layer 6)
      */
     KEYMAP(
     ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,
     ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
     TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,     DEL, END, PGDN,    P7,  P8,  P9,
-    FN2, A,   S,   D,   F,   G,   H,   J,   K,   L,   FN0, QUOT,     ENT,                         P4,  P5,  P6,  PPLS,
-    LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, FN1,           RSFT,          UP,           P1,  P2,  P3,
-    LCTL,LGUI,LALT,          SPC,                     RALT,FN2, FN2, GRV,      LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,                         P4,  P5,  P6,  PPLS,
+    LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT,          UP,           P1,  P2,  P3,
+    LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, GRV,      LEFT,DOWN,RGHT,    P0,       PDOT,PENT
     ),
 
     /* 1: plain Qwerty without layer switching
@@ -185,67 +131,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     LSFT,Z,   X,   M,   C,   V,   K,   L,   COMM,DOT, SLSH,          RSFT,          UP,           P1,  P2,  P3,
     LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
     ),
-
-    /* 5: Mouse keys
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
-     * |-----------------------------------------------------------|
-     * |Tab  |MwL|MwU|McU|WwU|WwR|MwL|MwD|MwU|MwR|   |   |   |    \|
-     * |-----------------------------------------------------------|
-     * |CapsLo|   |McL|McD|McR|   |McL|McD|McU|McR|Fn0|   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |VoD|VoU|Mut|Mb2|Mb3|Mb2|Mb1|VoD|VoU|Mut|Shift     |
-     * |-----------------------------------------------------------|
-     * |Ctrl |Gui |Alt |         Mb1           |Alt |Gui |Menu|Ctrl|
-     * `-----------------------------------------------------------'
-     * Mc = mouse cursor, Mw = mouse wheel, Mb = mouse button
-     * Vo = Volume, Mut = Mute
-     */
-    KEYMAP(
-    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,
-    GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F8,  F10, F11, F12, DEL,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
-    CAPS,NO,  NO,  NO,  NO,  NO,  WH_L,WH_D,WH_U,WH_R,PSCR,SLCK,PAUS,INS,      DEL, END, PGDN,    P7,  P8,  P9,
-    FN2, VOLD,VOLU,MUTE,NO,  NO,  MS_L,MS_D,MS_U,MS_R,FN0, NO,       ENT,                         P4,  P5,  P6,  PPLS,
-    LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,NO,  NO,  NO,            RSFT,          UP,           P1,  P2,  P3,
-    LCTL,LGUI,LALT,          BTN1,                    RALT,FN2, FN2, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
-    ),
-
-    /* 6: Cursor keys
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backspa|
-     * |-----------------------------------------------------------|
-     * |Tab  |Hom|PgU| Up|PgU|End|Hom|PgD|PgU|End|   |   |   |    \|
-     * |-----------------------------------------------------------|
-     * |CapsLo|   |Lef|Dow|Rig|   |Lef|Dow| Up|Rig|   |   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |   |Hom|PgD|PgU|End|Fn1|Shift     |
-     * |-----------------------------------------------------------|
-     * |Ctrl |Gui |Alt |         Space         |Alt |Gui |Menu|Ctrl|
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP(
-    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,PAUS,
-    GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F8,  F10, F11, F12, DEL,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
-    CAPS,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, NO,  NO,  NO,  INS,      DEL, END, PGDN,    P7,  P8,  P9,
-    LCTL,NO,  NO,  NO,  NO,  NO,  LEFT,DOWN,UP,  RGHT,NO,  NO,       ENT,                         P4,  P5,  P6,  PPLS,
-    LSFT,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, FN1,           RSFT,          UP,           P1,  P2,  P3,
-    LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
-    ),
 };
 
-
-
-uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
-{
-    return pgm_read_byte(&keymaps[(layer)][(row)][(col)]);
-}
-
-uint8_t keymap_fn_layer(uint8_t index)
-{
-    return pgm_read_byte(&fn_layer[index]);
-}
-
-uint8_t keymap_fn_keycode(uint8_t index)
-{
-    return pgm_read_byte(&fn_keycode[index]);
-}
+const uint16_t PROGMEM fn_actions[] = {
+};
diff --git a/converter/usb_usb/keymap_common.c b/converter/usb_usb/keymap_common.c
new file mode 100644
index 0000000000..8ab5ba923e
--- /dev/null
+++ b/converter/usb_usb/keymap_common.c
@@ -0,0 +1,31 @@
+/*
+Copyright 2014 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "keymap_common.h"
+#include "progmem.h"
+
+
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+    return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
+}
diff --git a/converter/usb_usb/keymap_common.h b/converter/usb_usb/keymap_common.h
new file mode 100644
index 0000000000..435d83fdc7
--- /dev/null
+++ b/converter/usb_usb/keymap_common.h
@@ -0,0 +1,77 @@
+/*
+Copyright 2014 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef KEYMAP_COMMON_H
+#define KEYMAP_COMMON_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "print.h"
+#include "debug.h"
+#include "keymap.h"
+
+
+extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+
+#define KEYMAP( \
+    K29,K3A,K3B,K3C,K3D,K3E,K3F,K40,K41,K42,K43,K44,K45,     K46,K47,K48,                   \
+    K35,K1E,K1F,K20,K21,K22,K23,K24,K25,K26,K27,K2D,K2E,K2A, K49,K4A,K4B,  K53,K54,K55,K56, \
+    K2B,K14,K1A,K08,K15,K17,K1C,K18,K0C,K12,K13,K2F,K30,K31, K4C,K4D,K4E,  K5F,K60,K61,     \
+    K39,K04,K16,K07,K09,K0A,K0B,K0D,K0E,K0F,K33,K34,    K28,               K5C,K5D,K5E,K57, \
+    KE1,K1D,K1B,K06,K19,K05,K11,K10,K36,K37,K38,        KE5,     K52,      K59,K5A,K5B,     \
+    KE0,KE3,KE2,        K2C,                KE6,KE7,K65,KE4, K50,K51,K4F,  K62,    K63,K58  \
+) { \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, /* 00-07 */ \
+    { KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, /* 08-0F */ \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, /* 10-17 */ \
+    { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K1F }, /* 18-1F */ \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, /* 20-27 */ \
+    { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, /* 28-2F */ \
+    { KC_##K30, KC_##K31, KC_NO,    KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, /* 30-37 */ \
+    { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, /* 38-3F */ \
+    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, /* 40-47 */ \
+    { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_##K4F }, /* 48-4F */ \
+    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, /* 50-57 */ \
+    { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F }, /* 58-5F */ \
+    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_NO,    KC_##K65, KC_NO,    KC_NO    }, /* 60-67 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 68-6F */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 70-77 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 78-7F */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 80-87 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 88-8F */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 90-97 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* 98-9F */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* A0-A7 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* A8-AF */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* B0-B7 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* B8-BF */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* C0-C7 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* C8-CF */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* D0-D7 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* D8-DF */ \
+    { KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7 }, /* E0-E7 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* E8-EF */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* F0-F7 */ \
+    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, /* F8-FF */ \
+}
+
+#endif
diff --git a/converter/usb_usb/keymap_hasu.c b/converter/usb_usb/keymap_hasu.c
new file mode 100644
index 0000000000..de19e23076
--- /dev/null
+++ b/converter/usb_usb/keymap_hasu.c
@@ -0,0 +1,158 @@
+#include "keymap_common.h"
+
+const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
+    /* Layer 0: Default Layer
+     * ,-----------------------------------------------------------.
+     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|  `|
+     * |-----------------------------------------------------------|
+     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Backs|
+     * |-----------------------------------------------------------|
+     * |Contro|  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Fn6     |
+     * |-----------------------------------------------------------|
+     * |Fn7     |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|Fn2|Shift |Fn1|
+     * `-----------------------------------------------------------'
+     *       |Gui|Alt  |         Fn4           |Fn5  |Gui|
+     *       `-------------------------------------------'
+     */
+    [0] = \
+    KEYMAP(
+    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,BRK,
+    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
+    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,     DEL, END, PGDN,    P7,  P8,  P9,
+    LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   FN3, QUOT,     FN6,                         P4,  P5,  P6,  PPLS,
+    FN7, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, FN2,           RSFT,          UP,           P1,  P2,  P3,
+    LCTL,LGUI,LALT,          FN4,                     RALT,FN5, FN5, FN1,      LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    ),
+
+    /* Layer 1: HHKB mode[HHKB Fn]
+     * ,-----------------------------------------------------------.
+     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+     * |-----------------------------------------------------------|
+     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |Backs|
+     * |-----------------------------------------------------------|
+     * |Contro|VoD|VoU|Mut|   |   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
+     * |-----------------------------------------------------------|
+     * |Shift   |   |   |   |   |   |  +|  -|End|PgD|Dow|Shift |   |
+     * `-----------------------------------------------------------'
+     *       |Gui|Alt  |         Space         |Alt  |Gui|
+     *       `-------------------------------------------'
+     */ 
+    [1] = \
+    KEYMAP(
+    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,BRK,
+    GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
+    CAPS,NO,  NO,  NO,  NO,  NO,  NO,  NO,  PSCR,SLCK,PAUS, UP,  NO, BSLS,     DEL, END, PGDN,    P7,  P8,  P9,
+    LCTL,VOLD,VOLU,MUTE,NO,  NO,  PAST,PSLS,HOME,PGUP,LEFT,RGHT,     ENT,                         P4,  P5,  P6,  PPLS,
+    LSFT,NO,  NO,  NO,  NO,  NO,  PPLS,PMNS,END, PGDN,DOWN,          RSFT,          UP,           P1,  P2,  P3,
+    LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    ),
+
+    /* Layer 2: Vi mode[Slash]
+     * ,-----------------------------------------------------------.
+     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+     * |-----------------------------------------------------------|
+     * |Tab  |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd|   |   |   |Backs|
+     * |-----------------------------------------------------------|
+     * |Contro|   |Lef|Dow|Rig|   |Lef|Dow|Up |Rig|   |   |Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |   |   |   |   |   |Hom|PgD|PgUlEnd|Fn0|Shift |   |
+     * `-----------------------------------------------------------'
+     *       |Gui|Alt  |          Space        |Alt  |Gui|
+     *       `-------------------------------------------'
+     */
+    [2] = \
+    KEYMAP(
+    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,BRK,
+    GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
+    TAB, HOME,PGDN,UP,  PGUP,END, HOME,PGDN,PGUP,END, NO,  NO,  NO,  BSLS,     DEL, END, PGDN,    P7,  P8,  P9,
+    LCTL,NO,  LEFT,DOWN,RGHT,NO,  LEFT,DOWN,UP,  RGHT,NO,  NO,       ENT,                         P4,  P5,  P6,  PPLS,
+    LSFT,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, TRNS,          RSFT,          UP,           P1,  P2,  P3,
+    LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    ),
+
+    /* Layer 3: Mouse mode(IJKL)[Semicolon]
+     * ,-----------------------------------------------------------.
+     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+     * |-----------------------------------------------------------|
+     * |Tab  |   |   |   |   |   |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
+     * |-----------------------------------------------------------|
+     * |Contro|   |   |   |   |   |Mb2|McL|McD|McR|Fn |   |Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift |   |
+     * `-----------------------------------------------------------'
+     *      |Gui |Alt  |          Mb1          |Fn   |Fn |
+     *      `--------------------------------------------'
+     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
+     */
+    [3] = \
+    KEYMAP(
+    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,BRK,
+    GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, FN8,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
+    FN8, NO,  NO,  NO,  NO,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8,      DEL, END, PGDN,    P7,  P8,  P9,
+    LCTL,ACL0,ACL1,ACL2,ACL2,NO,  NO,  MS_L,MS_D,MS_R,TRNS,NO,       ENT,                         P4,  P5,  P6,  PPLS,
+    LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,BTN4,BTN5,NO,            RSFT,          UP,           P1,  P2,  P3,
+    LCTL,LGUI,LALT,          BTN1,                    RALT,TRNS,TRNS,RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    ),
+
+    /* Layer 5: Mouse mode(IJKL)[Space]
+     * ,-----------------------------------------------------------.
+     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+     * |-----------------------------------------------------------|
+     * |Tab  |   |   |   |   |   |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
+     * |-----------------------------------------------------------|
+     * |Contro|   |   |   |   |   |Mb2|McL|McD|McR|Mb1|   |Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift |   |
+     * `-----------------------------------------------------------'
+     *      |Gui |Alt  |          Mb1          |Fn   |Fn |
+     *      `--------------------------------------------'
+     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
+     */
+    [4] = \
+    KEYMAP(
+    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,BRK,
+    GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, FN8,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
+    FN8, NO,  NO,  NO,  NO,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8,      DEL, END, PGDN,    P7,  P8,  P9,
+    LCTL,ACL0,ACL1,ACL2,ACL2,NO,  NO,  MS_L,MS_D,MS_R,BTN1,NO,       ENT,                         P4,  P5,  P6,  PPLS,
+    LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,BTN4,BTN5,NO,            RSFT,          UP,           P1,  P2,  P3,
+    LCTL,LGUI,LALT,          TRNS,                    RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    ),
+};
+
+
+/*
+ * Macro definition
+ */
+enum macro_id {
+    ALT_TAB,
+};
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+    switch (id) {
+        case ALT_TAB:
+            return (record->event.pressed ?
+                    MACRO( D(LALT), D(TAB), END ) :
+                    MACRO( U(TAB), END ));
+    }
+    return MACRO_NONE;
+}
+
+
+/*
+ * Fn action definition
+ */
+#ifdef KEYMAP_SECTION_ENABLE
+const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
+#else
+const uint16_t fn_actions[] PROGMEM = {
+#endif
+    [0] = ACTION_DEFAULT_LAYER_SET(0),                // Default layer(not used)
+    [1] = ACTION_LAYER_TAP_TOGGLE(1),                 // HHKB layer(toggle with 5 taps)
+    [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH),          // Cursor layer with Slash*
+    [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN),           // Mousekey layer with Semicolon*
+    [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC),            // Mousekey layer with Space
+    [5] = ACTION_LAYER_MOMENTARY(3),                  // Mousekey layer
+    [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT),      // RControl with tap Enter
+    [7] = ACTION_MODS_ONESHOT(MOD_LSFT),              // Oneshot Shift
+    [8] = ACTION_MACRO(ALT_TAB),                      // Application switching
+};
diff --git a/converter/usb_usb/keymap_spacefn.c b/converter/usb_usb/keymap_spacefn.c
new file mode 100644
index 0000000000..bffd2bc606
--- /dev/null
+++ b/converter/usb_usb/keymap_spacefn.c
@@ -0,0 +1,61 @@
+/*
+ * SpaceFN layout
+ * http://geekhack.org/index.php?topic=51069.0
+ */
+#include "keymap_common.h"
+
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* 0: default
+     * ,---.   ,---------------. ,---------------. ,---------------. ,-----------.     ,-----------.
+     * |Esc|   |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|     |Pwr|Slp|Wak|
+     * `---'   `---------------' `---------------' `---------------' `-----------'     `-----------'
+     * ,-----------------------------------------------------------. ,-----------. ,---------------.
+     * |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backspa| |Ins|Hom|PgU| |NmL|  /|  *|  -|
+     * |-----------------------------------------------------------| |-----------| |---------------|
+     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \| |Del|End|PgD| |  7|  8|  9|   |
+     * |-----------------------------------------------------------| `-----------' |-----------|  +|
+     * |CapsLo|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |               |  4|  5|  6|   |
+     * |-----------------------------------------------------------|     ,---.     |---------------|
+     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /|Shift     |     |Up |     |  1|  2|  3|   |
+     * |-----------------------------------------------------------| ,-----------. |-----------|Ent|
+     * |Ctrl |Gui |Alt |         Space         |Alt |Gui |Menu|Ctrl| |Lef|Dow|Rig| |      0|  .|   |
+     * `-----------------------------------------------------------' `-----------' `---------------'
+     */
+    KEYMAP(
+    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,BRK,
+    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,     INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
+    TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,     DEL, END, PGDN,    P7,  P8,  P9,
+    CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,                         P4,  P5,  P6,  PPLS,
+    LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT,          UP,           P1,  P2,  P3,
+    LCTL,LGUI,LALT,          FN0,                     RALT,RGUI,APP, RCTL,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    ),
+
+    /* 1: SpaceFN
+     * ,-----------------------------------------------------------.
+     * |`  | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
+     * |-----------------------------------------------------------|
+     * |     |   |   |Esc|   |   |   |Hom|Up |End|Psc|Slk|Pau|Ins  |
+     * |-----------------------------------------------------------|
+     * |      |   |   |   |   |   |PgU|Lef|Dow|Rig|   |   |        |
+     * |-----------------------------------------------------------|
+     * |        |   |   |   |   |Spc|PgD|`  |~  |   |Men|          |
+     * |-----------------------------------------------------------|
+     * |    |    |    |                        |    |    |    |    |
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP(
+    ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,           PSCR,SLCK,BRK,
+    GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL,      INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS,
+    TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP,  END, PSCR,SLCK,PAUS,INS,      DEL, END, PGDN,    P7,  P8,  P9,
+    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS,     TRNS,                        P4,  P5,  P6,  PPLS,
+    TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,APP,           TRNS,          UP,           P1,  P2,  P3,
+    TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS,     LEFT,DOWN,RGHT,    P0,       PDOT,PENT
+    ),
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE),
+    [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),    // tilde
+};
+

From 4a8b9b8a2e2ef98827109be08289e79fb0695d54 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Fri, 12 Dec 2014 12:11:46 -0500
Subject: [PATCH 11/95] Update keymap_planck.c

---
 keyboard/gh60/keymap_planck.c | 79 +++++++++++++++--------------------
 1 file changed, 34 insertions(+), 45 deletions(-)

diff --git a/keyboard/gh60/keymap_planck.c b/keyboard/gh60/keymap_planck.c
index 4ff3f3da57..a2e6b88749 100644
--- a/keyboard/gh60/keymap_planck.c
+++ b/keyboard/gh60/keymap_planck.c
@@ -1,51 +1,40 @@
 #include "keymap_common.h"
 
 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    [0] = KEYMAP( /* Native */
-      ESC,     Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    FN2, 
-      BSPC,    A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
-      TAB,     Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
-      DEL,     LCTL, NO,   LSFT, LALT, SPC,        NO,   LEFT, DOWN, UP,  RGHT), 
-    [1] = KEYMAP( /* QWERTY->PHOTOSHOP */
-      DELETE,  0,    1,    2,    3,    4,    5,    6,    7,    8,    9,    FN1,
-      O,       G,    S,    U,    T,    FN27,  F21,  F10,  F11,  F7,   F8,   F9,
-      TAB,     FN22, FN24,  FN6,  F1,   FN7,  F18,  F19,  F23,  F20,  F22,  FN9,
-      COMM,    DOT,  FN10, FN11, FN3,  SPC,        FN12, F2,   FN8,  F3,   F14),
-    [2] = KEYMAP( /* 2: FN3 PHOTOSHOP */
-      ESC,    FN25, FN26,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,
-      NO,      NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   FN19, FN20, FN21, 
-      C,       FN4,  NO,  FN5,   NO,   FN23, NO,   NO,   NO,   NO,   FN13, NO,
-      FN14,    FN15, FN16, FN17, FN3,   SPC,        FN18, NO,   NO,   F24,  NO),
+[0] = KEYMAP( /* Jack */
+  TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
+  LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
+  RSFT, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
+[1] = KEYMAP( /* Jack RAISE */
+  GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    BSPC,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC, BSLS,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS,    TRNS,   FN1,  MNXT, VOLD, VOLU, MPLY),
+[2] = KEYMAP( /* Jack LOWER */
+  FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, FN2,    TRNS,    TRNS, MNXT, VOLD, VOLU, MPLY),
 };
-
 const uint16_t PROGMEM fn_actions[] = {
-    [1] = ACTION_DEFAULT_LAYER_SET(0),                             // set Qwerty layout
-    [2] = ACTION_DEFAULT_LAYER_SET(1),                             // set Photoshop presets
-    [3] = ACTION_LAYER_ON_OFF(2),                                  // Photoshop function layer
- 
-    [4] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F9),   // photo folder AHK
-    [5] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_I),              // select inverse
-    [6] = ACTION_MODS_KEY(MOD_LSFT, KC_M),                         // marquee select
-    [7] = ACTION_MODS_KEY(MOD_LALT, KC_BSPC),                      // fill 
-    [8] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_X),    // warp
-    [9] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT | MOD_LSFT, KC_F12),  // merge all new layer
-    [10] = ACTION_MODS_KEY(MOD_LCTL, KC_MINS),                     // zoom out
-    [11] = ACTION_MODS_KEY(MOD_LCTL, KC_H),                        // RBG sliders
-    [12] = ACTION_MODS_KEY(MOD_LCTL, KC_S),                        // save
-    [13] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F5),           // layer mask from transparancy 
-    [14] = ACTION_MODS_KEY(MOD_LALT, KC_LBRC),                     // prev layer
-    [15] = ACTION_MODS_KEY(MOD_LALT, KC_RBRC),                     // next layer
-    [16] = ACTION_MODS_KEY(MOD_LCTL, KC_EQL),                      // zoom in
-    [17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_H),             // HSV sliders
-    [18] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F11), // save as PNG
-    [19] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F7),  // gaussian blur
-    [20] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F8),  // motion blur
-    [21] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_X),            // liquify filter
-    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),                     // prev layer blending
-    [23] = ACTION_MODS_KEY(MOD_LSFT | MOD_LALT, KC_N),             // normal layer blending
-    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),                      // next layer blending
-    [25] = ACTION_MODS_KEY(MOD_LCTL, KC_Z),                        // step back
-    [26] = ACTION_MODS_KEY(MOD_LCTL, KC_Y),                        // step forward
-    [27] = ACTION_MODS_KEY(MOD_LCTL, KC_R),                        // rasterize
-     
+    [1] = ACTION_LAYER_MOMENTARY(1),  // to Fn overlay
+    [2] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
+
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
 };

From 4e3397ca8aacf843c6c491716c0a638d0c63af49 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Fri, 12 Dec 2014 12:12:06 -0500
Subject: [PATCH 12/95] Update matrix.c

---
 keyboard/gh60/matrix.c | 82 +++++++++++++++++++-----------------------
 1 file changed, 37 insertions(+), 45 deletions(-)

diff --git a/keyboard/gh60/matrix.c b/keyboard/gh60/matrix.c
index 83016b77ae..720ac30043 100644
--- a/keyboard/gh60/matrix.c
+++ b/keyboard/gh60/matrix.c
@@ -30,7 +30,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 #ifndef DEBOUNCE
-#   define DEBOUNCE 10
+#   define DEBOUNCE	10
 #endif
 static uint8_t debouncing = DEBOUNCE;
 
@@ -56,21 +56,12 @@ uint8_t matrix_cols(void)
     return MATRIX_COLS;
 }
 
-static
-void setup_leds(void) {
-  DDRF  |=  0x00;
-  PORTF |=  0x00;
-}
-
-
 void matrix_init(void)
 {
     // initialize row and col
     unselect_rows();
     init_cols();
 
-    setup_leds();
-
     // initialize matrix state: all keys off
     for (uint8_t i=0; i < MATRIX_ROWS; i++) {
         matrix[i] = 0;
@@ -104,15 +95,16 @@ uint8_t matrix_scan(void)
         }
     }
 
-    // uint8_t layer = biton32(default_layer_state);
-    switch (default_layer_state) {
+    uint8_t layer = biton32(layer_state);
+    switch (layer) {
         case 1:
-            DDRF &= ~(1<<0);
-            PORTF &= ~(1<<0);
-            break;
         case 2:
-            DDRF |= (1<<0);
-            PORTF |= (1<<0);
+            DDRC |= (1<<7);
+            PORTC |= (1<<7);
+            break;
+        case 0:
+            DDRC &= ~(1<<7);
+            PORTC &= ~(1<<7);
             break;
     }
 
@@ -163,28 +155,28 @@ uint8_t matrix_key_count(void)
 
 static void init_cols(void)
 {
-    DDRC  &= ~(1<<6 | 1<<7);
-    PORTC |=  (1<<6 | 1<<7);
-    DDRD  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<5);
-    PORTD |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<5);
+    DDRF  &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    PORTF |=  (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    DDRD  &= ~(1<<0);
+    PORTD |=  (1<<0);
     DDRB  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
     PORTB |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
 }
 
 static matrix_row_t read_cols(void)
 {
-    return (PIND&(1<<5) ? 0 : (1<< 0)) |
-           (PINC&(1<<7) ? 0 : (1<< 1)) |
-           (PINC&(1<<6) ? 0 : (1<< 2)) |
-           (PIND&(1<<3) ? 0 : (1<< 3)) |
-           (PIND&(1<<2) ? 0 : (1<< 4)) |
-           (PIND&(1<<1) ? 0 : (1<< 5)) |
-           (PIND&(1<<0) ? 0 : (1<< 6)) |
-           (PINB&(1<<7) ? 0 : (1<< 7)) |
-           (PINB&(1<<3) ? 0 : (1<< 8)) |
-           (PINB&(1<<2) ? 0 : (1<< 9)) |
-           (PINB&(1<<1) ? 0 : (1<<10)) |
-           (PINB&(1<<0) ? 0 : (1<<11));
+    return (PINB&(1<<0) ? 0 : (1<< 0)) |
+           (PINB&(1<<1) ? 0 : (1<< 1)) |
+           (PINB&(1<<2) ? 0 : (1<< 2)) |
+           (PINB&(1<<3) ? 0 : (1<< 3)) |
+           (PINB&(1<<7) ? 0 : (1<< 4)) |
+           (PIND&(1<<0) ? 0 : (1<< 5)) |
+           (PINF&(1<<7) ? 0 : (1<< 6)) |
+           (PINF&(1<<6) ? 0 : (1<< 7)) |
+           (PINF&(1<<5) ? 0 : (1<< 8)) |
+           (PINF&(1<<4) ? 0 : (1<< 9)) |
+           (PINF&(1<<1) ? 0 : (1<<10)) |
+           (PINF&(1<<0) ? 0 : (1<<11));
 }
 
 /* Row pin configuration
@@ -194,30 +186,30 @@ static matrix_row_t read_cols(void)
 static void unselect_rows(void)
 {
     // Hi-Z(DDR:0, PORT:0) to unselect
-    DDRD  &= ~(1<<4 | 1<<6 | 1<<7);
-    PORTD |=  (1<<4 | 1<<6 | 1<<7);
-    DDRB  &= ~(1<<4);
-    PORTB |=  (1<<4);
+    DDRB  &= ~0b01110000;
+    PORTB &= ~0b01110000;
+    DDRD  &= ~0b10000000;
+    PORTD &= ~0b10000000;
 }
 
 static void select_row(uint8_t row)
 {
     switch (row) {
         case 0:
-            DDRD  |= (1<<4);
-            PORTD &= ~(1<<4);
+            DDRB  |= (1<<6);
+            PORTB &= ~(1<<6);
             break;
         case 1:
-            DDRD  |= (1<<6);
-            PORTD &= ~(1<<6);
+            DDRB  |= (1<<5);
+            PORTB &= ~(1<<5);
             break;
         case 2:
-            DDRD  |= (1<<7);
-            PORTD &= ~(1<<7);
-            break;
-        case 3:
             DDRB  |= (1<<4);
             PORTB &= ~(1<<4);
             break;
+        case 3:
+            DDRD  |= (1<<7);
+            PORTD &= ~(1<<7);
+            break;
     }
 }

From 79849ee5344a38118534219fb29276b20a8f3e24 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Fri, 12 Dec 2014 12:12:36 -0500
Subject: [PATCH 13/95] Update keymap_common.h

---
 keyboard/gh60/keymap_common.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/keyboard/gh60/keymap_common.h b/keyboard/gh60/keymap_common.h
index 738741815f..7c95fb8e7c 100644
--- a/keyboard/gh60/keymap_common.h
+++ b/keyboard/gh60/keymap_common.h
@@ -41,12 +41,12 @@ extern const uint16_t fn_actions[];
     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
     K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
-    K30, K31, K32, K33, K34,    K35,   K37, K38, K39, K3A, K3B  \
+    K30, K31, K32, K33, K34,      K36, K37, K38, K39, K3A, K3B  \
 ) { \
     { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
     { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
     { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
-    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO,    KC_##K35, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO,    KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
 }
 
 #endif

From ed8d9a099d90d0a367d3887a26a1efa9129bc345 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Sun, 14 Dec 2014 10:30:27 -0500
Subject: [PATCH 14/95] added planck folder

---
 keyboard/planck/Makefile                      | 135 +++++++++++
 keyboard/planck/Makefile.pjrc                 | 116 ++++++++++
 keyboard/planck/README.md                     | 141 ++++++++++++
 keyboard/planck/config.h                      |  70 ++++++
 keyboard/planck/keymap_common.c               |  30 +++
 keyboard/planck/keymap_common.h               |  52 +++++
 .../keymap_planck.c => planck/keymap_jack.c}  |   8 +-
 keyboard/planck/led.c                         |  34 +++
 keyboard/planck/matrix.c                      | 215 ++++++++++++++++++
 9 files changed, 798 insertions(+), 3 deletions(-)
 create mode 100644 keyboard/planck/Makefile
 create mode 100644 keyboard/planck/Makefile.pjrc
 create mode 100644 keyboard/planck/README.md
 create mode 100644 keyboard/planck/config.h
 create mode 100644 keyboard/planck/keymap_common.c
 create mode 100644 keyboard/planck/keymap_common.h
 rename keyboard/{gh60/keymap_planck.c => planck/keymap_jack.c} (91%)
 create mode 100644 keyboard/planck/led.c
 create mode 100644 keyboard/planck/matrix.c

diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
new file mode 100644
index 0000000000..2ec324bd95
--- /dev/null
+++ b/keyboard/planck/Makefile
@@ -0,0 +1,135 @@
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device.
+#                Please customize your programmer settings(PROGRAM_CMD)
+#
+# make teensy = Download the hex file to the device, using teensy_loader_cli.
+#               (must have teensy_loader_cli installed).
+#
+# make dfu = Download the hex file to the device, using dfu-programmer (must
+#            have dfu-programmer installed).
+#
+# make flip = Download the hex file to the device, using Atmel FLIP (must
+#             have Atmel FLIP installed).
+#
+# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
+#               (must have dfu-programmer installed).
+#
+# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
+#                (must have Atmel FLIP installed).
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+# Target file name (without extension).
+TARGET = gh60_lufa
+
+# Directory common source filess exist
+TOP_DIR = ../..
+
+# Directory keyboard dependent files exist
+TARGET_DIR = .
+
+# project specific files
+SRC =	keymap_common.c \
+	matrix.c \
+	led.c
+
+ifdef KEYMAP
+    SRC := keymap_$(KEYMAP).c $(SRC)
+else
+    SRC := keymap_jack.c $(SRC)
+endif
+
+CONFIG_H = config.h
+
+
+# MCU name
+#MCU = at90usb1287
+MCU = atmega32u4
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency in Hz. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+#
+#     This will be an integer division of F_USB below, as it is sourced by
+#     F_USB after it has run through any CPU prescalers. Note that this value
+#     does not *change* the processor frequency - it should merely be updated to
+#     reflect the processor speed set externally so that the code can use accurate
+#     software delays.
+F_CPU = 16000000
+
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+#     This will define a symbol, F_USB, in all source code files equal to the
+#     input clock frequency (before any prescaling is performed) in Hz. This value may
+#     differ from F_CPU if prescaling is used on the latter, and is required as the
+#     raw input clock is fed directly to the PLL sections of the AVR for high speed
+#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+#     at the end, this will be done automatically to create a 32-bit value in your
+#     source code.
+#
+#     If no clock division is performed on the input clock inside the AVR (via the
+#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+#   Teensy halfKay   512
+#   Teensy++ halfKay 1024
+#   Atmel DFU loader 4096
+#   LUFA bootloader  4096
+#   USBaspLoader     2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+
+# Build Options
+#   comment out to disable the options.
+#
+BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
+CONSOLE_ENABLE = yes	# Console for debug(+400)
+COMMAND_ENABLE = yes    # Commands for debug and configuration
+#SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
+NKRO_ENABLE = yes	# USB Nkey Rollover - not yet supported in LUFA
+
+
+# Optimize size but this may cause error "relocation truncated to fit"
+#EXTRALDFLAGS = -Wl,--relax
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol/lufa.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
diff --git a/keyboard/planck/Makefile.pjrc b/keyboard/planck/Makefile.pjrc
new file mode 100644
index 0000000000..be83ba18b1
--- /dev/null
+++ b/keyboard/planck/Makefile.pjrc
@@ -0,0 +1,116 @@
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device.
+#                Please customize your programmer settings(PROGRAM_CMD)
+#
+# make teensy = Download the hex file to the device, using teensy_loader_cli.
+#               (must have teensy_loader_cli installed).
+#
+# make dfu = Download the hex file to the device, using dfu-programmer (must
+#            have dfu-programmer installed).
+#
+# make flip = Download the hex file to the device, using Atmel FLIP (must
+#             have Atmel FLIP installed).
+#
+# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
+#               (must have dfu-programmer installed).
+#
+# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
+#                (must have Atmel FLIP installed).
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+# Target file name (without extension).
+TARGET = gh60_pjrc
+
+# Directory common source filess exist
+TOP_DIR = ../..
+
+# Directory keyboard dependent files exist
+TARGET_DIR = .
+
+# project specific files
+SRC =	keymap_common.c \
+	matrix.c \
+	led.c
+
+ifdef KEYMAP
+    SRC := keymap_$(KEYMAP).c $(SRC)
+else
+    SRC := keymap_jack.c $(SRC)
+endif
+
+CONFIG_H = config.h
+
+
+# MCU name, you MUST set this to match the board you are using
+# type "make clean" after changing this, so all files will be rebuilt
+MCU = atmega32u4
+#MCU = at90usb1286
+
+
+# Processor frequency.
+#   Normally the first thing your program should do is set the clock prescaler,
+#   so your program will run at the correct speed.  You should also set this
+#   variable to same clock speed.  The _delay_ms() macro uses this, and many
+#   examples use this variable to calculate timings.  Do not add a "UL" here.
+F_CPU = 16000000
+
+
+# Boot Section Size in *bytes*
+#   Teensy halfKay   512
+#   Atmel DFU loader 4096
+#   LUFA bootloader  4096
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+
+# Build Options
+#   comment out to disable the options.
+#
+BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes	# Mouse keys(+5000)
+EXTRAKEY_ENABLE = yes	# Audio control and System control(+600)
+CONSOLE_ENABLE = yes    # Console for debug
+COMMAND_ENABLE = yes    # Commands for debug and configuration
+SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
+NKRO_ENABLE = yes	# USB Nkey Rollover(+500)
+#PS2_MOUSE_ENABLE = yes	# PS/2 mouse(TrackPoint) support
+
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol/pjrc.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
+
+plain: OPT_DEFS += -DKEYMAP_PLAIN
+plain: all
+
+poker: OPT_DEFS += -DKEYMAP_POKER
+poker: all
+
+poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
+poker_set: all
+
+poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
+poker_bit: all
diff --git a/keyboard/planck/README.md b/keyboard/planck/README.md
new file mode 100644
index 0000000000..510cb5c8b6
--- /dev/null
+++ b/keyboard/planck/README.md
@@ -0,0 +1,141 @@
+GH60 keyboard firmware
+======================
+DIY compact keyboard designed and run by komar007 and Geekhack community.
+
+- Both Rev.A and Rev.B PCB are supported by one firmware binary(issue #64)
+
+## GH60 Resources
+- [KOMAR's project page](http://blog.komar.be/projects/gh60-programmable-keyboard/)
+- [Prototyping](http://geekhack.org/index.php?topic=34959.0)
+- [Rev.A PCB test](http://geekhack.org/index.php?topic=37570.0)
+- [Rev.B PCB test](http://geekhack.org/index.php?topic=50685.0)
+- [Group buy](http://geekhack.org/index.php?topic=41464.0)
+
+
+## Build
+Move to this directory then just run `make` like:
+
+    $ make
+
+Use `make -f Makefile.pjrc` if you want to use PJRC stack but I find no reason to do so now.
+
+
+## Keymap
+Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_<name>.c` and see keymap document(you can find in top README.md) and existent keymap files.
+
+To build firmware binary hex file with a certain keymap just do `make` with `KEYMAP` option like:
+
+    $ make KEYMAP=[poker|poker_set|poker_bit|plain|hasu|spacefn|hhkb|<name>]
+
+
+### 1  Poker
+[keymap_poker.c](keymap_poker.c) emulates original Poker layers
+while both [keymap_poker_bit.c](keymap_poker_bit.c) and [keymap_poker_set.c](keymap_poker_set.c) implements same layout in different way and they fix a minor issue of original Poker and enhance arrow keys.
+
+    Fn + Esc = `
+    Fn + {left, down, up, right}  = {home, pgdown, pgup, end}
+
+#### 1.0 Default layer
+    ,-----------------------------------------------------------.
+    |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+    |-----------------------------------------------------------|
+    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
+    |-----------------------------------------------------------|
+    |Ctrl|Gui |Alt |      Space             |Fn  |Gui |App |Ctrl|
+    `-----------------------------------------------------------'
+#### 1.1 Poker Fn layer
+    ,-----------------------------------------------------------.
+    |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|       |
+    |-----------------------------------------------------------|
+    |     |FnQ| Up|   |   |   |   |   |   |Cal|   |Hom|Ins|     |
+    |-----------------------------------------------------------|
+    |      |Lef|Dow|Rig|   |   |Psc|Slk|Pau|   |Tsk|End|        |
+    |-----------------------------------------------------------|
+    |        |Del|   |Web|Mut|VoU|VoD|   |PgU|PgD|Del|   Up     |
+    |-----------------------------------------------------------|
+    |    |    |    |         FnS            |Fn  |Left|Down|Righ|
+    `-----------------------------------------------------------'
+
+
+### 2. Plain
+Without any Fn layer this will be useful if you want to use key remapping tool like AHK on host.
+See [keymap_plain.c](keymap_plain.c) for detail.
+
+#### 1.0 Plain Default layer
+    ,-----------------------------------------------------------.
+    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+    |-----------------------------------------------------------|
+    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
+    |-----------------------------------------------------------|
+    |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |Ctrl|
+    `-----------------------------------------------------------'
+
+
+### 3. Hasu
+This is my favorite keymap with HHKB Fn, Vi cursor and Mousekey layer. See [keymap_hasu.c](keymap_hasu.c) for detail.
+
+
+### 4. SpaceFN
+This layout proposed by spiceBar uses space bar to change layer with using Dual role key technique. See [keymap_spacefn.c](keymap_spacefn.c) and [SpaceFN discussion](http://geekhack.org/index.php?topic=51069.0).
+
+#### 4.0 Default layer
+    ,-----------------------------------------------------------.
+    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+    |-----------------------------------------------------------|
+    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
+    |-----------------------------------------------------------|
+    |Ctrl|Gui |Alt |      Space/Fn          |Alt |Gui |App |Ctrl|
+    `-----------------------------------------------------------'
+#### 4.1 SpaceFN layer
+    ,-----------------------------------------------------------.
+    |`  | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
+    |-----------------------------------------------------------|
+    |     |   |   |   |   |   |   |Hom|Up |End|Psc|Slk|Pau|Ins  |
+    |-----------------------------------------------------------|
+    |      |   |   |   |   |   |PgU|Lef|Dow|Rig|   |   |        |
+    |-----------------------------------------------------------|
+    |        |   |   |   |   |Spc|PgD|`  |~  |   |   |          |
+    |-----------------------------------------------------------|
+    |    |    |    |            Fn          |    |    |    |    |
+    `-----------------------------------------------------------'
+
+
+### 5. HHKB
+[keymap_hhkb.c](keymap_hhkb.c) emulates original HHKB layers.
+#### 5.0: Default layer
+    ,-----------------------------------------------------------.
+    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|  `|
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Bspc |
+    |-----------------------------------------------------------|
+    |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Fn |
+    |-----------------------------------------------------------|
+    |    |Gui |Alt |      Space             |    |Alt |Gui |    |
+    `-----------------------------------------------------------'
+#### 5.1: HHKB Fn layer
+    ,-----------------------------------------------------------.
+    |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+    |-----------------------------------------------------------|
+    |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |     |
+    |-----------------------------------------------------------|
+    |      |VoD|VoU|Mut|Ejc|   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
+    |-----------------------------------------------------------|
+    |        |   |   |   |   |   |  +|  -|End|PgD|Dow|      |   |
+    |-----------------------------------------------------------|
+    |    |    |    |                        |    |    |    |    |
+    `-----------------------------------------------------------'
+
diff --git a/keyboard/planck/config.h b/keyboard/planck/config.h
new file mode 100644
index 0000000000..81637f45b2
--- /dev/null
+++ b/keyboard/planck/config.h
@@ -0,0 +1,70 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0x6060
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    jackhumbert
+#define PRODUCT         Planck
+#define DESCRIPTION     t.m.k. keyboard firmware for the Planck
+
+/* key matrix size */
+#define MATRIX_ROWS 4
+#define MATRIX_COLS 12
+
+/* define if matrix has ghost */
+//#define MATRIX_HAS_GHOST
+
+/* Set 0 if debouncing isn't needed */
+#define DEBOUNCE    5
+
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
+#define LOCKING_SUPPORT_ENABLE
+/* Locking resynchronize hack */
+#define LOCKING_RESYNC_ENABLE
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+
+
+/*
+ * Feature disable options
+ *  These options are also useful to firmware size reduction.
+ */
+
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
+//#define NO_ACTION_MACRO
+//#define NO_ACTION_FUNCTION
+
+#endif
diff --git a/keyboard/planck/keymap_common.c b/keyboard/planck/keymap_common.c
new file mode 100644
index 0000000000..fdb1769e1c
--- /dev/null
+++ b/keyboard/planck/keymap_common.c
@@ -0,0 +1,30 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "keymap_common.h"
+
+
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+    return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
+}
diff --git a/keyboard/planck/keymap_common.h b/keyboard/planck/keymap_common.h
new file mode 100644
index 0000000000..7c95fb8e7c
--- /dev/null
+++ b/keyboard/planck/keymap_common.h
@@ -0,0 +1,52 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef KEYMAP_COMMON_H
+#define KEYMAP_COMMON_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/pgmspace.h>
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "print.h"
+#include "debug.h"
+#include "keymap.h"
+
+
+extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+
+/* GH60 keymap definition macro
+ * K2C, K31 and  K3C are extra keys for ISO
+ */
+#define KEYMAP( \
+    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
+    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
+    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
+    K30, K31, K32, K33, K34,      K36, K37, K38, K39, K3A, K3B  \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO,    KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
+}
+
+#endif
diff --git a/keyboard/gh60/keymap_planck.c b/keyboard/planck/keymap_jack.c
similarity index 91%
rename from keyboard/gh60/keymap_planck.c
rename to keyboard/planck/keymap_jack.c
index a2e6b88749..a1d7e36b9c 100644
--- a/keyboard/gh60/keymap_planck.c
+++ b/keyboard/planck/keymap_jack.c
@@ -5,7 +5,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
   ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
   LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
-  RSFT, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
+  FN26, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
 [1] = KEYMAP( /* Jack RAISE */
   GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    BSPC,
   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC, BSLS,
@@ -13,7 +13,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   TRNS, TRNS, TRNS, TRNS, TRNS,    TRNS,   FN1,  MNXT, VOLD, VOLU, MPLY),
 [2] = KEYMAP( /* Jack LOWER */
   FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
-  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN25,
   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
   TRNS, TRNS, TRNS, TRNS, FN2,    TRNS,    TRNS, MNXT, VOLD, VOLU, MPLY),
 };
@@ -36,5 +36,7 @@ const uint16_t PROGMEM fn_actions[] = {
     [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
     [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
     [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
-    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+    [25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+
+    [26] = ACTION_MODS_KEY(MOD_LSFT, MOD_RSFT),
 };
diff --git a/keyboard/planck/led.c b/keyboard/planck/led.c
new file mode 100644
index 0000000000..7c98510801
--- /dev/null
+++ b/keyboard/planck/led.c
@@ -0,0 +1,34 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <avr/io.h>
+#include "stdint.h"
+#include "led.h"
+
+
+void led_set(uint8_t usb_led)
+{
+    if (usb_led & (1<<USB_LED_FUNCTION)) {
+        // Output high.
+        DDRF |= (1<<0);
+        PORTF |= (1<<0);
+    } else {
+        // Output low.
+        DDRF &= ~(1<<0);
+        PORTF &= ~(1<<0);
+    }
+}
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c
new file mode 100644
index 0000000000..720ac30043
--- /dev/null
+++ b/keyboard/planck/matrix.c
@@ -0,0 +1,215 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * scan matrix
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "action_layer.h"
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+
+
+#ifndef DEBOUNCE
+#   define DEBOUNCE	10
+#endif
+static uint8_t debouncing = DEBOUNCE;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static matrix_row_t read_cols(void);
+static void init_cols(void);
+static void unselect_rows(void);
+static void select_row(uint8_t row);
+
+
+inline
+uint8_t matrix_rows(void)
+{
+    return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+    return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+    // initialize row and col
+    unselect_rows();
+    init_cols();
+
+    // initialize matrix state: all keys off
+    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+        matrix[i] = 0;
+        matrix_debouncing[i] = 0;
+    }
+}
+
+uint8_t matrix_scan(void)
+{
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        select_row(i);
+        _delay_us(30);  // without this wait read unstable value.
+        matrix_row_t cols = read_cols();
+        if (matrix_debouncing[i] != cols) {
+            matrix_debouncing[i] = cols;
+            if (debouncing) {
+                debug("bounce!: "); debug_hex(debouncing); debug("\n");
+            }
+            debouncing = DEBOUNCE;
+        }
+        unselect_rows();
+    }
+
+    if (debouncing) {
+        if (--debouncing) {
+            _delay_ms(1);
+        } else {
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+                matrix[i] = matrix_debouncing[i];
+            }
+        }
+    }
+
+    uint8_t layer = biton32(layer_state);
+    switch (layer) {
+        case 1:
+        case 2:
+            DDRC |= (1<<7);
+            PORTC |= (1<<7);
+            break;
+        case 0:
+            DDRC &= ~(1<<7);
+            PORTC &= ~(1<<7);
+            break;
+    }
+
+    return 1;
+}
+
+bool matrix_is_modified(void)
+{
+    if (debouncing) return false;
+    return true;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+    return (matrix[row] & ((matrix_row_t)1<<col));
+}
+
+inline
+matrix_row_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void matrix_print(void)
+{
+    print("\nr/c 0123456789ABCDEF\n");
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+        phex(row); print(": ");
+        pbin_reverse16(matrix_get_row(row));
+        print("\n");
+    }
+}
+
+uint8_t matrix_key_count(void)
+{
+    uint8_t count = 0;
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        count += bitpop16(matrix[i]);
+    }
+    return count;
+}
+
+/* Column pin configuration
+ * col: 0  1  2  3  4  5  6  7  8  9  10 11
+ * pin: F0 F1 F4 F5 F6 F7 B6 B5 B4 D7 D5 D4
+ */
+
+static void init_cols(void)
+{
+    DDRF  &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    PORTF |=  (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    DDRD  &= ~(1<<0);
+    PORTD |=  (1<<0);
+    DDRB  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+    PORTB |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+}
+
+static matrix_row_t read_cols(void)
+{
+    return (PINB&(1<<0) ? 0 : (1<< 0)) |
+           (PINB&(1<<1) ? 0 : (1<< 1)) |
+           (PINB&(1<<2) ? 0 : (1<< 2)) |
+           (PINB&(1<<3) ? 0 : (1<< 3)) |
+           (PINB&(1<<7) ? 0 : (1<< 4)) |
+           (PIND&(1<<0) ? 0 : (1<< 5)) |
+           (PINF&(1<<7) ? 0 : (1<< 6)) |
+           (PINF&(1<<6) ? 0 : (1<< 7)) |
+           (PINF&(1<<5) ? 0 : (1<< 8)) |
+           (PINF&(1<<4) ? 0 : (1<< 9)) |
+           (PINF&(1<<1) ? 0 : (1<<10)) |
+           (PINF&(1<<0) ? 0 : (1<<11));
+}
+
+/* Row pin configuration
+ * row: 0  1  2  3
+ * pin: B0 B1 B2 B3
+ */
+static void unselect_rows(void)
+{
+    // Hi-Z(DDR:0, PORT:0) to unselect
+    DDRB  &= ~0b01110000;
+    PORTB &= ~0b01110000;
+    DDRD  &= ~0b10000000;
+    PORTD &= ~0b10000000;
+}
+
+static void select_row(uint8_t row)
+{
+    switch (row) {
+        case 0:
+            DDRB  |= (1<<6);
+            PORTB &= ~(1<<6);
+            break;
+        case 1:
+            DDRB  |= (1<<5);
+            PORTB &= ~(1<<5);
+            break;
+        case 2:
+            DDRB  |= (1<<4);
+            PORTB &= ~(1<<4);
+            break;
+        case 3:
+            DDRD  |= (1<<7);
+            PORTD &= ~(1<<7);
+            break;
+    }
+}

From bb2596042428fad08509709bd9d63dbbb50e59f9 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Wed, 24 Dec 2014 11:11:07 +0900
Subject: [PATCH 15/95] [ps2,terminal_usb] Quick fix for build problem

---
 protocol.mk           | 2 ++
 protocol/ps2_io_avr.c | 1 +
 2 files changed, 3 insertions(+)

diff --git a/protocol.mk b/protocol.mk
index e057d1d601..d9194b2bfc 100644
--- a/protocol.mk
+++ b/protocol.mk
@@ -15,11 +15,13 @@ endif
 
 ifdef PS2_USE_INT
     SRC += protocol/ps2_interrupt.c
+    SRC += protocol/ps2_io_avr.c
     OPT_DEFS += -DPS2_USE_INT
 endif
 
 ifdef PS2_USE_USART
     SRC += protocol/ps2_usart.c
+    SRC += protocol/ps2_io_avr.c
     OPT_DEFS += -DPS2_USE_USART
 endif
 
diff --git a/protocol/ps2_io_avr.c b/protocol/ps2_io_avr.c
index be13d6696a..ed462345ba 100644
--- a/protocol/ps2_io_avr.c
+++ b/protocol/ps2_io_avr.c
@@ -1,4 +1,5 @@
 #include <stdbool.h>
+#include <avr/io.h>
 #include <util/delay.h>
 
 /* Check port settings for clock and data line */

From 5a8dbc63ea29eb454ad5f36de5c6c33172230f88 Mon Sep 17 00:00:00 2001
From: Colt Ma <mumchristmas@gmail.com>
Date: Fri, 26 Dec 2014 11:02:25 +0800
Subject: [PATCH 16/95] Add keycode for Fast Forward & Rewind

KC_MEDIA_FAST_FORWARD
KC_MEDIA_REWIND
---
 common/keycode.h | 6 +++++-
 common/report.h  | 5 ++++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/common/keycode.h b/common/keycode.h
index 08c3cbf42b..074e0f68f9 100644
--- a/common/keycode.h
+++ b/common/keycode.h
@@ -140,6 +140,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define KC_VOLD KC_AUDIO_VOL_DOWN
 #define KC_MNXT KC_MEDIA_NEXT_TRACK
 #define KC_MPRV KC_MEDIA_PREV_TRACK
+#define KC_MFFD KC_MEDIA_FAST_FORWARD
+#define KC_MRWD KC_MEDIA_REWIND
 #define KC_MSTP KC_MEDIA_STOP
 #define KC_MPLY KC_MEDIA_PLAY_PAUSE
 #define KC_MSEL KC_MEDIA_SELECT
@@ -420,7 +422,9 @@ enum internal_special_keycodes {
     KC_WWW_FORWARD,
     KC_WWW_STOP,
     KC_WWW_REFRESH,
-    KC_WWW_FAVORITES,   /* 0xBA */
+    KC_WWW_FAVORITES,   
+    KC_MEDIA_FAST_FORWARD,
+    KC_MEDIA_REWIND,    /* 0xBC */
 
     /* Fn key */
     KC_FN0              = 0xC0,
diff --git a/common/report.h b/common/report.h
index 62190469a4..f6c0a315de 100644
--- a/common/report.h
+++ b/common/report.h
@@ -61,6 +61,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* supplement for Bluegiga iWRAP HID(not supported by Windows?) */
 #define AL_LOCK                 0x019E
 #define TRANSPORT_RECORD        0x00B2
+#define TRANSPORT_FAST_FORWARD  0x00B3
 #define TRANSPORT_REWIND        0x00B4
 #define TRANSPORT_EJECT         0x00B8
 #define AC_MINIMIZE             0x0206
@@ -158,6 +159,8 @@ typedef struct {
     (key == KC_AUDIO_VOL_DOWN   ?  AUDIO_VOL_DOWN : \
     (key == KC_MEDIA_NEXT_TRACK ?  TRANSPORT_NEXT_TRACK : \
     (key == KC_MEDIA_PREV_TRACK ?  TRANSPORT_PREV_TRACK : \
+    (key == KC_MEDIA_FAST_FORWARD ?  TRANSPORT_FAST_FORWARD : \
+    (key == KC_MEDIA_REWIND     ?  TRANSPORT_REWIND : \
     (key == KC_MEDIA_STOP       ?  TRANSPORT_STOP : \
     (key == KC_MEDIA_EJECT      ?  TRANSPORT_STOP_EJECT : \
     (key == KC_MEDIA_PLAY_PAUSE ?  TRANSPORT_PLAY_PAUSE : \
@@ -171,7 +174,7 @@ typedef struct {
     (key == KC_WWW_FORWARD      ?  AC_FORWARD : \
     (key == KC_WWW_STOP         ?  AC_STOP : \
     (key == KC_WWW_REFRESH      ?  AC_REFRESH : \
-    (key == KC_WWW_FAVORITES    ?  AC_BOOKMARKS : 0)))))))))))))))))))
+    (key == KC_WWW_FAVORITES    ?  AC_BOOKMARKS : 0)))))))))))))))))))))
 
 #ifdef __cplusplus
 }

From af556d39d2f5a1ee30c34ee65ecd5d1b7a519bdc Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Fri, 26 Dec 2014 13:27:06 +0900
Subject: [PATCH 17/95] Remove unwanted white space

---
 common/keycode.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/keycode.h b/common/keycode.h
index 074e0f68f9..ac4ef00db6 100644
--- a/common/keycode.h
+++ b/common/keycode.h
@@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-/* 
+/*
  * Keycodes based on HID Usage Keyboard/Keypad Page(0x07) plus special codes
  * http://www.usb.org/developers/devclass_docs/Hut1_12.pdf
  */
@@ -392,7 +392,7 @@ enum hid_keyboard_keypad_usage {
     KC_RALT,
     KC_RGUI,
 
-    /* NOTE: 0xE8-FF are used for internal special purpose */ 
+    /* NOTE: 0xE8-FF are used for internal special purpose */
 };
 
 /* Special keycodes */
@@ -422,7 +422,7 @@ enum internal_special_keycodes {
     KC_WWW_FORWARD,
     KC_WWW_STOP,
     KC_WWW_REFRESH,
-    KC_WWW_FAVORITES,   
+    KC_WWW_FAVORITES,
     KC_MEDIA_FAST_FORWARD,
     KC_MEDIA_REWIND,    /* 0xBC */
 

From a6d33e2c98b16fdd3c7eaccb9e8c941d4315d528 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Vlastimil=20Ov=C4=8D=C3=A1=C4=8D=C3=ADk?=
 <vovcacik@github.ovcacik.org>
Date: Sun, 28 Dec 2014 09:49:57 +0100
Subject: [PATCH 18/95] Added support for The Ghost Squid controller used for
 CM XT keyboard.

- initial commit
- created as clone of the kitten_paw subproject with pins adjusted for CM
  XT
---
 README.md                          |   3 +
 keyboard/ghost_squid/Makefile.lufa | 117 ++++++++++++++
 keyboard/ghost_squid/README.md     |  20 +++
 keyboard/ghost_squid/config.h      |  43 ++++++
 keyboard/ghost_squid/keymap.c      | 102 +++++++++++++
 keyboard/ghost_squid/keymap_ansi.h |  23 +++
 keyboard/ghost_squid/led.c         |  60 ++++++++
 keyboard/ghost_squid/matrix.c      | 237 +++++++++++++++++++++++++++++
 8 files changed, 605 insertions(+)
 create mode 100644 keyboard/ghost_squid/Makefile.lufa
 create mode 100644 keyboard/ghost_squid/README.md
 create mode 100644 keyboard/ghost_squid/config.h
 create mode 100644 keyboard/ghost_squid/keymap.c
 create mode 100644 keyboard/ghost_squid/keymap_ansi.h
 create mode 100644 keyboard/ghost_squid/led.c
 create mode 100644 keyboard/ghost_squid/matrix.c

diff --git a/README.md b/README.md
index a01de8c6f8..550f1267de 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 * [macway](keyboard/macway/)                - [Compact keyboard mod][GH_macway] [retired]
 * [KMAC](keyboard/kmac/)                    - Korean custom keyboard
 * [Lightsaber](keyboard/lightsaber/)        - Korean custom keyboard
+* [ghost_squid](keyboard/ghost_squid/)      - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt]
 
 [GH_macway]:    http://geekhack.org/showwiki.php?title=Island:11930
 [GH_hhkb]:      http://geekhack.org/showwiki.php?title=Island:12047
@@ -72,6 +73,8 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 [PC98]:         http://en.wikipedia.org/wiki/NEC_PC-9801
 [Sun]:          http://en.wikipedia.org/wiki/Sun-3
 [IIGS]:         http://en.wikipedia.org/wiki/Apple_IIGS
+[ghost_squid]:  http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid
+[cmxt]:         http://gaming.coolermaster.com/en/products/keyboards/quickfirext/
 
 
 
diff --git a/keyboard/ghost_squid/Makefile.lufa b/keyboard/ghost_squid/Makefile.lufa
new file mode 100644
index 0000000000..61893893a4
--- /dev/null
+++ b/keyboard/ghost_squid/Makefile.lufa
@@ -0,0 +1,117 @@
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device.
+#                Please customize your programmer settings(PROGRAM_CMD)
+#
+# make teensy = Download the hex file to the device, using teensy_loader_cli.
+#               (must have teensy_loader_cli installed).
+#
+# make dfu = Download the hex file to the device, using dfu-programmer (must
+#            have dfu-programmer installed).
+#
+# make flip = Download the hex file to the device, using Atmel FLIP (must
+#             have Atmel FLIP installed).
+#
+# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
+#               (must have dfu-programmer installed).
+#
+# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
+#                (must have Atmel FLIP installed).
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+# Target file name (without extension).
+TARGET = ghostsquid_lufa
+
+# Directory common source filess exist
+TOP_DIR = ../..
+
+# Directory keyboard dependent files exist
+TARGET_DIR = .
+
+# List C source files here. (C dependencies are automatically generated.)
+SRC =	keymap.c \
+	matrix.c \
+	led.c
+
+CONFIG_H = config.h
+
+# MCU name
+MCU = atmega32u2
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency in Hz. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+#
+#     This will be an integer division of F_USB below, as it is sourced by
+#     F_USB after it has run through any CPU prescalers. Note that this value
+#     does not *change* the processor frequency - it should merely be updated to
+#     reflect the processor speed set externally so that the code can use accurate
+#     software delays.
+F_CPU = 16000000
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+#     This will define a symbol, F_USB, in all source code files equal to the
+#     input clock frequency (before any prescaling is performed) in Hz. This value may
+#     differ from F_CPU if prescaling is used on the latter, and is required as the
+#     raw input clock is fed directly to the PLL sections of the AVR for high speed
+#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+#     at the end, this will be done automatically to create a 32-bit value in your
+#     source code.
+#
+#     If no clock division is performed on the input clock inside the AVR (via the
+#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+
+# Build Options
+#   comment out to disable the options.
+#
+#BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
+#CONSOLE_ENABLE = yes	# Console for debug(+400)
+COMMAND_ENABLE = yes    # Commands for debug and configuration
+#SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
+#NKRO_ENABLE = yes	# USB Nkey Rollover - not yet supported in LUFA
+
+
+# Boot Section Size in bytes
+#   Teensy halfKay   512
+#   Atmel DFU loader 4096
+#   LUFA bootloader  4096
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol/lufa.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
diff --git a/keyboard/ghost_squid/README.md b/keyboard/ghost_squid/README.md
new file mode 100644
index 0000000000..dda67e6ba1
--- /dev/null
+++ b/keyboard/ghost_squid/README.md
@@ -0,0 +1,20 @@
+The Ghost Squid controller
+==========================
+Custom controller for the Cooler Master QuickFire XT keyboard designed by bpiphany.
+
+*Note that this is not the official firmware*
+
+Build
+-----
+Move to this directory then just run `make` like:
+
+    $ make -f Makefile.lufa
+
+At the moment only the LUFA stack is supported.
+
+
+Bootloader
+---------
+To enter bootloader by hardware use a magnet above the controller before connecting the usb cable.
+
+It is still possible to use Boot Magic and Command (LSFT+RSFT+PAUS) to access the bootloader though.
diff --git a/keyboard/ghost_squid/config.h b/keyboard/ghost_squid/config.h
new file mode 100644
index 0000000000..54f03143c1
--- /dev/null
+++ b/keyboard/ghost_squid/config.h
@@ -0,0 +1,43 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xFEED // 0x2516 (original CM XT value)
+#define PRODUCT_ID      0x001A
+#define DEVICE_VER      0x0000
+#define MANUFACTURER    Cooler Master
+#define PRODUCT         Cooler Master QuickFire XT
+
+/* message strings */
+#define DESCRIPTION     t.m.k. keyboard firmware for Cooler Master QuickFire XT
+
+/* matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 18
+
+/* Set 0 if need no debouncing */
+#define DEBOUNCE    5
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+#endif
diff --git a/keyboard/ghost_squid/keymap.c b/keyboard/ghost_squid/keymap.c
new file mode 100644
index 0000000000..e9ad9efe1a
--- /dev/null
+++ b/keyboard/ghost_squid/keymap.c
@@ -0,0 +1,102 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/pgmspace.h>
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "debug.h"
+#include "keymap.h"
+
+/*
+ Matrix col/row mapping
+
+ ,----.    ,-------------------. ,-------------------. ,-------------------. ,--------------.
+ |06/6|    |07/4|08/4|08/2|08/6| |15/5|11/6|12/2|12/4| |14/4|14/5|14/6|14/0| |13/5|13/7|15/7|
+ `----'    `-------------------' `-------------------' `-------------------' `--------------'
+ ,-------------------------------------------------------------------------. ,--------------. ,-------------------.
+ |06/4|06/5|07/5|08/5|09/5|09/4|10/4|10/5|11/5|12/5|05/5|05/4|11/4|    14/2| |17/4|02/4|04/4| |16/1|17/1|04/1|04/0|
+ |-------------------------------------------------------------------------| |--------------| |-------------------|
+ |06/2  |06/7|07/7|08/7|09/7|09/2|10/2|10/7|11/7|12/7|05/7|05/2|11/2|  14/3| |16/4|02/5|04/5| |16/7|17/7|04/7|    |
+ |-------------------------------------------------------------------------| '--------------' |-------------- 02/7|
+ |02/7   |06/3|07/3|08/3|09/3|09/6|10/6|10/3|11/3|12/3|05/3|05/6|      14/1|                  |16/2|17/2|04/2|    |
+ |-------------------------------------------------------------------------|      ,----.      |-------------------|
+ |01/2     |06/1|07/1|08/1|09/1|09/0|10/0|10/1|11/1|12/1|05/0|         01/3|      |02/6|      |16/3|17/3|04/3|    |
+ |-------------------------------------------------------------------------| ,--------------. |-------------- 02/3|
+ |15/4|03/2|13/6|                 16/6                  |13/0|0/3|12/0|15/1| |02/0|16/0|17/0| | 17/6    |04/6|    |
+ `-------------------------------------------------------------------------' `--------------' `-------------------'
+*/
+
+#define KEYMAP( \
+    KG6,      KH4, KI4, KI2, KI6, KP5, KL6, KM2, KM4, KO4, KO5, KO6, KO0,   KN5, KN7, KP7,                       \
+    KG4, KG5, KH5, KI5, KJ5, KJ4, KK4, KK5, KL5, KM5, KF5, KF4, KL4, KO2,   KR4, KC4, KE4,   KQ1, KR1, KE1, KE0, \
+    KG2, KG7, KH7, KI7, KJ7, KJ2, KK2, KK7, KL7, KM7, KF7, KF2, KL2, KO3,   KQ4, KC5, KE5,   KQ7, KR7, KE7, KC7, \
+    KH2, KG3, KH3, KI3, KJ3, KJ6, KK6, KK3, KL3, KM3, KF3, KF6,      KO1,                    KQ2, KR2, KE2,      \
+    KB2, KH6, KG1, KH1, KI1, KJ1, KJ0, KK0, KK1, KL1, KM1, KF0,      KB3,        KC6,        KQ3, KR3, KE3, KC3, \
+    KP4, KD2, KN6,                KQ6,                KN0, KA3, KM0, KP1,   KC0, KQ0, KR0,   KR6,      KE6       \
+) { \
+/*            0         1         2         3         4         5         6         7   */  \
+/* A  0 */ {KC_NO,    KC_NO,    KC_NO,    KC_##KA3, KC_NO,    KC_NO,    KC_NO,    KC_NO   },\
+/* B  1 */ {KC_NO,    KC_NO,    KC_##KB2, KC_##KB3, KC_NO,    KC_NO,    KC_NO,    KC_NO   },\
+/* C  2 */ {KC_##KC0, KC_NO,    KC_NO,    KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7},\
+/* D  3 */ {KC_NO,    KC_NO,    KC_##KD2, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO   },\
+/* E  4 */ {KC_##KE0, KC_##KE1, KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_##KE7},\
+/* F  5 */ {KC_##KF0, KC_NO,    KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_##KF7},\
+/* G  6 */ {KC_NO,    KC_##KG1, KC_##KG2, KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7},\
+/* H  7 */ {KC_NO,    KC_##KH1, KC_##KH2, KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7},\
+/* I  8 */ {KC_NO,    KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7},\
+/* J  9 */ {KC_##KJ0, KC_##KJ1, KC_##KJ2, KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7},\
+/* K 10 */ {KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7},\
+/* L 11 */ {KC_NO,    KC_##KL1, KC_##KL2, KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7},\
+/* M 12 */ {KC_##KM0, KC_##KM1, KC_##KM2, KC_##KM3, KC_##KM4, KC_##KM5, KC_NO,    KC_##KM7},\
+/* N 13 */ {KC_##KN0, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##KN5, KC_##KN6, KC_##KN7},\
+/* O 14 */ {KC_##KO0, KC_##KO1, KC_##KO2, KC_##KO3, KC_##KO4, KC_##KO5, KC_##KO6, KC_NO   },\
+/* P 15 */ {KC_NO,    KC_##KP1, KC_NO,    KC_NO,    KC_##KP4, KC_##KP5, KC_NO,    KC_##KP7},\
+/* Q 16 */ {KC_##KQ0, KC_##KQ1, KC_##KQ2, KC_##KQ3, KC_##KQ4, KC_NO,    KC_##KQ6, KC_##KQ7},\
+/* R 17 */ {KC_##KR0, KC_##KR1, KC_##KR2, KC_##KR3, KC_##KR4, KC_NO,    KC_##KR6, KC_##KR7} \
+}
+
+#include "keymap_ansi.h"
+
+#define KEYMAPS_SIZE    (sizeof(keymaps) / sizeof(keymaps[0]))
+#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
+
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+    if (layer < KEYMAPS_SIZE) {
+        return pgm_read_byte(&keymaps[(layer)][(key.col)][(key.row)]);
+    } else {
+        return pgm_read_byte(&keymaps[0][(key.col)][(key.row)]);
+    }
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    action_t action;
+    if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
+        action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
+    } else {
+        action.code = ACTION_NO;
+    }
+    return action;
+}
diff --git a/keyboard/ghost_squid/keymap_ansi.h b/keyboard/ghost_squid/keymap_ansi.h
new file mode 100644
index 0000000000..ed1088baa9
--- /dev/null
+++ b/keyboard/ghost_squid/keymap_ansi.h
@@ -0,0 +1,23 @@
+
+static const uint8_t PROGMEM keymaps[][MATRIX_COLS][MATRIX_ROWS] = {
+    /* Layer 0: Standard ANSI layer */
+    KEYMAP(\
+         ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11,  F12,        PSCR,SLCK,PAUS,                         \
+         GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS, EQL,BSPC,   INS, HOME,PGUP,    NLCK,PSLS,PAST,PMNS, \
+         TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,   DEL, END, PGDN,    P7,  P8,  P9,  PPLS, \
+         CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,      ENT,                      P4,  P5,  P6,        \
+         LSFT,NUBS,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,        UP,           P1,  P2,  P3,  PENT, \
+         LCTL,LGUI,LALT,               SPC,                RALT,RGUI, FN0,RCTL,   LEFT,DOWN,RGHT,    P0,  PDOT),          \
+    /* Layer 1: Function layer */
+    KEYMAP(\
+         CALC,MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MSEL,MSTP,MPLY,MPRV,MNXT,TRNS,        WAKE, PWR,SLEP,                         \
+         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
+         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS,TRNS,TRNS, \
+         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,                      TRNS,TRNS,TRNS,      \
+         TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,        TRNS,         TRNS,TRNS,TRNS,TRNS, \
+         TRNS,TRNS,TRNS,               TRNS,               TRNS,TRNS,TRNS,TRNS,   TRNS,TRNS,TRNS,    TRNS,TRNS)
+};
+
+static const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(1)
+};
diff --git a/keyboard/ghost_squid/led.c b/keyboard/ghost_squid/led.c
new file mode 100644
index 0000000000..da5dbd7ae2
--- /dev/null
+++ b/keyboard/ghost_squid/led.c
@@ -0,0 +1,60 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <avr/io.h>
+#include "stdint.h"
+#include "led.h"
+
+/* LED pin configuration
+ *
+ * Scroll Lock  PB7
+ * CAPS         PC6
+ * NUMLOCK      PC5
+ *
+ */
+void led_set(uint8_t usb_led)
+{
+    DDRB |= (1<<7);
+    DDRC |= (1<<5) | (1<<6);
+
+    if (usb_led & (1<<USB_LED_CAPS_LOCK))
+    {
+        PORTC &= ~(1<<6);
+    }
+    else
+    {
+        PORTC |= (1<<6);
+    }
+
+    if (usb_led & (1<<USB_LED_NUM_LOCK))
+    {
+        PORTC &= ~(1<<5);
+    }
+    else
+    {
+        PORTC |= (1<<5);
+    }
+
+    if (usb_led & (1<<USB_LED_SCROLL_LOCK))
+    {
+        PORTB &= ~(1<<7);
+    }
+    else
+    {
+        PORTB |= (1<<7);
+    }
+}
diff --git a/keyboard/ghost_squid/matrix.c b/keyboard/ghost_squid/matrix.c
new file mode 100644
index 0000000000..d6a82ef759
--- /dev/null
+++ b/keyboard/ghost_squid/matrix.c
@@ -0,0 +1,237 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+
+#ifndef DEBOUNCE
+#   define DEBOUNCE 0
+#endif
+static uint8_t debouncing = DEBOUNCE;
+
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static uint8_t read_rows(void);
+static void init_rows(void);
+static void unselect_cols(void);
+static void select_col(uint8_t col);
+
+inline uint8_t matrix_rows(void)
+{
+    return MATRIX_ROWS;
+}
+
+inline uint8_t matrix_cols(void)
+{
+    return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+    unselect_cols();
+    init_rows();
+    for (uint8_t i=0; i < MATRIX_ROWS; i++)  {
+        matrix[i] = 0;
+        matrix_debouncing[i] = 0;
+    }
+}
+
+uint8_t matrix_scan(void)
+{
+    for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+        select_col(col);
+        _delay_us(3);
+        uint8_t rows = read_rows();
+        for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+            bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
+            bool curr_bit = rows & (1<<row);
+            if (prev_bit != curr_bit) {
+                matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
+                debouncing = DEBOUNCE;
+            }
+        }
+        unselect_cols();
+    }
+
+    if (debouncing) {
+        if (--debouncing) {
+            _delay_ms(1);
+        } else {
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+                matrix[i] = matrix_debouncing[i];
+            }
+        }
+    }
+
+    return 1;
+}
+
+bool matrix_is_modified(void)
+{
+    if (debouncing) return false;
+    return true;
+}
+
+inline bool matrix_is_on(uint8_t row, uint8_t col)
+{
+    return (matrix[row] & ((matrix_row_t)1<<col));
+}
+
+inline matrix_row_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void matrix_print(void)
+{
+    print("\nr/c 0123456789ABCDEF\n");
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+        xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
+    }
+}
+
+uint8_t matrix_key_count(void)
+{
+    uint8_t count = 0;
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        count += bitpop32(matrix[i]);
+    }
+    return count;
+}
+
+/* Row pin configuration
+ *
+ * row: 0    1    2    3    4    5    6    7
+ * pin: PB1  PC2  PB6  PB4  PB3  PB5  PB0  PB2
+ *
+ */
+static void init_rows(void)
+{
+    DDRC &= ~0b00000100;
+    DDRB &= ~0b01111111;
+    PORTC |= 0b00000100;
+    PORTB |= 0b01111111;
+}
+
+static uint8_t read_rows(void)
+{
+    return (PINB&(1<<1) ? 0 : (1<<0)) |
+           (PINC&(1<<2) ? 0 : (1<<1)) |
+           (PINB&(1<<6) ? 0 : (1<<2)) |
+           (PINB&(1<<4) ? 0 : (1<<3)) |
+           (PINB&(1<<3) ? 0 : (1<<4)) |
+           (PINB&(1<<5) ? 0 : (1<<5)) |
+           (PINB&(1<<0) ? 0 : (1<<6)) |
+           (PINB&(1<<2) ? 0 : (1<<7));
+}
+
+/*  These columns uses two 74HC42 4 to 10 bit demultiplexers (low active).
+ *
+ *   COL PD6 PD5 PD4 PD3 PD2 PD1
+ *   10   1   1   0   0   0   0
+ *   15   1   1   0   0   0   1
+ *    8   1   1   0   0   1   0
+ *   14   1   1   0   1   0   0
+ *    6   1   1   0   1   0   1
+ *   13   1   1   0   1   1   0
+ *   12   1   1   1   0   0   0
+ *    9   1   1   1   0   1   0
+ *   11   1   1   1   1   0   0
+ *    7   1   1   1   1   1   0
+ *
+ *   COL PD1 PD2 PD3 PD4 PD5 PD6
+ *    3   1   1   0   0   0   1
+ *    4   1   1   0   0   1   0
+ *   17   1   1   0   1   0   0
+ *   16   1   1   0   1   1   0
+ *    0   1   1   1   0   0   1
+ *    5   1   1   1   0   1   0
+ *    2   1   1   1   1   0   0
+ *    1   1   1   1   1   1   0
+ */
+static void unselect_cols(void)
+{
+    DDRD |= 0b01111111;
+    PORTD &= ~0b01111111;
+}
+
+static void select_col(uint8_t col)
+{
+    switch (col) {
+        case 0:
+            PORTD |= (1<<6) | (1<<3) | (1<<2) | (1<<1);
+            break;
+        case 1:
+            PORTD |= (1<<5) | (1<<4) | (1<<3) | (1<<2) | (1<<1);
+            break;
+        case 2:
+            PORTD |= (1<<4) | (1<<3) | (1<<2) | (1<<1);
+            break;
+        case 3:
+            PORTD |= (1<<6) | (1<<2) | (1<<1);
+            break;
+        case 4:
+            PORTD |= (1<<5) | (1<<2) | (1<<1);
+            break;
+        case 5:
+            PORTD |= (1<<5) | (1<<3) | (1<<2) | (1<<1);
+            break;
+        case 6:
+            PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<1);
+            break;
+        case 7:
+            PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3) | (1<<2);
+            break;
+        case 8:
+            PORTD |= (1<<6) | (1<<5) | (1<<2);
+            break;
+        case 9:
+            PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<2);
+            break;
+        case 10:
+            PORTD |= (1<<6) | (1<<5);
+            break;
+        case 11:
+            PORTD |= (1<<6) | (1<<5) | (1<<4) | (1<<3);
+            break;
+        case 12:
+            PORTD |= (1<<6) | (1<<5) | (1<<4);
+            break;
+        case 13:
+            PORTD |= (1<<6) | (1<<5) | (1<<3) | (1<<2);
+            break;
+        case 14:
+            PORTD |= (1<<6) | (1<<5) | (1<<3);
+            break;
+        case 15:
+            PORTD |= (1<<6) | (1<<5) | (1<<1);
+            break;
+        case 16:
+            PORTD |= (1<<5) | (1<<4) | (1<<2) | (1<<1);
+            break;
+        case 17:
+            PORTD |= (1<<4) | (1<<2) | (1<<1);
+            break;
+    }
+}

From 2e17aa2d6006ce42889d489847e504575f5d0995 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Tue, 30 Dec 2014 13:52:53 +0900
Subject: [PATCH 19/95] usb_usb: update README

---
 converter/usb_usb/README | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/converter/usb_usb/README b/converter/usb_usb/README
index 69caabb278..30d5deb1e5 100644
--- a/converter/usb_usb/README
+++ b/converter/usb_usb/README
@@ -7,7 +7,19 @@ Arduino Leonardo
     http://arduino.cc/en/Main/ArduinoBoardLeonardo 
 
 Circuit@Home USB Host Shield 2.0
-    http://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino
+    https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-2-0-for-arduino-assembled/
+
+Buying Arduino Leonardo and USB Host Shield 2.0(from Circuit@home) will be the easiest way, you won't need even soldering iron.
+Arduino's Shield will also work well but I think Sparkfun's needs to be modified.
+
+    http://arduino.cc/en/Main/ArduinoUSBHostShield
+    https://www.sparkfun.com/products/9947
+
+Also Pro Micro 3.3V(not Mini) or Teensy with mini host shield will work with some fixes on signal/power routing.
+    https://www.circuitsathome.com/products-page/arduino-shields/usb-host-shield-for-arduino-pro-mini
+    https://www.sparkfun.com/products/12587
+    https://www.pjrc.com/teensy/td_libs_USBHostShield.html
+
 
 
 Build firmware
@@ -32,6 +44,8 @@ Limitation
 Only supports 'HID Boot protocol'.
 Not support keyboard LED yet.
 
+Note that the converter can host only USB "boot protocol" keyboard(6KRO) and not NKRO, it is possible to support NKRO keyboard but you will need to write HID report parser for that. Every NKRO keyboard can have different HID report and it is difficult to support all kind of NKRO keyboards in the market.
+
 
 
 Update

From 22d99f26af757c0bedb31ba3f63d793e4b2d4ca3 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Thu, 1 Jan 2015 12:17:11 +0900
Subject: [PATCH 20/95] Fix modifier stuck of Lock command(#127)

---
 common/command.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/command.c b/common/command.c
index 971ef7f0af..1a507e3a46 100644
--- a/common/command.c
+++ b/common/command.c
@@ -194,6 +194,7 @@ static bool command_common(uint8_t code)
         case KC_CAPSLOCK:
             if (host_get_driver()) {
                 host_driver = host_get_driver();
+                clear_keyboard();
                 host_set_driver(0);
                 print("Locked.\n");
             } else {

From 06527bde4f873ffc6eb8e359fb3b150e880b89ba Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Sat, 3 Jan 2015 12:02:48 +0900
Subject: [PATCH 21/95] bluefruit, pjrc: Update protocols for new API

---
 converter/terminal_bluefruit/Makefile | 16 +---------------
 converter/terminal_usb/Makefile       | 15 ---------------
 protocol/bluefruit/bluefruit.c        |  4 ++--
 protocol/bluefruit/main.c             |  2 +-
 protocol/pjrc/main.c                  |  3 ++-
 protocol/pjrc/usb_keyboard.c          |  2 +-
 6 files changed, 7 insertions(+), 35 deletions(-)

diff --git a/converter/terminal_bluefruit/Makefile b/converter/terminal_bluefruit/Makefile
index 83d68fc252..28b7397bae 100644
--- a/converter/terminal_bluefruit/Makefile
+++ b/converter/terminal_bluefruit/Makefile
@@ -83,21 +83,6 @@ COMMAND_ENABLE = yes    # Commands for debug and configuration
 PS2_USE_INT = yes	# uses external interrupt for falling edge of PS/2 clock pin
 #PS2_USE_BUSYWAIT = yes	# uses primitive reference code
 
-ifdef PS2_USE_USART
-    SRC += protocol/ps2_usart.c
-    OPT_DEFS += -DPS2_USE_USART
-endif
-
-ifdef PS2_USE_INT
-    SRC += protocol/ps2.c
-    OPT_DEFS += -DPS2_USE_INT
-endif
-
-ifdef PS2_USE_BUSYWAIT
-    SRC += protocol/ps2.c
-    OPT_DEFS += -DPS2_USE_BUSYWAIT
-endif
-
 #---------------- Programming Options --------------------------
 PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
 
@@ -107,6 +92,7 @@ VPATH += $(TARGET_DIR)
 VPATH += $(TOP_DIR)
 
 
+include $(TOP_DIR)/protocol.mk
 include $(TOP_DIR)/protocol/bluefruit.mk
 include $(TOP_DIR)/protocol.mk
 include $(TOP_DIR)/common.mk
diff --git a/converter/terminal_usb/Makefile b/converter/terminal_usb/Makefile
index 6154d86826..16df638b94 100644
--- a/converter/terminal_usb/Makefile
+++ b/converter/terminal_usb/Makefile
@@ -82,21 +82,6 @@ PS2_USE_USART = yes	# uses hardware USART engine for PS/2 signal receive(recomen
 #PS2_USE_INT = yes	# uses external interrupt for falling edge of PS/2 clock pin
 #PS2_USE_BUSYWAIT = yes	# uses primitive reference code
 
-ifdef PS2_USE_USART
-    SRC += protocol/ps2_usart.c
-    OPT_DEFS += -DPS2_USE_USART
-endif
-
-ifdef PS2_USE_INT
-    SRC += protocol/ps2.c
-    OPT_DEFS += -DPS2_USE_INT
-endif
-
-ifdef PS2_USE_BUSYWAIT
-    SRC += protocol/ps2.c
-    OPT_DEFS += -DPS2_USE_BUSYWAIT
-endif
-
 
 #---------------- Programming Options --------------------------
 PROGRAM_CMD = teensy_loader_cli -mmcu=$(MCU) -w -v $(TARGET).hex
diff --git a/protocol/bluefruit/bluefruit.c b/protocol/bluefruit/bluefruit.c
index f991e4d04e..cf26b83dff 100644
--- a/protocol/bluefruit/bluefruit.c
+++ b/protocol/bluefruit/bluefruit.c
@@ -36,7 +36,7 @@ static void bluefruit_serial_send(uint8_t);
 void bluefruit_keyboard_print_report(report_keyboard_t *report)
 {
     if (!debug_keyboard) return;
-    dprintf("keys: "); for (int i = 0; i < REPORT_KEYS; i++) { debug_hex8(report->keys[i]); dprintf(" "); }
+    dprintf("keys: "); for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { debug_hex8(report->keys[i]); dprintf(" "); }
     dprintf(" mods: "); debug_hex8(report->mods);
     dprintf(" reserved: "); debug_hex8(report->reserved); 
     dprintf("\n");
@@ -99,7 +99,7 @@ static void send_keyboard(report_keyboard_t *report)
     bluefruit_trace_header();
 #endif
     bluefruit_serial_send(0xFD);
-    for (uint8_t i = 0; i < REPORT_SIZE; i++) {
+    for (uint8_t i = 0; i < KEYBOARD_REPORT_SIZE; i++) {
         bluefruit_serial_send(report->raw[i]);
     }
 #ifdef BLUEFRUIT_TRACE_SERIAL   
diff --git a/protocol/bluefruit/main.c b/protocol/bluefruit/main.c
index 871062ab11..094fdb3662 100644
--- a/protocol/bluefruit/main.c
+++ b/protocol/bluefruit/main.c
@@ -104,7 +104,7 @@ int main(void)
         dprintf("Starting main loop");
         while (1) {
             while (suspend) {
-                suspend_power_down();
+                suspend_power_down(WDTO_120MS);
                 if (remote_wakeup && suspend_wakeup_condition()) {
                     usb_remote_wakeup();
                 }
diff --git a/protocol/pjrc/main.c b/protocol/pjrc/main.c
index 1ef87f8651..4f87a17364 100644
--- a/protocol/pjrc/main.c
+++ b/protocol/pjrc/main.c
@@ -24,6 +24,7 @@
 #include <stdbool.h>
 #include <avr/io.h>
 #include <avr/interrupt.h>
+#include <avr/wdt.h>
 #include <util/delay.h>
 #include "keyboard.h"
 #include "usb.h"
@@ -60,7 +61,7 @@ int main(void)
 #endif
     while (1) {
         while (suspend) {
-            suspend_power_down();
+            suspend_power_down(WDTO_120MS);
             if (remote_wakeup && suspend_wakeup_condition()) {
                 usb_remote_wakeup();
             }
diff --git a/protocol/pjrc/usb_keyboard.c b/protocol/pjrc/usb_keyboard.c
index 758a4edc6c..4b87b5d7b5 100644
--- a/protocol/pjrc/usb_keyboard.c
+++ b/protocol/pjrc/usb_keyboard.c
@@ -74,7 +74,7 @@ void usb_keyboard_print_report(report_keyboard_t *report)
 {
     if (!debug_keyboard) return;
     print("keys: ");
-    for (int i = 0; i < REPORT_KEYS; i++) { phex(report->keys[i]); print(" "); }
+    for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { phex(report->keys[i]); print(" "); }
     print(" mods: "); phex(report->mods); print("\n");
 }
 

From 02a9f8a906f67d252d8608606065b44ad94316b0 Mon Sep 17 00:00:00 2001
From: Oleg Kostyuk <cub.uanic@gmail.com>
Date: Sat, 3 Jan 2015 15:10:45 +0200
Subject: [PATCH 22/95] Update other_projects.md - added TMK/Ergodox

---
 doc/other_projects.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/doc/other_projects.md b/doc/other_projects.md
index ce24e0ab5c..bf980b0a9e 100644
--- a/doc/other_projects.md
+++ b/doc/other_projects.md
@@ -29,6 +29,7 @@ Other Keyboard Firmware Projects
 ## ErgoDox[Ergo][Split][USB][AVR]
 - <http://geekhack.org/index.php?topic=22780.0>
 - <https://github.com/benblazak/ergodox-firmware>
+- <https://github.com/cub-uanic/tmk_keyboard>
 
 ## Suka's keyboard collection[Ergo][Split][3DPrinting][USB][AVR]
 - <http://deskthority.net/workshop-f7/my-diy-keyboard-collection-or-how-i-became-a-kb-geek-t2534.html>

From 8f1e311cd7624d765901c69e61837db33a51928b Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Fri, 12 Dec 2014 14:05:05 +0900
Subject: [PATCH 23/95] Ad hoc fix of print and debug for mbed

---
 common/print.c      | 12 ++++++++++--
 tool/mbed/common.mk |  2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/common/print.c b/common/print.c
index c13a29f317..ca94e1e5d6 100644
--- a/common/print.c
+++ b/common/print.c
@@ -22,13 +22,14 @@
  * THE SOFTWARE.
  */
 
-#include <avr/io.h>
-#include <avr/pgmspace.h>
+#include <stdint.h>
 #include "print.h"
 
 
 #ifndef NO_PRINT
 
+#if defined(__AVR__)
+
 #define sendchar(c)    xputc(c)
 
 
@@ -37,4 +38,11 @@ void print_set_sendchar(int8_t (*sendchar_func)(uint8_t))
     xdev_out(sendchar_func);
 }
 
+#elif defined(__arm__)
+
+// TODO
+//void print_set_sendchar(int8_t (*sendchar_func)(uint8_t)) { }
+
+#endif
+
 #endif
diff --git a/tool/mbed/common.mk b/tool/mbed/common.mk
index 93a927a3e8..403da9ac8d 100644
--- a/tool/mbed/common.mk
+++ b/tool/mbed/common.mk
@@ -7,6 +7,8 @@ OBJECTS += \
 	$(OBJDIR)/common/host.o \
 	$(OBJDIR)/common/keymap.o \
 	$(OBJDIR)/common/keyboard.o \
+	$(OBJDIR)/common/print.o \
+	$(OBJDIR)/common/debug.o \
 	$(OBJDIR)/common/util.o \
 	$(OBJDIR)/common/mbed/suspend.o \
 	$(OBJDIR)/common/mbed/timer.o \

From 75a59e4d12a13efc03cacd85b394fcf1204aad76 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Sun, 14 Dec 2014 13:59:22 +0900
Subject: [PATCH 24/95] Update makefiles to mbed-sdk 14666bb

---
 converter/ps2_usb/Makefile.mbed |   2 +
 tool/mbed/gcc.mk                |  37 +++++----
 tool/mbed/lpc11u35_501.mk       |  49 ++++++++++++
 tool/mbed/mbed.mk               | 132 ++++++++++++++------------------
 4 files changed, 130 insertions(+), 90 deletions(-)
 create mode 100644 tool/mbed/lpc11u35_501.mk

diff --git a/converter/ps2_usb/Makefile.mbed b/converter/ps2_usb/Makefile.mbed
index 631f270f75..ff8a0de7a4 100644
--- a/converter/ps2_usb/Makefile.mbed
+++ b/converter/ps2_usb/Makefile.mbed
@@ -39,6 +39,8 @@ LIBRARIES =
 MOUSEKEY_ENABLE = yes
 
 
+#include $(TMK_DIR)/tool/mbed/mk20d50m.mk
+include $(TMK_DIR)/tool/mbed/lpc11u35_501.mk
 include $(TMK_DIR)/tool/mbed/mbed.mk
 include $(TMK_DIR)/tool/mbed/common.mk
 include $(TMK_DIR)/tool/mbed/gcc.mk
diff --git a/tool/mbed/gcc.mk b/tool/mbed/gcc.mk
index 032f7c6cae..b8c7336b45 100644
--- a/tool/mbed/gcc.mk
+++ b/tool/mbed/gcc.mk
@@ -1,4 +1,6 @@
-############################################################################### 
+# based on Makefile exported form mbed.org
+# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
+
 GCC_BIN = 
 AS      = $(GCC_BIN)arm-none-eabi-as
 CC      = $(GCC_BIN)arm-none-eabi-gcc
@@ -9,13 +11,21 @@ OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump
 SIZE 	= $(GCC_BIN)arm-none-eabi-size
 CHKSUM  = $(TMK_DIR)/tool/mbed/lpc-vector-checksum
 
-CPU = -mcpu=cortex-m0 -mthumb
-
-CC_FLAGS += $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections
+CC_FLAGS += \
+	$(CPU) \
+	-c \
+	-g \
+	-fno-common \
+	-fmessage-length=0 \
+	-Wall \
+	-fno-exceptions \
+	-ffunction-sections \
+	-fdata-sections \
+	-fomit-frame-pointer
 CC_FLAGS += -MMD -MP
-CC_SYMBOLS = -DTARGET_LPC11U35_401 -DTARGET_M0 -DTARGET_NXP -DTARGET_LPC11UXX -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0 -DARM_MATH_CM0 -DMBED_BUILD_TIMESTAMP=1399108688.49 -D__MBED__=1 
 
-LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs
+LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs
+#LD_FLAGS += -u _printf_float -u _scanf_float
 LD_FLAGS += -Wl,-Map=$(OBJDIR)/$(PROJECT).map,--cref
 LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
 
@@ -25,7 +35,7 @@ else
   CC_FLAGS += -DNDEBUG -Os
 endif
 
-all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex size
+all: $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).hex
 
 clean:
 	rm -f $(OBJDIR)/$(PROJECT).bin $(OBJDIR)/$(PROJECT).elf $(OBJDIR)/$(PROJECT).hex $(OBJDIR)/$(PROJECT).map $(OBJDIR)/$(PROJECT).lst $(OBJECTS) $(DEPS)
@@ -41,22 +51,21 @@ $(OBJDIR)/%.o: %.c
 
 $(OBJDIR)/%.o: %.cpp
 	mkdir -p $(@D)
-	$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 $(INCLUDE_PATHS) -o $@ $<
+	$(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $<
 
 
 $(OBJDIR)/$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS)
 	$(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS)
-	@echo ""
-	@echo "*****"
-	@echo "***** You must modify vector checksum value in *.bin and *.hex files."
-	@echo "*****"
-	@echo ""
+	$(SIZE) $@
 
 $(OBJDIR)/$(PROJECT).bin: $(OBJDIR)/$(PROJECT).elf
 	@$(OBJCOPY) -O binary $< $@
-	@echo "Writing vector checksum value into $@ ..."
+ifneq (,$(findstring TARGET_NXP,$(CC_SYMBOLS)))
+	@echo
+	@echo "For NXP writing vector checksum value into $@ ..."
 	@$(CHKSUM) $@
 	@echo
+endif
 
 $(OBJDIR)/$(PROJECT).hex: $(OBJDIR)/$(PROJECT).elf
 	@$(OBJCOPY) -O ihex $< $@
diff --git a/tool/mbed/lpc11u35_501.mk b/tool/mbed/lpc11u35_501.mk
new file mode 100644
index 0000000000..af1aad797f
--- /dev/null
+++ b/tool/mbed/lpc11u35_501.mk
@@ -0,0 +1,49 @@
+# based on Makefile exported form mbed.org
+# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
+
+CPU = -mcpu=cortex-m0 -mthumb
+
+CC_SYMBOLS = \
+	-DTARGET_LPC11U35_501 \
+	-DTARGET_M0 \
+	-DTARGET_CORTEX_M \
+	-DTARGET_NXP \
+	-DTARGET_LPC11UXX \
+	-DTARGET_MCU_LPC11U35_501 \
+	-DTOOLCHAIN_GCC_ARM \
+	-DTOOLCHAIN_GCC \
+	-D__CORTEX_M0 \
+	-DARM_MATH_CM0 \
+	-D__MBED__=1
+
+OBJECTS += \
+	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/startup_LPC11xx.o \
+	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/cmsis_nvic.o \
+	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/system_LPC11Uxx.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501/PeripheralPins.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_irq_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/port_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/sleep.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/us_ticker.o
+
+INCLUDE_PATHS += \
+	-I$(MBED_DIR)/libraries/mbed/targets \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_501 \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501 \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501/TARGET_LPC11U35_501 \
+
+LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_501/LPC11U35.ld
diff --git a/tool/mbed/mbed.mk b/tool/mbed/mbed.mk
index 0f12ee2af3..242d78794f 100644
--- a/tool/mbed/mbed.mk
+++ b/tool/mbed/mbed.mk
@@ -1,99 +1,79 @@
+# based on Makefile exported form mbed.org
+# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
+
 OBJECTS += \
-	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/startup_LPC11xx.o \
-	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/cmsis_nvic.o \
-	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/system_LPC11Uxx.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/port_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/spi_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/analogin_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/gpio_irq_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/serial_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/i2c_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pwmout_api.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/sleep.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/pinmap.o \
-	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/us_ticker.o \
-	$(OBJDIR)/libraries/mbed/common/board.o \
-	$(OBJDIR)/libraries/mbed/common/mbed_interface.o \
-	$(OBJDIR)/libraries/mbed/common/exit.o \
-	$(OBJDIR)/libraries/mbed/common/rtc_time.o \
-	$(OBJDIR)/libraries/mbed/common/us_ticker_api.o \
-	$(OBJDIR)/libraries/mbed/common/pinmap_common.o \
-	$(OBJDIR)/libraries/mbed/common/error.o \
-	$(OBJDIR)/libraries/mbed/common/gpio.o \
-	$(OBJDIR)/libraries/mbed/common/semihost_api.o \
-	$(OBJDIR)/libraries/mbed/common/wait_api.o \
-	$(OBJDIR)/libraries/mbed/common/RawSerial.o \
-	$(OBJDIR)/libraries/mbed/common/Ticker.o \
-	$(OBJDIR)/libraries/mbed/common/FilePath.o \
-	$(OBJDIR)/libraries/mbed/common/I2C.o \
-	$(OBJDIR)/libraries/mbed/common/FileBase.o \
-	$(OBJDIR)/libraries/mbed/common/retarget.o \
-	$(OBJDIR)/libraries/mbed/common/Serial.o \
-	$(OBJDIR)/libraries/mbed/common/Stream.o \
-	$(OBJDIR)/libraries/mbed/common/FileSystemLike.o \
-	$(OBJDIR)/libraries/mbed/common/CallChain.o \
-	$(OBJDIR)/libraries/mbed/common/InterruptManager.o \
-	$(OBJDIR)/libraries/mbed/common/SerialBase.o \
-	$(OBJDIR)/libraries/mbed/common/BusInOut.o \
-	$(OBJDIR)/libraries/mbed/common/SPISlave.o \
-	$(OBJDIR)/libraries/mbed/common/I2CSlave.o \
-	$(OBJDIR)/libraries/mbed/common/FunctionPointer.o \
-	$(OBJDIR)/libraries/mbed/common/Timer.o \
-	$(OBJDIR)/libraries/mbed/common/SPI.o \
-	$(OBJDIR)/libraries/mbed/common/Timeout.o \
-	$(OBJDIR)/libraries/mbed/common/Ethernet.o \
-	$(OBJDIR)/libraries/mbed/common/TimerEvent.o \
-	$(OBJDIR)/libraries/mbed/common/CAN.o \
-	$(OBJDIR)/libraries/mbed/common/BusOut.o \
-	$(OBJDIR)/libraries/mbed/common/FileLike.o \
 	$(OBJDIR)/libraries/mbed/common/BusIn.o \
+	$(OBJDIR)/libraries/mbed/common/BusInOut.o \
+	$(OBJDIR)/libraries/mbed/common/BusOut.o \
+	$(OBJDIR)/libraries/mbed/common/CAN.o \
+	$(OBJDIR)/libraries/mbed/common/CallChain.o \
+	$(OBJDIR)/libraries/mbed/common/Ethernet.o \
+	$(OBJDIR)/libraries/mbed/common/FileBase.o \
+	$(OBJDIR)/libraries/mbed/common/FileLike.o \
+	$(OBJDIR)/libraries/mbed/common/FilePath.o \
+	$(OBJDIR)/libraries/mbed/common/FileSystemLike.o \
+	$(OBJDIR)/libraries/mbed/common/FunctionPointer.o \
+	$(OBJDIR)/libraries/mbed/common/I2C.o \
+	$(OBJDIR)/libraries/mbed/common/I2CSlave.o \
 	$(OBJDIR)/libraries/mbed/common/InterruptIn.o \
+	$(OBJDIR)/libraries/mbed/common/InterruptManager.o \
 	$(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \
+	$(OBJDIR)/libraries/mbed/common/RawSerial.o \
+	$(OBJDIR)/libraries/mbed/common/SPI.o \
+	$(OBJDIR)/libraries/mbed/common/SPISlave.o \
+	$(OBJDIR)/libraries/mbed/common/Serial.o \
+	$(OBJDIR)/libraries/mbed/common/SerialBase.o \
+	$(OBJDIR)/libraries/mbed/common/Stream.o \
+	$(OBJDIR)/libraries/mbed/common/Ticker.o \
+	$(OBJDIR)/libraries/mbed/common/Timeout.o \
+	$(OBJDIR)/libraries/mbed/common/Timer.o \
+	$(OBJDIR)/libraries/mbed/common/TimerEvent.o \
+	$(OBJDIR)/libraries/mbed/common/assert.o \
+	$(OBJDIR)/libraries/mbed/common/board.o \
+	$(OBJDIR)/libraries/mbed/common/error.o \
+	$(OBJDIR)/libraries/mbed/common/exit.o \
+	$(OBJDIR)/libraries/mbed/common/gpio.o \
+	$(OBJDIR)/libraries/mbed/common/mbed_interface.o \
+	$(OBJDIR)/libraries/mbed/common/pinmap_common.o \
+	$(OBJDIR)/libraries/mbed/common/retarget.o \
+	$(OBJDIR)/libraries/mbed/common/rtc_time.o \
+	$(OBJDIR)/libraries/mbed/common/semihost_api.o \
+	$(OBJDIR)/libraries/mbed/common/us_ticker_api.o \
+	$(OBJDIR)/libraries/mbed/common/wait_api.o \
+	$(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \
 	$(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \
+	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \
+	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
 	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \
 	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
+	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.o \
 	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \
-	$(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \
-	$(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o \
-	$(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \
+	$(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \
+	$(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \
+	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \
+	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \
+	$(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o \
 	$(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \
-	$(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o
+	$(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \
+	$(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o
 
 INCLUDE_PATHS += \
-	-I$(MBED_DIR)/libraries/mbed/targets \
-	-I$(MBED_DIR)/libraries/mbed/targets/hal \
-	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP \
-	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX \
-	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_LPC11U35_401 \
-	-I$(MBED_DIR)/libraries/mbed/targets/cmsis \
-	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP \
-	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX \
-	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM \
-	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401 \
 	-I$(MBED_DIR)/libraries/mbed \
-	-I$(MBED_DIR)/libraries/mbed/hal \
 	-I$(MBED_DIR)/libraries/mbed/api \
 	-I$(MBED_DIR)/libraries/mbed/common \
+	-I$(MBED_DIR)/libraries/mbed/hal \
 	-I$(MBED_DIR)/libraries/USBDevice \
-	-I$(MBED_DIR)/libraries/USBDevice/USBHID \
-	-I$(MBED_DIR)/libraries/USBDevice/USBDevice \
 	-I$(MBED_DIR)/libraries/USBDevice/USBAudio \
-	-I$(MBED_DIR)/libraries/USBDevice/USBSerial \
+	-I$(MBED_DIR)/libraries/USBDevice/USBDevice \
+	-I$(MBED_DIR)/libraries/USBDevice/USBHID \
+	-I$(MBED_DIR)/libraries/USBDevice/USBMIDI \
 	-I$(MBED_DIR)/libraries/USBDevice/USBMSD \
-	-I$(MBED_DIR)/libraries/USBDevice/USBMIDI
+	-I$(MBED_DIR)/libraries/USBDevice/USBSerial
 
+# TMK mbed protocol
 OBJECTS += \
 	$(OBJDIR)/protocol/mbed/mbed_driver.o \
-	$(OBJDIR)/protocol/mbed/HIDKeyboard.o \
+	$(OBJDIR)/protocol/mbed/HIDKeyboard.o
 
 INCLUDE_PATHS += \
 	-I$(TMK_DIR)/protocol/mbed
-
-LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_401/LPC11U35.ld

From 541913029150d57e83396293d35807a16d3755e8 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Sun, 14 Dec 2014 15:52:33 +0900
Subject: [PATCH 25/95] Fix ps2 protocol build using ps2_io.h

---
 protocol/ps2_interrupt.c | 1 +
 protocol/ps2_usart.c     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/protocol/ps2_interrupt.c b/protocol/ps2_interrupt.c
index 259d254007..8114442bac 100644
--- a/protocol/ps2_interrupt.c
+++ b/protocol/ps2_interrupt.c
@@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include <avr/interrupt.h>
 #include <util/delay.h>
 #include "ps2.h"
+#include "ps2_io.h"
 #include "print.h"
 
 
diff --git a/protocol/ps2_usart.c b/protocol/ps2_usart.c
index c2d9d0a208..6936ca7b88 100644
--- a/protocol/ps2_usart.c
+++ b/protocol/ps2_usart.c
@@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #include <avr/interrupt.h>
 #include <util/delay.h>
 #include "ps2.h"
+#include "ps2_io.h"
 #include "print.h"
 
 

From e259a722e7e8abcb97606b6cfbcce99667a66277 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Fri, 2 Jan 2015 21:16:40 +0900
Subject: [PATCH 26/95] Add keyboard/infinity

---
 keyboard/infinity/MEMO.txt    | 398 ++++++++++++++++++++++++++++++++++
 keyboard/infinity/Makefile    |  30 +++
 keyboard/infinity/config.h    |  39 ++++
 keyboard/infinity/infinity.ld | 156 +++++++++++++
 keyboard/infinity/main.cpp    |  29 +++
 tool/mbed/lpc11u35_501.mk     |   2 +-
 tool/mbed/mbed.mk             | 114 +++++-----
 tool/mbed/mk20d50m.mk         |  45 ++++
 8 files changed, 757 insertions(+), 56 deletions(-)
 create mode 100644 keyboard/infinity/MEMO.txt
 create mode 100644 keyboard/infinity/Makefile
 create mode 100644 keyboard/infinity/config.h
 create mode 100644 keyboard/infinity/infinity.ld
 create mode 100644 keyboard/infinity/main.cpp
 create mode 100644 tool/mbed/mk20d50m.mk

diff --git a/keyboard/infinity/MEMO.txt b/keyboard/infinity/MEMO.txt
new file mode 100644
index 0000000000..ca0da937d7
--- /dev/null
+++ b/keyboard/infinity/MEMO.txt
@@ -0,0 +1,398 @@
+mbed patch for Infinity
+-----------------------
+Without ld script patch vector table it doesn't place vector table in binary file.
+And clock setting is changed as Infinity uses internal oscillator instead of exteranl crystal.
+
+diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
+index 600751c..55c3393 100644
+--- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
++++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
+@@ -43,7 +43,7 @@ SECTIONS
+     .isr_vector :
+     {
+         __vector_table = .;
+-        KEEP(*(.vector_table))
++        KEEP(*(.isr_vector))
+         *(.text.Reset_Handler)
+         *(.text.System_Init)
+          . = ALIGN(4);
+diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
+index 393d1f0..b78b71a 100644
+--- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
++++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
+@@ -44,7 +44,7 @@
+
+ #define DISABLE_WDOG    1
+
+-#define CLOCK_SETUP     1
++#define CLOCK_SETUP     0
+ /* Predefined clock setups
+    0 ... Multipurpose Clock Generator (MCG) in FLL Engaged Internal (FEI) mode
+          Reference clock source for MCG module is the slow internal clock source 32.768kHz
+
+
+
+CMSIS/mbed HAL
+==============
+http://developer.mbed.org/users/MACRUM/notebook/mbed-library-internals/
+
+api/        mbed API
+├── AnalogIn.h
+├── AnalogOut.h
+├── BusIn.h
+├── BusInOut.h
+├── BusOut.h
+├── CallChain.h
+├── CAN.h
+├── can_helper.h
+├── DigitalIn.h
+├── DigitalInOut.h
+├── DigitalOut.h
+├── DirHandle.h
+├── Ethernet.h
+├── FileBase.h
+├── FileHandle.h
+├── FileLike.h
+├── FilePath.h
+├── FileSystemLike.h
+├── FunctionPointer.h
+├── I2C.h
+├── I2CSlave.h
+├── InterruptIn.h
+├── InterruptManager.h
+├── LocalFileSystem.h
+├── mbed_assert.h
+├── mbed_debug.h
+├── mbed_error.h
+├── mbed.h
+├── mbed_interface.h
+├── platform.h
+├── PortIn.h
+├── PortInOut.h
+├── PortOut.h
+├── PwmOut.h
+├── RawSerial.h
+├── rtc_time.h
+├── semihost_api.h
+├── SerialBase.h
+├── Serial.h
+├── SPI.h
+├── SPISlave.h
+├── Stream.h
+├── Ticker.h
+├── Timeout.h
+├── TimerEvent.h
+├── Timer.h
+├── toolchain.h
+└── wait_api.h
+
+common/     mbed API implementation
+
+hal/        mbed HAL implementation interface
+├── analogin_api.h
+├── analogout_api.h
+├── can_api.h
+├── ethernet_api.h
+├── gpio_api.h
+├── gpio_irq_api.h
+├── i2c_api.h
+├── pinmap.h
+├── port_api.h
+├── pwmout_api.h
+├── rtc_api.h
+├── serial_api.h
+├── sleep_api.h
+├── spi_api.h
+└── us_ticker_api.h
+
+targets/hal/TARGET_<vendor>/TARGET_<board>/
+    mbed HAL implementation
+
+targets/cmsis/      CMSIS interface
+    core_caInstr.h
+    core_ca9.h
+    core_cmFunc.h
+    core_caFunc.h
+    core_cmInstr.h
+    core_cm4_simd.h
+    core_ca_mmu.h
+    core_cm0.h
+    core_cm0plus.h
+    core_cm3.h
+    core_cm4.h
+
+targets/cmsis/TARGET_<vendor>/TARGET_<chip>/
+    <chip>.h
+    system_<chip>.[ch]
+    cmsis.h 
+    cmsis_nvic.[ch]
+
+targets/cmsis/TARGET_<vendor>/TARGET_<chip>/TOOLSCHAIN_<tool>/
+    startup_<chip>.s
+    linker-script
+
+
+
+Infinity
+========
+Massdrop Infinity Keyboard:
+https://www.massdrop.com/buy/infinity-keyboard-kit
+
+Freescale MK20DX128VLF5 48-QFP:
+http://cache.freescale.com/files/32bit/doc/data_sheet/K20P48M50SF0.pdf
+
+kiibohd controller(MD1):
+https://github.com/kiibohd/controller
+
+DFU bootloader:
+https://github.com/kiibohd/controller/tree/master/Bootloader
+
+Program with bootloader:
+    $ dfu-util -D kiibohd.dfu.bin
+
+Pinout:
+https://github.com/kiibohd/controller/blob/master/Scan/MD1/pinout
+
+
+
+Pin Usage
+=========
+
+mk20dx128vlf5
+
+ ----
+|Keys|
+ ----
+
+* Strobe (Columns)
+
+PTB0
+PTB1
+PTB2
+PTB3
+PTB16
+PTB17
+PTC4
+PTC5
+PTD0
+
+
+* Sense (Rows)
+
+PTD1
+PTD2
+PTD3
+PTD4
+PTD5
+PTD6
+PTD7
+
+
+ -----
+|Debug|
+ -----
+
+* SWD
+
+PTA0 (Pull-down)
+PTA3 (Pull-up)
+
+* LEDs
+
+PTA19 (LED only for PCB, not McHCK) (XTAL)
+
+* UARTs
+
+PTA1 - RX0
+PTA2 - TX0
+
+
+ ------
+|Unused|
+ ------
+
+* GPIO
+
+PTA1 (Not broken out on PCB, available on McHCK) (Pull-up)
+PTA2 (")
+PTA4 (Pull-up)
+PTA18 (EXTAL)
+
+PTC0
+PTC1
+PTC2
+PTC3
+PTC6
+PTC7
+
+* Analog
+
+ADC0_DP0
+ADC0_DM0
+
+
+
+Freescale kinetis MK20DX128
+===========================
+If FSEC of flash config at 0x400-40F is changed accidentally SWD/JTAG debug access will be lost and very difficult to get back.
+For example, high level adapter like stlink cannot work to get access back after FSEC is changed. To regain the chip to be programmable low level DAP inteface like JTAG, CMSIS-DAP or OpenSAD.
+
+
+Memory map
+==========
+kiibohd bootloader: Lib/mk20dx128vlf5.bootloader.ld
+0x0000_0000 +-------------------+ -----------------+---------------+
+            | .vectors          | ---------.       | StackPointer0 |
+            | .startup          |           \      | ResetHandler1 |
+            | .rodata           |            \     | ...           |
+0x0000_0400 | .flashconfig      | 0x10        \    | ...           |
+            | .text             |              \   | ...        61 | 0xF7
+            | .init             |               `--+---------------+ 0xF8
+0x0000_1000 +-------------------+ 4KB
+            | _app_rom          |
+            ~                   ~
+            ~                   ~
+            |                   |
+0x07FF_FFFF +-------------------+ 128KB
+
+
+0x1FFF_E000 +-------------------+
+            |                   |
+            | RAM               |
+            |                8KB|
+0x2000_0000 +-------------------+
+            |                   |
+            | RAM               |
+            |                8KB|
+0x2000_2000 +-------------------+ _estack
+
+
+
+
+
+OpenOCD
+========
+Synopsis of SWD, JTAG and SWJ-DP transport:
+https://fedcsis.org/proceedings/2012/pliks/279.pdf
+
+OpenSDA Freescale: Mass storage bootloader & serial port; part of CMSIS-DAP?
+http://cache.freescale.com/files/32bit/doc/user_guide/OPENSDAUG.pdf
+
+
+interface_list:
+    1: ftdi
+    2: usb_blaster
+    3: usbprog
+    4: jlink
+    5: vsllink
+    6: rlink
+    7: ulink
+    8: arm-jtag-ew
+    9: hla
+    10: osbdm
+    11: opendous
+    12: aice
+    13: cmsis-dap
+
+transport list:
+    stlink_swim
+    hla_jtag
+    hla_swd
+    aice_jtag
+    swd
+    cmsis-dap
+    jtag
+
+target types:
+    arm7tdmi
+    arm9tdmi
+    arm920t
+    arm720t
+    arm966e
+    arm946e
+    arm926ejs
+    fa526
+    feroceon
+    dragonite
+    xscale
+    cortex_m
+    cortex_a
+    cortex_r4
+    arm11
+    mips_m4k
+    avr
+    dsp563xx
+    dsp5680xx
+    testee
+    avr32_ap7k
+    hla_target
+    nds32_v2
+    nds32_v3
+    nds32_v3m
+    or1k
+    quark_x10xx
+
+
+TAP
+---
+http://openocd.sourceforge.net/doc/html/TAP-Declaration.html#TAP-Declaration
+    jtag newtap chipname tapname configparams...
+    hla newtap chipname tapname configparams...
+    swd newtap chipname tapname configparams...
+    cmsis-dap newtap chipname tapname configparams...
+
+        The tapname reflects the role of that TAP, and should follow this convention:
+        bs – For boundary scan if this is a separate TAP;
+        cpu – The main CPU of the chip, alternatively arm and dsp on chips with both ARM and DSP CPUs, arm1 and arm2 on chips with two ARMs, and so forth;
+        etb – For an embedded trace buffer (example: an ARM ETB11);
+        flash – If the chip has a flash TAP, like the str912;
+        jrc – For JTAG route controller (example: the ICEPick modules on many Texas Instruments chips, like the OMAP3530 on Beagleboards);
+        tap – Should be used only for FPGA- or CPLD-like devices with a single TAP;
+        unknownN – If you have no idea what the TAP is for (N is a number);
+        when in doubt – Use the chip maker's name in their data sheet. For example, the Freescale i.MX31 has a SDMA (Smart DMA) with a JTAG TAP; that TAP should be named sdma.
+
+-irlen NUMBER 
+The length in bits of the instruction register, such as 4 or 5 bits.
+
+Target
+------
+http://openocd.sourceforge.net/doc/html/CPU-Configuration.html#CPU-Configuration
+
+    target create target_name type configparams...
+    $target_name configure configparams...
+
+        -chain-position dotted.name – names the TAP used to access this target.
+        -endian (big|little) – specifies whether the CPU uses big or little endian conventions
+        -event event_name event_body – See Target Events. Note that this updates a list of named event handlers. Calling this twice with two different event names assigns two different handlers, but calling it twice with the same event name assigns only one handler.
+        -work-area-backup (0|1) – says whether the work area gets backed up; by default, it is not backed up. When possible, use a working_area that doesn't need to be backed up, since performing a backup slows down operations. For example, the beginning of an SRAM block is likely to be used by most build systems, but the end is often unused.
+        -work-area-size size – specify work are size, in bytes. The same size applies regardless of whether its physical or virtual address is being used.
+        -work-area-phys address – set the work area base address to be used when no MMU is active.
+        -work-area-virt address – set the work area base address to be used when an MMU is active. Do not specify a value for this except on targets with an MMU. The value should normally correspond to a static mapping for the -work-area-phys address, set up by the current operating system.
+        -rtos rtos_type – enable rtos support for target, rtos_type can be one of auto|eCos|ThreadX| FreeRTOS|linux|ChibiOS|embKernel See RTOS Support.
+
+Flash
+-----
+http://openocd.sourceforge.net/doc/html/Flash-Commands.html#norconfiguration
+
+    flash bank name driver base size chip_width bus_width target [driver_options]
+
+        name ... may be used to reference the flash bank in other flash commands. A number is also available.
+        driver ... identifies the controller driver associated with the flash bank being declared. This is usually cfi for external flash, or else the name of a microcontroller with embedded flash memory. See Flash Driver List.
+        base ... Base address of the flash chip.
+        size ... Size of the chip, in bytes. For some drivers, this value is detected from the hardware.
+        chip_width ... Width of the flash chip, in bytes; ignored for most microcontroller drivers.
+        bus_width ... Width of the data bus used to access the chip, in bytes; ignored for most microcontroller drivers.
+        target ... Names the target used to issue commands to the flash controller.
+        driver_options ... drivers may support, or require, additional parameters. See the driver-specific documentation for more information.
+
+    flash write_image [erase] [unlock] filename [offset] [type]
+
+
+Memory Access
+-------------
+http://openocd.sourceforge.net/doc/html/General-Commands.html#imageaccess
+    {mdw,mdh,mdb} addr [count]
+        dump {word, half-word, byte} data
+    {mww,mwh,mwb} addr data
+        write data
+
diff --git a/keyboard/infinity/Makefile b/keyboard/infinity/Makefile
new file mode 100644
index 0000000000..ec9dc00278
--- /dev/null
+++ b/keyboard/infinity/Makefile
@@ -0,0 +1,30 @@
+PROJECT = infinity
+
+TMK_DIR = ../..
+MBED_DIR = $(TMK_DIR)/mbed-sdk
+
+#VPATH += $(MBED_DIR):$(TMK_DIR)
+vpath %.s .:$(MBED_DIR):$(TMK_DIR)
+vpath %.c .:$(MBED_DIR):$(TMK_DIR)
+vpath %.cpp .:$(MBED_DIR):$(TMK_DIR)
+
+OBJDIR = ./build
+
+OBJECTS = \
+	$(OBJDIR)/main.o
+
+CONFIG_H = config.h
+
+INCLUDE_PATHS = -I.
+
+
+# Build Options
+#   Comment out to disable
+#BOOTMAGIC_ENABLE = yes
+#MOUSEKEY_ENABLE = yes
+
+
+include $(TMK_DIR)/tool/mbed/mk20d50m.mk
+include $(TMK_DIR)/tool/mbed/mbed.mk
+include $(TMK_DIR)/tool/mbed/common.mk
+include $(TMK_DIR)/tool/mbed/gcc.mk
diff --git a/keyboard/infinity/config.h b/keyboard/infinity/config.h
new file mode 100644
index 0000000000..28f2ca0293
--- /dev/null
+++ b/keyboard/infinity/config.h
@@ -0,0 +1,39 @@
+/*
+Copyright 2014 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#if 0
+// duplicated name against mbed USBDeivce
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0x3BED
+#endif
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    tmk.
+#define PRODUCT         Infinitiy
+#define DESCRIPTION     Massdrop Infinity keyboard firmware by tmk
+
+
+/* matrix size */
+#define MATRIX_ROWS 9   // Strobe
+#define MATRIX_COLS 7   // Sense
+
+/* key combination for command */
+#define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) 
+
+#endif
diff --git a/keyboard/infinity/infinity.ld b/keyboard/infinity/infinity.ld
new file mode 100644
index 0000000000..5f699a536f
--- /dev/null
+++ b/keyboard/infinity/infinity.ld
@@ -0,0 +1,156 @@
+/* 
+ * Linker script for Massdrop Infinity
+ * Infinity has bootloader in top 4KB sector of flash and app should be placed after the area.
+ *
+ * based on mbed.org K20 ARM GCC linker script file: MK20D5.ld
+ */
+
+MEMORY
+{
+  /* Infinity blootloader uses 4KB */
+  FLASH (rx) : ORIGIN = 4K, LENGTH = 128K - 4K
+  RAM (rwx) : ORIGIN = 0x1FFFE000, LENGTH = 16K
+}
+
+/* Linker script to place sections and symbol values. Should be used together
+ * with other linker script that defines memory regions FLASH and RAM.
+ * It references following symbols, which must be defined in code:
+ * _reset_init : Entry of reset handler
+ *
+ * It defines following symbols, which code can use without definition:
+ * __exidx_start
+ * __exidx_end
+ * __etext
+ * __data_start__
+ * __preinit_array_start
+ * __preinit_array_end
+ * __init_array_start
+ * __init_array_end
+ * __fini_array_start
+ * __fini_array_end
+ * __data_end__
+ * __bss_start__
+ * __bss_end__
+ * __end__
+ * end
+ * __HeapLimit
+ * __StackLimit
+ * __StackTop
+ * __stack
+ */
+ENTRY(Reset_Handler)
+
+SECTIONS
+{
+    .text :
+    {
+        __vector_table = .;
+        KEEP(*(.isr_vector))
+        *(.text.Reset_Handler)
+        *(.text.System_Init)
+         . = ALIGN(4);
+
+        *(.text*)
+
+        KEEP(*(.init))
+        KEEP(*(.fini))
+
+        /* .ctors */
+        *crtbegin.o(.ctors)
+        *crtbegin?.o(.ctors)
+        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
+        *(SORT(.ctors.*))
+        *(.ctors)
+
+        /* .dtors */
+        *crtbegin.o(.dtors)
+        *crtbegin?.o(.dtors)
+        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
+        *(SORT(.dtors.*))
+        *(.dtors)
+
+        *(.rodata*)
+
+        KEEP(*(.eh_frame*))
+    } > FLASH
+
+    .ARM.extab :
+    {
+        *(.ARM.extab* .gnu.linkonce.armextab.*)
+    } > FLASH
+
+    __exidx_start = .;
+    .ARM.exidx :
+    {
+        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
+    } > FLASH
+    __exidx_end = .;
+
+    __etext = .;
+
+    .data : AT (__etext)
+    {
+        __data_start__ = .;
+        *(vtable)
+        *(.data*)
+
+        . = ALIGN(4);
+        /* preinit data */
+        PROVIDE_HIDDEN (__preinit_array_start = .);
+        KEEP(*(.preinit_array))
+        PROVIDE_HIDDEN (__preinit_array_end = .);
+
+        . = ALIGN(4);
+        /* init data */
+        PROVIDE_HIDDEN (__init_array_start = .);
+        KEEP(*(SORT(.init_array.*)))
+        KEEP(*(.init_array))
+        PROVIDE_HIDDEN (__init_array_end = .);
+
+
+        . = ALIGN(4);
+        /* finit data */
+        PROVIDE_HIDDEN (__fini_array_start = .);
+        KEEP(*(SORT(.fini_array.*)))
+        KEEP(*(.fini_array))
+        PROVIDE_HIDDEN (__fini_array_end = .);
+
+        . = ALIGN(4);
+        /* All data end */
+        __data_end__ = .;
+
+    } > RAM
+
+    .bss :
+    {
+        __bss_start__ = .;
+        *(.bss*)
+        *(COMMON)
+        __bss_end__ = .;
+    } > RAM
+
+    .heap :
+    {
+        __end__ = .;
+        end = __end__;
+        *(.heap*)
+        __HeapLimit = .;
+    } > RAM
+
+    /* .stack_dummy section doesn't contains any symbols. It is only
+     * used for linker to calculate size of stack sections, and assign
+     * values to stack symbols later */
+    .stack_dummy :
+    {
+        *(.stack)
+    } > RAM
+
+    /* Set stack top to end of RAM, and stack limit move down by
+     * size of stack_dummy section */
+    __StackTop = ORIGIN(RAM) + LENGTH(RAM);
+    __StackLimit = __StackTop - SIZEOF(.stack_dummy);
+    PROVIDE(__stack = __StackTop);
+
+    /* Check if data + heap + stack exceeds RAM limit */
+    ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
+}
diff --git a/keyboard/infinity/main.cpp b/keyboard/infinity/main.cpp
new file mode 100644
index 0000000000..7db59cdfb9
--- /dev/null
+++ b/keyboard/infinity/main.cpp
@@ -0,0 +1,29 @@
+//#include "mbed.h"
+#include "MK20D5.h"
+#include "wait.h"
+#include "gpio_api.h"
+#include "PinNames.h"
+
+
+//DigitalOut led(PTA19);
+
+int main() {
+    gpio_t led;
+    gpio_init_out(&led, PTA19);
+    while(1) {
+        gpio_write(&led, 1);
+        wait_ms(500);
+        gpio_write(&led, 0);
+        wait_ms(500);
+    }
+/*
+    SIM->SCGC6 |= SIM_SCGC5_PORTA_MASK;
+    PORTA->PCR[19] = PORT_PCR_SRE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_MUX(1);
+    PTA->PDDR |= (1<<19);
+    PTA->PSOR |= (1<<19);
+    while(1) {
+        PTA->PTOR |= (1<<19);
+        wait_ms(500);
+    }
+*/
+}
diff --git a/tool/mbed/lpc11u35_501.mk b/tool/mbed/lpc11u35_501.mk
index af1aad797f..15e14910ce 100644
--- a/tool/mbed/lpc11u35_501.mk
+++ b/tool/mbed/lpc11u35_501.mk
@@ -44,6 +44,6 @@ INCLUDE_PATHS += \
 	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP \
 	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX \
 	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501 \
-	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501/TARGET_LPC11U35_501 \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC11UXX/TARGET_MCU_LPC11U35_501/TARGET_LPC11U35_501
 
 LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/TARGET_LPC11U35_501/LPC11U35.ld
diff --git a/tool/mbed/mbed.mk b/tool/mbed/mbed.mk
index 242d78794f..db322b260a 100644
--- a/tool/mbed/mbed.mk
+++ b/tool/mbed/mbed.mk
@@ -2,60 +2,64 @@
 # see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
 
 OBJECTS += \
-	$(OBJDIR)/libraries/mbed/common/BusIn.o \
-	$(OBJDIR)/libraries/mbed/common/BusInOut.o \
-	$(OBJDIR)/libraries/mbed/common/BusOut.o \
-	$(OBJDIR)/libraries/mbed/common/CAN.o \
-	$(OBJDIR)/libraries/mbed/common/CallChain.o \
-	$(OBJDIR)/libraries/mbed/common/Ethernet.o \
-	$(OBJDIR)/libraries/mbed/common/FileBase.o \
-	$(OBJDIR)/libraries/mbed/common/FileLike.o \
-	$(OBJDIR)/libraries/mbed/common/FilePath.o \
-	$(OBJDIR)/libraries/mbed/common/FileSystemLike.o \
-	$(OBJDIR)/libraries/mbed/common/FunctionPointer.o \
-	$(OBJDIR)/libraries/mbed/common/I2C.o \
-	$(OBJDIR)/libraries/mbed/common/I2CSlave.o \
-	$(OBJDIR)/libraries/mbed/common/InterruptIn.o \
-	$(OBJDIR)/libraries/mbed/common/InterruptManager.o \
-	$(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \
-	$(OBJDIR)/libraries/mbed/common/RawSerial.o \
-	$(OBJDIR)/libraries/mbed/common/SPI.o \
-	$(OBJDIR)/libraries/mbed/common/SPISlave.o \
-	$(OBJDIR)/libraries/mbed/common/Serial.o \
-	$(OBJDIR)/libraries/mbed/common/SerialBase.o \
-	$(OBJDIR)/libraries/mbed/common/Stream.o \
-	$(OBJDIR)/libraries/mbed/common/Ticker.o \
-	$(OBJDIR)/libraries/mbed/common/Timeout.o \
-	$(OBJDIR)/libraries/mbed/common/Timer.o \
-	$(OBJDIR)/libraries/mbed/common/TimerEvent.o \
-	$(OBJDIR)/libraries/mbed/common/assert.o \
-	$(OBJDIR)/libraries/mbed/common/board.o \
-	$(OBJDIR)/libraries/mbed/common/error.o \
-	$(OBJDIR)/libraries/mbed/common/exit.o \
 	$(OBJDIR)/libraries/mbed/common/gpio.o \
-	$(OBJDIR)/libraries/mbed/common/mbed_interface.o \
-	$(OBJDIR)/libraries/mbed/common/pinmap_common.o \
-	$(OBJDIR)/libraries/mbed/common/retarget.o \
-	$(OBJDIR)/libraries/mbed/common/rtc_time.o \
-	$(OBJDIR)/libraries/mbed/common/semihost_api.o \
 	$(OBJDIR)/libraries/mbed/common/us_ticker_api.o \
-	$(OBJDIR)/libraries/mbed/common/wait_api.o \
-	$(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.o \
-	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \
-	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \
-	$(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o \
-	$(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \
-	$(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \
-	$(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o
+	$(OBJDIR)/libraries/mbed/common/wait_api.o
+
+#	$(OBJDIR)/libraries/mbed/common/assert.o \
+#	$(OBJDIR)/libraries/mbed/common/board.o \
+#	$(OBJDIR)/libraries/mbed/common/BusIn.o \
+#	$(OBJDIR)/libraries/mbed/common/BusInOut.o \
+#	$(OBJDIR)/libraries/mbed/common/BusOut.o \
+#	$(OBJDIR)/libraries/mbed/common/CallChain.o \
+#	$(OBJDIR)/libraries/mbed/common/CAN.o \
+#	$(OBJDIR)/libraries/mbed/common/error.o \
+#	$(OBJDIR)/libraries/mbed/common/Ethernet.o \
+#	$(OBJDIR)/libraries/mbed/common/exit.o \
+#	$(OBJDIR)/libraries/mbed/common/FileBase.o \
+#	$(OBJDIR)/libraries/mbed/common/FileLike.o \
+#	$(OBJDIR)/libraries/mbed/common/FilePath.o \
+#	$(OBJDIR)/libraries/mbed/common/FileSystemLike.o \
+#	$(OBJDIR)/libraries/mbed/common/FunctionPointer.o \
+#	$(OBJDIR)/libraries/mbed/common/gpio.o \
+#	$(OBJDIR)/libraries/mbed/common/I2C.o \
+#	$(OBJDIR)/libraries/mbed/common/I2CSlave.o \
+#	$(OBJDIR)/libraries/mbed/common/InterruptIn.o \
+#	$(OBJDIR)/libraries/mbed/common/InterruptManager.o \
+#	$(OBJDIR)/libraries/mbed/common/LocalFileSystem.o \
+#	$(OBJDIR)/libraries/mbed/common/mbed_interface.o \
+#	$(OBJDIR)/libraries/mbed/common/pinmap_common.o \
+#	$(OBJDIR)/libraries/mbed/common/RawSerial.o \
+#	$(OBJDIR)/libraries/mbed/common/retarget.o \
+#	$(OBJDIR)/libraries/mbed/common/rtc_time.o \
+#	$(OBJDIR)/libraries/mbed/common/semihost_api.o \
+#	$(OBJDIR)/libraries/mbed/common/SerialBase.o \
+#	$(OBJDIR)/libraries/mbed/common/Serial.o \
+#	$(OBJDIR)/libraries/mbed/common/SPI.o \
+#	$(OBJDIR)/libraries/mbed/common/SPISlave.o \
+#	$(OBJDIR)/libraries/mbed/common/Stream.o \
+#	$(OBJDIR)/libraries/mbed/common/Ticker.o \
+#	$(OBJDIR)/libraries/mbed/common/Timeout.o \
+#	$(OBJDIR)/libraries/mbed/common/TimerEvent.o \
+#	$(OBJDIR)/libraries/mbed/common/Timer.o \
+#	$(OBJDIR)/libraries/mbed/common/us_ticker_api.o \
+#	$(OBJDIR)/libraries/mbed/common/wait_api.o \
+#	$(OBJDIR)/libraries/USBDevice/USBAudio/USBAudio.o \
+#	$(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o \
+#	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_KL25Z.o \
+#	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
+#	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC17.o \
+#	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC40.o \
+#	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_RZ_A1H.o \
+#	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_STM32F4.o \
+#	$(OBJDIR)/libraries/USBDevice/USBHID/USBHID.o \
+#	$(OBJDIR)/libraries/USBDevice/USBHID/USBKeyboard.o \
+#	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouseKeyboard.o \
+#	$(OBJDIR)/libraries/USBDevice/USBHID/USBMouse.o \
+#	$(OBJDIR)/libraries/USBDevice/USBMIDI/USBMIDI.o \
+#	$(OBJDIR)/libraries/USBDevice/USBMSD/USBMSD.o \
+#	$(OBJDIR)/libraries/USBDevice/USBSerial/USBCDC.o \
+#	$(OBJDIR)/libraries/USBDevice/USBSerial/USBSerial.o
 
 INCLUDE_PATHS += \
 	-I$(MBED_DIR)/libraries/mbed \
@@ -71,9 +75,9 @@ INCLUDE_PATHS += \
 	-I$(MBED_DIR)/libraries/USBDevice/USBSerial
 
 # TMK mbed protocol
-OBJECTS += \
-	$(OBJDIR)/protocol/mbed/mbed_driver.o \
-	$(OBJDIR)/protocol/mbed/HIDKeyboard.o
+#OBJECTS += \
+#	$(OBJDIR)/protocol/mbed/mbed_driver.o \
+#	$(OBJDIR)/protocol/mbed/HIDKeyboard.o
 
 INCLUDE_PATHS += \
 	-I$(TMK_DIR)/protocol/mbed
diff --git a/tool/mbed/mk20d50m.mk b/tool/mbed/mk20d50m.mk
new file mode 100644
index 0000000000..eb7bde6427
--- /dev/null
+++ b/tool/mbed/mk20d50m.mk
@@ -0,0 +1,45 @@
+# based on Makefile exported form mbed.org
+# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded
+
+CPU = -mcpu=cortex-m4 -mthumb
+
+CC_SYMBOLS += \
+	-DTARGET_K20D50M \
+	-DTARGET_M4 \
+	-DTARGET_CORTEX_M \
+	-DTARGET_Freescale \
+	-DTOOLCHAIN_GCC_ARM \
+	-DTOOLCHAIN_GCC \
+	-D__CORTEX_M4 \
+	-DARM_MATH_CM4 \
+	-D__MBED__=1
+
+OBJECTS += \
+	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.o \
+	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/cmsis_nvic.o \
+	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/analogin_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_irq_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/i2c_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/pinmap.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/port_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/pwmout_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/rtc_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/serial_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/sleep.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/spi_api.o \
+	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/us_ticker.o
+
+INCLUDE_PATHS += \
+	-I$(MBED_DIR)/libraries/mbed/targets \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M \
+	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale \
+	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M
+
+LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
+#LINKER_SCRIPT = infinity.ld

From d5e5dbd0aa28477884940ce045da09a9168859d8 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Fri, 2 Jan 2015 23:19:26 +0900
Subject: [PATCH 27/95] Add openocd config files for K20

---
 keyboard/infinity/k20dx32_flash.cfg | 124 ++++++++++++++++++++++++++++
 keyboard/infinity/openocd.cfg       |  13 +++
 2 files changed, 137 insertions(+)
 create mode 100644 keyboard/infinity/k20dx32_flash.cfg
 create mode 100644 keyboard/infinity/openocd.cfg

diff --git a/keyboard/infinity/k20dx32_flash.cfg b/keyboard/infinity/k20dx32_flash.cfg
new file mode 100644
index 0000000000..714d9991f8
--- /dev/null
+++ b/keyboard/infinity/k20dx32_flash.cfg
@@ -0,0 +1,124 @@
+# FreeScale Kinetis K20 devices with 32kB Flash and 8kB Local On-Chip SRAM,
+# Nemuisan's Special for MK20DN32VFT5,MK20DX32VFT5,MK10DN32VFT5,MK10DX32VFT5
+
+
+source [find target/swj-dp.tcl]
+
+if { [info exists CHIPNAME] } {
+    set _CHIPNAME $CHIPNAME
+} else {
+    set _CHIPNAME k20
+}
+
+if { [info exists ENDIAN] } {
+    set _ENDIAN $ENDIAN
+} else {
+    set _ENDIAN little
+}
+
+if { [info exists CPUTAPID] } {
+   set _CPUTAPID $CPUTAPID
+} else {
+   if { [using_jtag] } {
+      set _CPUTAPID 0x4BA00477
+   } {
+      # this is the SW-DP tap id not the jtag tap id
+      set _CPUTAPID 0x2BA01477
+   }
+}
+
+# Work-area is a space in RAM used for flash programming
+# By default use 8kB
+if { [info exists WORKAREASIZE] == 0 } {
+   set _WORKAREASIZE 0x2000
+}
+
+# Select "srst_only", Nemuisan said so!
+echo "Kinetis MUST need Hardware SRST Control to Recover Secure-State!"
+adapter_nsrst_delay 200
+reset_config srst_only
+
+swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
+set _TARGETNAME $_CHIPNAME.cpu
+target create $_TARGETNAME cortex_m -chain-position $_TARGETNAME
+
+# It is important that "kinetis mdm check_security" is called for
+# 'examine-end' event and not 'eximine-start'. Calling it in 'examine-start'
+# causes "kinetis mdm check_security" to fail the first time openocd
+# calls it when it tries to connect after the CPU has been power-cycled.
+$_CHIPNAME.cpu configure -event examine-end {
+	kinetis mdm check_security
+# Uncomment when gone into s*ck'n secured state!
+#	kinetis mdm mass_erase
+}
+
+# K20 has minimun 8kB of SRAM and starts at 1FFFF000.
+$_TARGETNAME configure -work-area-phys 0x1FFFF000 -work-area-size $_WORKAREASIZE -work-area-backup 0 -rtos auto
+
+# MK20DN32VFT5,MK20DX32VFT5,MK10DN32VFT5,MK10DX32VFT5 has 32kB of flash memory.
+flash bank $_CHIPNAME.pflash kinetis 0x00000000 0x8000 0 4 $_TARGETNAME
+
+
+proc mt_flash {IMGFILE} {
+	flash write_image erase $IMGFILE
+	reset run
+	halt
+	verify_image $IMGFILE
+	reset run
+	shutdown
+}
+
+proc mt_flash_bin {IMGFILE OFFSET} {
+	flash write_image erase $IMGFILE $OFFSET bin
+	reset run
+	halt
+	verify_image $IMGFILE $OFFSET bin
+	reset run
+	shutdown
+}
+
+proc mt_flash_hex {IMGFILE} {
+	flash write_image erase $IMGFILE 0 ihex
+	reset run
+	halt
+	verify_image $IMGFILE 0 ihex
+	reset run
+	shutdown
+}
+
+proc mt_flash_srec {IMGFILE} {
+	flash write_image erase $IMGFILE 0 s19
+	reset run
+	halt
+	verify_image $IMGFILE 0 s19
+	reset run
+	shutdown
+}
+
+proc mass_erase {} {
+	kinetis mdm mass_erase
+}
+
+proc eraser {} {
+# Verbose procedure confirmed erase routine
+	flash info 0
+# CAUTION! "flash erase_sector 0 0 last" goes into secure state!!!
+# USE "mass_erase" command instead of
+#	flash erase_sector 0 0 last
+	mass_erase
+	shutdown
+}
+
+
+#debug_level 3
+# HLA doesn't have cortex_m commands 
+if {![using_hla]} {
+   # if srst is not fitted use SYSRESETREQ to
+   # perform a soft reset
+   cortex_m reset_config sysresetreq
+}
+adapter_khz 1000
+reset_config srst_only srst_nogate connect_assert_srst
+gdb_target_description disable
+init
+reset init
diff --git a/keyboard/infinity/openocd.cfg b/keyboard/infinity/openocd.cfg
new file mode 100644
index 0000000000..2b0a63b933
--- /dev/null
+++ b/keyboard/infinity/openocd.cfg
@@ -0,0 +1,13 @@
+# mchack openocd
+# https://github.com/mchck/mchck/wiki/Openocd
+#
+# adapter: frdm-kl05z with cmsis-dap firmware
+# inteface: cmsis-dap
+# transport: hla_swd
+# target: MK20DX128VLF5 Freescale Kinetis
+
+# adapter/interface
+source [find interface/cmsis-dap.cfg]
+
+# CPU
+source [find k20dx32_flash.cfg]

From 4acde45102cbf7b29f524c227bcd1c11aa83ebc0 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Sat, 3 Jan 2015 20:21:23 +0900
Subject: [PATCH 28/95] Fix linker script for NVIC vector on RAM

---
 keyboard/infinity/infinity.ld |  2 +-
 keyboard/infinity/main.cpp    | 21 ++++++---------------
 tool/mbed/mk20d50m.mk         |  3 +--
 3 files changed, 8 insertions(+), 18 deletions(-)

diff --git a/keyboard/infinity/infinity.ld b/keyboard/infinity/infinity.ld
index 5f699a536f..decdaa26e0 100644
--- a/keyboard/infinity/infinity.ld
+++ b/keyboard/infinity/infinity.ld
@@ -9,7 +9,7 @@ MEMORY
 {
   /* Infinity blootloader uses 4KB */
   FLASH (rx) : ORIGIN = 4K, LENGTH = 128K - 4K
-  RAM (rwx) : ORIGIN = 0x1FFFE000, LENGTH = 16K
+  RAM (rwx) : ORIGIN = 0x1FFFE0F8, LENGTH = 16K - 0xF8
 }
 
 /* Linker script to place sections and symbol values. Should be used together
diff --git a/keyboard/infinity/main.cpp b/keyboard/infinity/main.cpp
index 7db59cdfb9..f28840d3ef 100644
--- a/keyboard/infinity/main.cpp
+++ b/keyboard/infinity/main.cpp
@@ -5,25 +5,16 @@
 #include "PinNames.h"
 
 
-//DigitalOut led(PTA19);
-
 int main() {
     gpio_t led;
     gpio_init_out(&led, PTA19);
     while(1) {
-        gpio_write(&led, 1);
-        wait_ms(500);
-        gpio_write(&led, 0);
         wait_ms(500);
+        uint32_t delay = 0xf;
+        while (delay--) {
+            uint32_t delay2 = 0xffff;
+            while (delay2--) ;
+        }
+        gpio_write(&led, !gpio_read(&led));
     }
-/*
-    SIM->SCGC6 |= SIM_SCGC5_PORTA_MASK;
-    PORTA->PCR[19] = PORT_PCR_SRE_MASK | PORT_PCR_DSE_MASK | PORT_PCR_MUX(1);
-    PTA->PDDR |= (1<<19);
-    PTA->PSOR |= (1<<19);
-    while(1) {
-        PTA->PTOR |= (1<<19);
-        wait_ms(500);
-    }
-*/
 }
diff --git a/tool/mbed/mk20d50m.mk b/tool/mbed/mk20d50m.mk
index eb7bde6427..e62e39d21f 100644
--- a/tool/mbed/mk20d50m.mk
+++ b/tool/mbed/mk20d50m.mk
@@ -41,5 +41,4 @@ INCLUDE_PATHS += \
 	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale \
 	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M
 
-LINKER_SCRIPT = $(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
-#LINKER_SCRIPT = infinity.ld
+LINKER_SCRIPT = infinity.ld

From c6e533ce83d6ae4393e6cdf1f6d39ffefc790115 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Sun, 4 Jan 2015 03:27:24 +0900
Subject: [PATCH 29/95] infinity: Move project specific files to local

---
 keyboard/infinity/Makefile                    |   5 +-
 .../infinity/mbed-infinity.mk                 |   7 +-
 keyboard/infinity/mbed-infinity/cmsis_nvic.c  |  55 ++++
 .../infinity/{ => mbed-infinity}/infinity.ld  |   0
 .../infinity/mbed-infinity/system_MK20D5.c    | 299 ++++++++++++++++++
 .../infinity/{ => tool}/k20dx32_flash.cfg     |   0
 keyboard/infinity/{ => tool}/openocd.cfg      |   0
 7 files changed, 362 insertions(+), 4 deletions(-)
 rename tool/mbed/mk20d50m.mk => keyboard/infinity/mbed-infinity.mk (90%)
 create mode 100644 keyboard/infinity/mbed-infinity/cmsis_nvic.c
 rename keyboard/infinity/{ => mbed-infinity}/infinity.ld (100%)
 create mode 100644 keyboard/infinity/mbed-infinity/system_MK20D5.c
 rename keyboard/infinity/{ => tool}/k20dx32_flash.cfg (100%)
 rename keyboard/infinity/{ => tool}/openocd.cfg (100%)

diff --git a/keyboard/infinity/Makefile b/keyboard/infinity/Makefile
index ec9dc00278..e97f759dfa 100644
--- a/keyboard/infinity/Makefile
+++ b/keyboard/infinity/Makefile
@@ -24,7 +24,10 @@ INCLUDE_PATHS = -I.
 #MOUSEKEY_ENABLE = yes
 
 
-include $(TMK_DIR)/tool/mbed/mk20d50m.mk
+include mbed-infinity.mk
 include $(TMK_DIR)/tool/mbed/mbed.mk
 include $(TMK_DIR)/tool/mbed/common.mk
 include $(TMK_DIR)/tool/mbed/gcc.mk
+
+program:
+	dfu-util -D $(OBJDIR)/$(PROJECT).bin
diff --git a/tool/mbed/mk20d50m.mk b/keyboard/infinity/mbed-infinity.mk
similarity index 90%
rename from tool/mbed/mk20d50m.mk
rename to keyboard/infinity/mbed-infinity.mk
index e62e39d21f..cd4434a230 100644
--- a/tool/mbed/mk20d50m.mk
+++ b/keyboard/infinity/mbed-infinity.mk
@@ -15,9 +15,9 @@ CC_SYMBOLS += \
 	-D__MBED__=1
 
 OBJECTS += \
+	$(OBJDIR)/mbed-infinity/cmsis_nvic.o \
+	$(OBJDIR)/mbed-infinity/system_MK20D5.o \
 	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.o \
-	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/cmsis_nvic.o \
-	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.o \
 	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/analogin_api.o \
 	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_api.o \
 	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_irq_api.o \
@@ -32,6 +32,7 @@ OBJECTS += \
 	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/us_ticker.o
 
 INCLUDE_PATHS += \
+	-Imbed \
 	-I$(MBED_DIR)/libraries/mbed/targets \
 	-I$(MBED_DIR)/libraries/mbed/targets/cmsis \
 	-I$(MBED_DIR)/libraries/mbed/targets/cmsis/TARGET_Freescale \
@@ -41,4 +42,4 @@ INCLUDE_PATHS += \
 	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale \
 	-I$(MBED_DIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M
 
-LINKER_SCRIPT = infinity.ld
+LINKER_SCRIPT = mbed-infinity/infinity.ld
diff --git a/keyboard/infinity/mbed-infinity/cmsis_nvic.c b/keyboard/infinity/mbed-infinity/cmsis_nvic.c
new file mode 100644
index 0000000000..985c1d33f5
--- /dev/null
+++ b/keyboard/infinity/mbed-infinity/cmsis_nvic.c
@@ -0,0 +1,55 @@
+/* mbed Microcontroller Library
+ * CMSIS-style functionality to support dynamic vectors
+ *******************************************************************************
+ * Copyright (c) 2011 ARM Limited. All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ * 3. Neither the name of ARM Limited nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *******************************************************************************
+ */
+#include "cmsis_nvic.h"
+
+#define NVIC_RAM_VECTOR_ADDRESS (0x1FFFE000)  // Vectors positioned at start of RAM
+#define NVIC_FLASH_VECTOR_ADDRESS (0x1000)       // Initial vector position in flash
+
+void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector) {
+    uint32_t *vectors = (uint32_t*)SCB->VTOR;
+    uint32_t i;
+
+    // Copy and switch to dynamic vectors if the first time called
+    if (SCB->VTOR == NVIC_FLASH_VECTOR_ADDRESS) {
+        uint32_t *old_vectors = vectors;
+        vectors = (uint32_t*)NVIC_RAM_VECTOR_ADDRESS;
+        for (i=0; i<NVIC_NUM_VECTORS; i++) {
+            vectors[i] = old_vectors[i];
+        }
+        SCB->VTOR = (uint32_t)NVIC_RAM_VECTOR_ADDRESS;
+    }
+    vectors[IRQn + 16] = vector;
+}
+
+uint32_t NVIC_GetVector(IRQn_Type IRQn) {
+    uint32_t *vectors = (uint32_t*)SCB->VTOR;
+    return vectors[IRQn + 16];
+}
diff --git a/keyboard/infinity/infinity.ld b/keyboard/infinity/mbed-infinity/infinity.ld
similarity index 100%
rename from keyboard/infinity/infinity.ld
rename to keyboard/infinity/mbed-infinity/infinity.ld
diff --git a/keyboard/infinity/mbed-infinity/system_MK20D5.c b/keyboard/infinity/mbed-infinity/system_MK20D5.c
new file mode 100644
index 0000000000..4f4e2a2624
--- /dev/null
+++ b/keyboard/infinity/mbed-infinity/system_MK20D5.c
@@ -0,0 +1,299 @@
+/*
+** ###################################################################
+**     Compilers:           ARM Compiler
+**                          Freescale C/C++ for Embedded ARM
+**                          GNU C Compiler
+**                          IAR ANSI C/C++ Compiler for ARM
+**
+**     Reference manuals:   K20P64M50SF0RM Rev. 1, Oct 2011
+**                          K20P32M50SF0RM Rev. 1, Oct 2011
+**                          K20P48M50SF0RM Rev. 1, Oct 2011
+**
+**     Version:             rev. 1.0, 2011-12-15
+**
+**     Abstract:
+**         Provides a system configuration function and a global variable that
+**         contains the system frequency. It configures the device and initializes
+**         the oscillator (PLL) that is part of the microcontroller device.
+**
+**     Copyright: 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+**
+**     http:                 www.freescale.com
+**     mail:                 support@freescale.com
+**
+**     Revisions:
+**     - rev. 1.0 (2011-12-15)
+**         Initial version
+**
+** ###################################################################
+*/
+
+/**
+ * @file MK20D5
+ * @version 1.0
+ * @date 2011-12-15
+ * @brief Device specific configuration file for MK20D5 (implementation file)
+ *
+ * Provides a system configuration function and a global variable that contains
+ * the system frequency. It configures the device and initializes the oscillator
+ * (PLL) that is part of the microcontroller device.
+ */
+
+#include <stdint.h>
+#include "MK20D5.h"
+
+#define DISABLE_WDOG    1
+
+#define CLOCK_SETUP     3
+/* Predefined clock setups
+   0 ... Multipurpose Clock Generator (MCG) in FLL Engaged Internal (FEI) mode
+         Reference clock source for MCG module is the slow internal clock source 32.768kHz
+         Core clock = 41.94MHz, BusClock = 41.94MHz
+   1 ... Multipurpose Clock Generator (MCG) in PLL Engaged External (PEE) mode
+         Reference clock source for MCG module is an external crystal 8MHz
+         Core clock = 48MHz, BusClock = 48MHz
+   2 ... Multipurpose Clock Generator (MCG) in Bypassed Low Power External (BLPE) mode
+         Core clock/Bus clock derived directly from an external crystal 8MHz with no multiplication
+         Core clock = 8MHz, BusClock = 8MHz
+*/
+
+/*----------------------------------------------------------------------------
+  Define clock source values
+ *----------------------------------------------------------------------------*/
+#if (CLOCK_SETUP == 0)
+    #define CPU_XTAL_CLK_HZ                 8000000u /* Value of the external crystal or oscillator clock frequency in Hz */
+    #define CPU_XTAL32k_CLK_HZ              32768u   /* Value of the external 32k crystal or oscillator clock frequency in Hz */
+    #define CPU_INT_SLOW_CLK_HZ             32768u   /* Value of the slow internal oscillator clock frequency in Hz  */
+    #define CPU_INT_FAST_CLK_HZ             4000000u /* Value of the fast internal oscillator clock frequency in Hz  */
+    #define DEFAULT_SYSTEM_CLOCK            41943040u /* Default System clock value */
+#elif (CLOCK_SETUP == 1)
+    #define CPU_XTAL_CLK_HZ                 8000000u /* Value of the external crystal or oscillator clock frequency in Hz */
+    #define CPU_XTAL32k_CLK_HZ              32768u   /* Value of the external 32k crystal or oscillator clock frequency in Hz */
+    #define CPU_INT_SLOW_CLK_HZ             32768u   /* Value of the slow internal oscillator clock frequency in Hz  */
+    #define CPU_INT_FAST_CLK_HZ             4000000u /* Value of the fast internal oscillator clock frequency in Hz  */
+    #define DEFAULT_SYSTEM_CLOCK            48000000u /* Default System clock value */
+#elif (CLOCK_SETUP == 2)
+    #define CPU_XTAL_CLK_HZ                 8000000u /* Value of the external crystal or oscillator clock frequency in Hz */
+    #define CPU_XTAL32k_CLK_HZ              32768u   /* Value of the external 32k crystal or oscillator clock frequency in Hz */
+    #define CPU_INT_SLOW_CLK_HZ             32768u   /* Value of the slow internal oscillator clock frequency in Hz  */
+    #define CPU_INT_FAST_CLK_HZ             4000000u /* Value of the fast internal oscillator clock frequency in Hz  */
+    #define DEFAULT_SYSTEM_CLOCK            8000000u /* Default System clock value */
+#elif (CLOCK_SETUP == 3)
+    /* for Infinity */
+    #define CPU_XTAL_CLK_HZ                 8000000u
+    #define CPU_XTAL32k_CLK_HZ              32768u
+    #define CPU_INT_SLOW_CLK_HZ             32768u
+    #define CPU_INT_FAST_CLK_HZ             4000000u
+    #define DEFAULT_SYSTEM_CLOCK            48000000u
+#endif
+
+
+/* ----------------------------------------------------------------------------
+   -- Core clock
+   ---------------------------------------------------------------------------- */
+
+uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
+
+/* ----------------------------------------------------------------------------
+   -- SystemInit()
+   ---------------------------------------------------------------------------- */
+
+void SystemInit (void) {
+#if (DISABLE_WDOG)
+  /* Disable the WDOG module */
+  /* WDOG_UNLOCK: WDOGUNLOCK=0xC520 */
+  WDOG->UNLOCK = (uint16_t)0xC520u;     /* Key 1 */
+  /* WDOG_UNLOCK : WDOGUNLOCK=0xD928 */
+  WDOG->UNLOCK  = (uint16_t)0xD928u;    /* Key 2 */
+  /* WDOG_STCTRLH: ??=0,DISTESTWDOG=0,BYTESEL=0,TESTSEL=0,TESTWDOG=0,??=0,STNDBYEN=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=0,CLKSRC=1,WDOGEN=0 */
+  WDOG->STCTRLH = (uint16_t)0x01D2u;
+#endif /* (DISABLE_WDOG) */
+#if (CLOCK_SETUP == 0)
+  /* SIM->CLKDIV1: OUTDIV1=0,OUTDIV2=0,OUTDIV3=1,OUTDIV4=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
+  SIM->CLKDIV1 = (uint32_t)0x00110000u; /* Update system prescalers */
+  /* Switch to FEI Mode */
+  /* MCG->C1: CLKS=0,FRDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0 */
+  MCG->C1 = (uint8_t)0x06u;
+  /* MCG->C2: ??=0,??=0,RANGE0=0,HGO=0,EREFS=0,LP=0,IRCS=0 */
+  MCG->C2 = (uint8_t)0x00u;
+  /* MCG_C4: DMX32=0,DRST_DRS=1 */
+  MCG->C4 = (uint8_t)((MCG->C4 & (uint8_t)~(uint8_t)0xC0u) | (uint8_t)0x20u);
+  /* MCG->C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=0 */
+  MCG->C5 = (uint8_t)0x00u;
+  /* MCG->C6: LOLIE=0,PLLS=0,CME=0,VDIV0=0 */
+  MCG->C6 = (uint8_t)0x00u;
+  while((MCG->S & MCG_S_IREFST_MASK) == 0u) { /* Check that the source of the FLL reference clock is the internal reference clock. */
+  }
+  while((MCG->S & 0x0Cu) != 0x00u) {    /* Wait until output of the FLL is selected */
+  }
+#elif (CLOCK_SETUP == 1)
+  /* SIM->CLKDIV1: OUTDIV1=0,OUTDIV2=0,OUTDIV3=1,OUTDIV4=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
+  SIM->CLKDIV1 = (uint32_t)0x00110000u; /* Update system prescalers */
+  /* Switch to FBE Mode */
+  /* OSC0->CR: ERCLKEN=0,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
+  OSC0->CR = (uint8_t)0x00u;
+  /* MCG->C7: OSCSEL=0 */
+  MCG->C7 = (uint8_t)0x00u;
+  /* MCG->C2: ??=0,??=0,RANGE0=2,HGO=0,EREFS=1,LP=0,IRCS=0 */
+  MCG->C2 = (uint8_t)0x24u;
+  /* MCG->C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
+  MCG->C1 = (uint8_t)0x9Au;
+  /* MCG->C4: DMX32=0,DRST_DRS=0 */
+  MCG->C4 &= (uint8_t)~(uint8_t)0xE0u;
+  /* MCG->C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=3 */
+  MCG->C5 = (uint8_t)0x03u;
+  /* MCG->C6: LOLIE=0,PLLS=0,CME=0,VDIV0=0 */
+  MCG->C6 = (uint8_t)0x00u;
+  while((MCG->S & MCG_S_OSCINIT0_MASK) == 0u) { /* Check that the oscillator is running */
+  }
+#if 0 /* ARM: THIS CHECK IS REMOVED DUE TO BUG WITH SLOW IRC IN REV. 1.0 */
+  while((MCG->S & MCG_S_IREFST_MASK) != 0u) { /* Check that the source of the FLL reference clock is the external reference clock. */
+  }
+#endif
+  while((MCG->S & 0x0Cu) != 0x08u) {    /* Wait until external reference clock is selected as MCG output */
+  }
+  /* Switch to PBE Mode */
+  /* MCG_C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=3 */
+  MCG->C5 = (uint8_t)0x03u;
+  /* MCG->C6: LOLIE=0,PLLS=1,CME=0,VDIV0=0 */
+  MCG->C6 = (uint8_t)0x40u;
+  while((MCG->S & MCG_S_PLLST_MASK) == 0u) { /* Wait until the source of the PLLS clock has switched to the PLL */
+  }
+  while((MCG->S & MCG_S_LOCK0_MASK) == 0u) { /* Wait until locked */
+  }
+  /* Switch to PEE Mode */
+  /* MCG->C1: CLKS=0,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
+  MCG->C1 = (uint8_t)0x1Au;
+  while((MCG->S & 0x0Cu) != 0x0Cu) {    /* Wait until output of the PLL is selected */
+  }
+  while((MCG->S & MCG_S_LOCK0_MASK) == 0u) { /* Wait until locked */
+  }
+#elif (CLOCK_SETUP == 2)
+  /* SIM_CLKDIV1: OUTDIV1=0,OUTDIV2=0,OUTDIV3=1,OUTDIV4=1,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
+  SIM->CLKDIV1 = (uint32_t)0x00110000u; /* Update system prescalers */
+  /* Switch to FBE Mode */
+  /* OSC0->CR: ERCLKEN=0,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
+  OSC0->CR = (uint8_t)0x00u;
+  /* MCG->C7: OSCSEL=0 */
+  MCG->C7 = (uint8_t)0x00u;
+  /* MCG->C2: ??=0,??=0,RANGE0=2,HGO=0,EREFS=1,LP=0,IRCS=0 */
+  MCG->C2 = (uint8_t)0x24u;
+  /* MCG->C1: CLKS=2,FRDIV=3,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
+  MCG->C1 = (uint8_t)0x9Au;
+  /* MCG->C4: DMX32=0,DRST_DRS=0 */
+  MCG->C4 &= (uint8_t)~(uint8_t)0xE0u;
+  /* MCG->C5: ??=0,PLLCLKEN=0,PLLSTEN=0,PRDIV0=0 */
+  MCG->C5 = (uint8_t)0x00u;
+  /* MCG->C6: LOLIE=0,PLLS=0,CME=0,VDIV0=0 */
+  MCG->C6 = (uint8_t)0x00u;
+  while((MCG->S & MCG_S_OSCINIT0_MASK) == 0u) { /* Check that the oscillator is running */
+  }
+#if 0 /* ARM: THIS CHECK IS REMOVED DUE TO BUG WITH SLOW IRC IN REV. 1.0 */
+  while((MCG->S & MCG_S_IREFST_MASK) != 0u) { /* Check that the source of the FLL reference clock is the external reference clock. */
+  }
+#endif
+  while((MCG->S & 0x0CU) != 0x08u) {    /* Wait until external reference clock is selected as MCG output */
+  }
+  /* Switch to BLPE Mode */
+  /* MCG->C2: ??=0,??=0,RANGE0=2,HGO=0,EREFS=1,LP=0,IRCS=0 */
+  MCG->C2 = (uint8_t)0x24u;
+
+#elif (CLOCK_SETUP == 3)
+  /* for Infinity FEI: 48MHz */
+
+  /* OUTDIV1(core/system): 48/1, OUTDIV2(bus): 48/1, OUTDIV4(flash): 48/2 */
+  SIM->CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(0) | SIM_CLKDIV1_OUTDIV4(1);
+  MCG->C1 = MCG_C1_IREFS_MASK | MCG_C1_IRCLKEN_MASK;
+  /* 32.768KHz x FLL(1464) = 48MHz */
+  MCG->C4 = MCG_C4_DMX32_MASK | MCG_C4_DRST_DRS(1);
+  /* USB clock source: MCGPLLCLK/MCGFLLCLK */
+  //SIM->SOPT2 = SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_TRACECLKSEL_MASK;
+
+  while((MCG->S & MCG_S_IREFST_MASK) == 0u) { }
+  while((MCG->S & 0x0Cu) != 0x00u) { }
+#endif
+}
+
+/* ----------------------------------------------------------------------------
+   -- SystemCoreClockUpdate()
+   ---------------------------------------------------------------------------- */
+
+void SystemCoreClockUpdate (void) {
+  uint32_t MCGOUTClock;                                                        /* Variable to store output clock frequency of the MCG module */
+  uint8_t Divider;
+
+  if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x0u) {
+    /* Output of FLL or PLL is selected */
+    if ((MCG->C6 & MCG_C6_PLLS_MASK) == 0x0u) {
+      /* FLL is selected */
+      if ((MCG->C1 & MCG_C1_IREFS_MASK) == 0x0u) {
+        /* External reference clock is selected */
+        if ((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u) {
+          MCGOUTClock = CPU_XTAL_CLK_HZ;                                       /* System oscillator drives MCG clock */
+        } else { /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
+          MCGOUTClock = CPU_XTAL32k_CLK_HZ;                                    /* RTC 32 kHz oscillator drives MCG clock */
+        } /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
+        Divider = (uint8_t)(1u << ((MCG->C1 & MCG_C1_FRDIV_MASK) >> MCG_C1_FRDIV_SHIFT));
+        MCGOUTClock = (MCGOUTClock / Divider);  /* Calculate the divided FLL reference clock */
+        if ((MCG->C2 & MCG_C2_RANGE0_MASK) != 0x0u) {
+          MCGOUTClock /= 32u;                                                  /* If high range is enabled, additional 32 divider is active */
+        } /* ((MCG->C2 & MCG_C2_RANGE0_MASK) != 0x0u) */
+      } else { /* (!((MCG->C1 & MCG_C1_IREFS_MASK) == 0x0u)) */
+        MCGOUTClock = CPU_INT_SLOW_CLK_HZ;                                     /* The slow internal reference clock is selected */
+      } /* (!((MCG->C1 & MCG_C1_IREFS_MASK) == 0x0u)) */
+      /* Select correct multiplier to calculate the MCG output clock  */
+      switch (MCG->C4 & (MCG_C4_DMX32_MASK | MCG_C4_DRST_DRS_MASK)) {
+        case 0x0u:
+          MCGOUTClock *= 640u;
+          break;
+        case 0x20u:
+          MCGOUTClock *= 1280u;
+          break;
+        case 0x40u:
+          MCGOUTClock *= 1920u;
+          break;
+        case 0x60u:
+          MCGOUTClock *= 2560u;
+          break;
+        case 0x80u:
+          MCGOUTClock *= 732u;
+          break;
+        case 0xA0u:
+          MCGOUTClock *= 1464u;
+          break;
+        case 0xC0u:
+          MCGOUTClock *= 2197u;
+          break;
+        case 0xE0u:
+          MCGOUTClock *= 2929u;
+          break;
+        default:
+          break;
+      }
+    } else { /* (!((MCG->C6 & MCG_C6_PLLS_MASK) == 0x0u)) */
+      /* PLL is selected */
+      Divider = (1u + (MCG->C5 & MCG_C5_PRDIV0_MASK));
+      MCGOUTClock = (uint32_t)(CPU_XTAL_CLK_HZ / Divider);                     /* Calculate the PLL reference clock */
+      Divider = ((MCG->C6 & MCG_C6_VDIV0_MASK) + 24u);
+      MCGOUTClock *= Divider;                       /* Calculate the MCG output clock */
+    } /* (!((MCG->C6 & MCG_C6_PLLS_MASK) == 0x0u)) */
+  } else if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x40u) {
+    /* Internal reference clock is selected */
+    if ((MCG->C2 & MCG_C2_IRCS_MASK) == 0x0u) {
+      MCGOUTClock = CPU_INT_SLOW_CLK_HZ;                                       /* Slow internal reference clock selected */
+    } else { /* (!((MCG->C2 & MCG_C2_IRCS_MASK) == 0x0u)) */
+      MCGOUTClock = CPU_INT_FAST_CLK_HZ / (1 << ((MCG->SC & MCG_SC_FCRDIV_MASK) >> MCG_SC_FCRDIV_SHIFT));  /* Fast internal reference clock selected */
+    } /* (!((MCG->C2 & MCG_C2_IRCS_MASK) == 0x0u)) */
+  } else if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80u) {
+    /* External reference clock is selected */
+    if ((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u) {
+      MCGOUTClock = CPU_XTAL_CLK_HZ;                                           /* System oscillator drives MCG clock */
+    } else { /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
+      MCGOUTClock = CPU_XTAL32k_CLK_HZ;                                        /* RTC 32 kHz oscillator drives MCG clock */
+    } /* (!((MCG->C7 & MCG_C7_OSCSEL_MASK) == 0x0u)) */
+  } else { /* (!((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80u)) */
+    /* Reserved value */
+    return;
+  } /* (!((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80u)) */
+  SystemCoreClock = (MCGOUTClock / (1u + ((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV1_MASK) >> SIM_CLKDIV1_OUTDIV1_SHIFT)));
+}
diff --git a/keyboard/infinity/k20dx32_flash.cfg b/keyboard/infinity/tool/k20dx32_flash.cfg
similarity index 100%
rename from keyboard/infinity/k20dx32_flash.cfg
rename to keyboard/infinity/tool/k20dx32_flash.cfg
diff --git a/keyboard/infinity/openocd.cfg b/keyboard/infinity/tool/openocd.cfg
similarity index 100%
rename from keyboard/infinity/openocd.cfg
rename to keyboard/infinity/tool/openocd.cfg

From d0fefb76f8a1430c749e67bc72b4dba00c7143c9 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Sun, 4 Jan 2015 17:03:47 +0900
Subject: [PATCH 30/95] infinity: Add initial files for keyboard support

---
 README.md                                     |   2 +
 common/matrix.h                               |   9 +-
 common/mbed/xprintf.cpp                       |   5 +
 keyboard/infinity/MEMO.txt                    | 398 -------------
 keyboard/infinity/Makefile                    |   6 +-
 keyboard/infinity/README                      |  81 +++
 keyboard/infinity/keymap.c                    |  47 ++
 keyboard/infinity/keymap_common.c             |  30 +
 keyboard/infinity/keymap_common.h             |  58 ++
 keyboard/infinity/led.c                       |  25 +
 keyboard/infinity/main.cpp                    |  38 +-
 keyboard/infinity/matrix.c                    | 107 ++++
 keyboard/infinity/mbed-infinity.mk            |   2 +
 keyboard/infinity/mbed-infinity/README        |  39 ++
 .../infinity/mbed-infinity/USBHAL_KL25Z.cpp   | 557 ++++++++++++++++++
 keyboard/infinity/tool/README                 |  25 +
 tool/mbed/lpc11u35_501.mk                     |   1 +
 tool/mbed/mbed.mk                             |  10 +-
 18 files changed, 1029 insertions(+), 411 deletions(-)
 delete mode 100644 keyboard/infinity/MEMO.txt
 create mode 100644 keyboard/infinity/README
 create mode 100644 keyboard/infinity/keymap.c
 create mode 100644 keyboard/infinity/keymap_common.c
 create mode 100644 keyboard/infinity/keymap_common.h
 create mode 100644 keyboard/infinity/led.c
 create mode 100644 keyboard/infinity/matrix.c
 create mode 100644 keyboard/infinity/mbed-infinity/README
 create mode 100644 keyboard/infinity/mbed-infinity/USBHAL_KL25Z.cpp
 create mode 100644 keyboard/infinity/tool/README

diff --git a/README.md b/README.md
index a01de8c6f8..e077fc928d 100644
--- a/README.md
+++ b/README.md
@@ -53,6 +53,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 * [macway](keyboard/macway/)                - [Compact keyboard mod][GH_macway] [retired]
 * [KMAC](keyboard/kmac/)                    - Korean custom keyboard
 * [Lightsaber](keyboard/lightsaber/)        - Korean custom keyboard
+* [Infinity](keyboard/infinity/)            - Massdrop [Infinity keyboard][Infinity]
 
 [GH_macway]:    http://geekhack.org/showwiki.php?title=Island:11930
 [GH_hhkb]:      http://geekhack.org/showwiki.php?title=Island:12047
@@ -72,6 +73,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 [PC98]:         http://en.wikipedia.org/wiki/NEC_PC-9801
 [Sun]:          http://en.wikipedia.org/wiki/Sun-3
 [IIGS]:         http://en.wikipedia.org/wiki/Apple_IIGS
+[Infinity]:     https://www.massdrop.com/buy/infinity-keyboard-kit
 
 
 
diff --git a/common/matrix.h b/common/matrix.h
index 23fef78f74..107ee72653 100644
--- a/common/matrix.h
+++ b/common/matrix.h
@@ -35,6 +35,10 @@ typedef  uint32_t   matrix_row_t;
 #define MATRIX_IS_ON(row, col)  (matrix_get_row(row) && (1<<col))
 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* number of matrix rows */
 uint8_t matrix_rows(void);
 /* number of matrix columns */
@@ -48,7 +52,7 @@ bool matrix_is_modified(void) __attribute__ ((deprecated));
 /* whether a swtich is on */
 bool matrix_is_on(uint8_t row, uint8_t col);
 /* matrix state on row */
-matrix_row_t  matrix_get_row(uint8_t row);
+matrix_row_t matrix_get_row(uint8_t row);
 /* print matrix for debug */
 void matrix_print(void);
 
@@ -57,5 +61,8 @@ void matrix_print(void);
 void matrix_power_up(void);
 void matrix_power_down(void);
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif
diff --git a/common/mbed/xprintf.cpp b/common/mbed/xprintf.cpp
index 4342b79f80..3647ece751 100644
--- a/common/mbed/xprintf.cpp
+++ b/common/mbed/xprintf.cpp
@@ -6,6 +6,10 @@
 
 #define STRING_STACK_LIMIT    120
 
+//TODO
+int xprintf(const char* format, ...) { return 0; }
+
+#if 0
 /* mbed Serial */
 Serial ser(UART_TX, UART_RX);
 
@@ -44,3 +48,4 @@ int xprintf(const char* format, ...)
     return r;
 */
 }
+#endif
diff --git a/keyboard/infinity/MEMO.txt b/keyboard/infinity/MEMO.txt
deleted file mode 100644
index ca0da937d7..0000000000
--- a/keyboard/infinity/MEMO.txt
+++ /dev/null
@@ -1,398 +0,0 @@
-mbed patch for Infinity
------------------------
-Without ld script patch vector table it doesn't place vector table in binary file.
-And clock setting is changed as Infinity uses internal oscillator instead of exteranl crystal.
-
-diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
-index 600751c..55c3393 100644
---- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
-+++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
-@@ -43,7 +43,7 @@ SECTIONS
-     .isr_vector :
-     {
-         __vector_table = .;
--        KEEP(*(.vector_table))
-+        KEEP(*(.isr_vector))
-         *(.text.Reset_Handler)
-         *(.text.System_Init)
-          . = ALIGN(4);
-diff --git a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
-index 393d1f0..b78b71a 100644
---- a/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
-+++ b/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
-@@ -44,7 +44,7 @@
-
- #define DISABLE_WDOG    1
-
--#define CLOCK_SETUP     1
-+#define CLOCK_SETUP     0
- /* Predefined clock setups
-    0 ... Multipurpose Clock Generator (MCG) in FLL Engaged Internal (FEI) mode
-          Reference clock source for MCG module is the slow internal clock source 32.768kHz
-
-
-
-CMSIS/mbed HAL
-==============
-http://developer.mbed.org/users/MACRUM/notebook/mbed-library-internals/
-
-api/        mbed API
-├── AnalogIn.h
-├── AnalogOut.h
-├── BusIn.h
-├── BusInOut.h
-├── BusOut.h
-├── CallChain.h
-├── CAN.h
-├── can_helper.h
-├── DigitalIn.h
-├── DigitalInOut.h
-├── DigitalOut.h
-├── DirHandle.h
-├── Ethernet.h
-├── FileBase.h
-├── FileHandle.h
-├── FileLike.h
-├── FilePath.h
-├── FileSystemLike.h
-├── FunctionPointer.h
-├── I2C.h
-├── I2CSlave.h
-├── InterruptIn.h
-├── InterruptManager.h
-├── LocalFileSystem.h
-├── mbed_assert.h
-├── mbed_debug.h
-├── mbed_error.h
-├── mbed.h
-├── mbed_interface.h
-├── platform.h
-├── PortIn.h
-├── PortInOut.h
-├── PortOut.h
-├── PwmOut.h
-├── RawSerial.h
-├── rtc_time.h
-├── semihost_api.h
-├── SerialBase.h
-├── Serial.h
-├── SPI.h
-├── SPISlave.h
-├── Stream.h
-├── Ticker.h
-├── Timeout.h
-├── TimerEvent.h
-├── Timer.h
-├── toolchain.h
-└── wait_api.h
-
-common/     mbed API implementation
-
-hal/        mbed HAL implementation interface
-├── analogin_api.h
-├── analogout_api.h
-├── can_api.h
-├── ethernet_api.h
-├── gpio_api.h
-├── gpio_irq_api.h
-├── i2c_api.h
-├── pinmap.h
-├── port_api.h
-├── pwmout_api.h
-├── rtc_api.h
-├── serial_api.h
-├── sleep_api.h
-├── spi_api.h
-└── us_ticker_api.h
-
-targets/hal/TARGET_<vendor>/TARGET_<board>/
-    mbed HAL implementation
-
-targets/cmsis/      CMSIS interface
-    core_caInstr.h
-    core_ca9.h
-    core_cmFunc.h
-    core_caFunc.h
-    core_cmInstr.h
-    core_cm4_simd.h
-    core_ca_mmu.h
-    core_cm0.h
-    core_cm0plus.h
-    core_cm3.h
-    core_cm4.h
-
-targets/cmsis/TARGET_<vendor>/TARGET_<chip>/
-    <chip>.h
-    system_<chip>.[ch]
-    cmsis.h 
-    cmsis_nvic.[ch]
-
-targets/cmsis/TARGET_<vendor>/TARGET_<chip>/TOOLSCHAIN_<tool>/
-    startup_<chip>.s
-    linker-script
-
-
-
-Infinity
-========
-Massdrop Infinity Keyboard:
-https://www.massdrop.com/buy/infinity-keyboard-kit
-
-Freescale MK20DX128VLF5 48-QFP:
-http://cache.freescale.com/files/32bit/doc/data_sheet/K20P48M50SF0.pdf
-
-kiibohd controller(MD1):
-https://github.com/kiibohd/controller
-
-DFU bootloader:
-https://github.com/kiibohd/controller/tree/master/Bootloader
-
-Program with bootloader:
-    $ dfu-util -D kiibohd.dfu.bin
-
-Pinout:
-https://github.com/kiibohd/controller/blob/master/Scan/MD1/pinout
-
-
-
-Pin Usage
-=========
-
-mk20dx128vlf5
-
- ----
-|Keys|
- ----
-
-* Strobe (Columns)
-
-PTB0
-PTB1
-PTB2
-PTB3
-PTB16
-PTB17
-PTC4
-PTC5
-PTD0
-
-
-* Sense (Rows)
-
-PTD1
-PTD2
-PTD3
-PTD4
-PTD5
-PTD6
-PTD7
-
-
- -----
-|Debug|
- -----
-
-* SWD
-
-PTA0 (Pull-down)
-PTA3 (Pull-up)
-
-* LEDs
-
-PTA19 (LED only for PCB, not McHCK) (XTAL)
-
-* UARTs
-
-PTA1 - RX0
-PTA2 - TX0
-
-
- ------
-|Unused|
- ------
-
-* GPIO
-
-PTA1 (Not broken out on PCB, available on McHCK) (Pull-up)
-PTA2 (")
-PTA4 (Pull-up)
-PTA18 (EXTAL)
-
-PTC0
-PTC1
-PTC2
-PTC3
-PTC6
-PTC7
-
-* Analog
-
-ADC0_DP0
-ADC0_DM0
-
-
-
-Freescale kinetis MK20DX128
-===========================
-If FSEC of flash config at 0x400-40F is changed accidentally SWD/JTAG debug access will be lost and very difficult to get back.
-For example, high level adapter like stlink cannot work to get access back after FSEC is changed. To regain the chip to be programmable low level DAP inteface like JTAG, CMSIS-DAP or OpenSAD.
-
-
-Memory map
-==========
-kiibohd bootloader: Lib/mk20dx128vlf5.bootloader.ld
-0x0000_0000 +-------------------+ -----------------+---------------+
-            | .vectors          | ---------.       | StackPointer0 |
-            | .startup          |           \      | ResetHandler1 |
-            | .rodata           |            \     | ...           |
-0x0000_0400 | .flashconfig      | 0x10        \    | ...           |
-            | .text             |              \   | ...        61 | 0xF7
-            | .init             |               `--+---------------+ 0xF8
-0x0000_1000 +-------------------+ 4KB
-            | _app_rom          |
-            ~                   ~
-            ~                   ~
-            |                   |
-0x07FF_FFFF +-------------------+ 128KB
-
-
-0x1FFF_E000 +-------------------+
-            |                   |
-            | RAM               |
-            |                8KB|
-0x2000_0000 +-------------------+
-            |                   |
-            | RAM               |
-            |                8KB|
-0x2000_2000 +-------------------+ _estack
-
-
-
-
-
-OpenOCD
-========
-Synopsis of SWD, JTAG and SWJ-DP transport:
-https://fedcsis.org/proceedings/2012/pliks/279.pdf
-
-OpenSDA Freescale: Mass storage bootloader & serial port; part of CMSIS-DAP?
-http://cache.freescale.com/files/32bit/doc/user_guide/OPENSDAUG.pdf
-
-
-interface_list:
-    1: ftdi
-    2: usb_blaster
-    3: usbprog
-    4: jlink
-    5: vsllink
-    6: rlink
-    7: ulink
-    8: arm-jtag-ew
-    9: hla
-    10: osbdm
-    11: opendous
-    12: aice
-    13: cmsis-dap
-
-transport list:
-    stlink_swim
-    hla_jtag
-    hla_swd
-    aice_jtag
-    swd
-    cmsis-dap
-    jtag
-
-target types:
-    arm7tdmi
-    arm9tdmi
-    arm920t
-    arm720t
-    arm966e
-    arm946e
-    arm926ejs
-    fa526
-    feroceon
-    dragonite
-    xscale
-    cortex_m
-    cortex_a
-    cortex_r4
-    arm11
-    mips_m4k
-    avr
-    dsp563xx
-    dsp5680xx
-    testee
-    avr32_ap7k
-    hla_target
-    nds32_v2
-    nds32_v3
-    nds32_v3m
-    or1k
-    quark_x10xx
-
-
-TAP
----
-http://openocd.sourceforge.net/doc/html/TAP-Declaration.html#TAP-Declaration
-    jtag newtap chipname tapname configparams...
-    hla newtap chipname tapname configparams...
-    swd newtap chipname tapname configparams...
-    cmsis-dap newtap chipname tapname configparams...
-
-        The tapname reflects the role of that TAP, and should follow this convention:
-        bs – For boundary scan if this is a separate TAP;
-        cpu – The main CPU of the chip, alternatively arm and dsp on chips with both ARM and DSP CPUs, arm1 and arm2 on chips with two ARMs, and so forth;
-        etb – For an embedded trace buffer (example: an ARM ETB11);
-        flash – If the chip has a flash TAP, like the str912;
-        jrc – For JTAG route controller (example: the ICEPick modules on many Texas Instruments chips, like the OMAP3530 on Beagleboards);
-        tap – Should be used only for FPGA- or CPLD-like devices with a single TAP;
-        unknownN – If you have no idea what the TAP is for (N is a number);
-        when in doubt – Use the chip maker's name in their data sheet. For example, the Freescale i.MX31 has a SDMA (Smart DMA) with a JTAG TAP; that TAP should be named sdma.
-
--irlen NUMBER 
-The length in bits of the instruction register, such as 4 or 5 bits.
-
-Target
-------
-http://openocd.sourceforge.net/doc/html/CPU-Configuration.html#CPU-Configuration
-
-    target create target_name type configparams...
-    $target_name configure configparams...
-
-        -chain-position dotted.name – names the TAP used to access this target.
-        -endian (big|little) – specifies whether the CPU uses big or little endian conventions
-        -event event_name event_body – See Target Events. Note that this updates a list of named event handlers. Calling this twice with two different event names assigns two different handlers, but calling it twice with the same event name assigns only one handler.
-        -work-area-backup (0|1) – says whether the work area gets backed up; by default, it is not backed up. When possible, use a working_area that doesn't need to be backed up, since performing a backup slows down operations. For example, the beginning of an SRAM block is likely to be used by most build systems, but the end is often unused.
-        -work-area-size size – specify work are size, in bytes. The same size applies regardless of whether its physical or virtual address is being used.
-        -work-area-phys address – set the work area base address to be used when no MMU is active.
-        -work-area-virt address – set the work area base address to be used when an MMU is active. Do not specify a value for this except on targets with an MMU. The value should normally correspond to a static mapping for the -work-area-phys address, set up by the current operating system.
-        -rtos rtos_type – enable rtos support for target, rtos_type can be one of auto|eCos|ThreadX| FreeRTOS|linux|ChibiOS|embKernel See RTOS Support.
-
-Flash
------
-http://openocd.sourceforge.net/doc/html/Flash-Commands.html#norconfiguration
-
-    flash bank name driver base size chip_width bus_width target [driver_options]
-
-        name ... may be used to reference the flash bank in other flash commands. A number is also available.
-        driver ... identifies the controller driver associated with the flash bank being declared. This is usually cfi for external flash, or else the name of a microcontroller with embedded flash memory. See Flash Driver List.
-        base ... Base address of the flash chip.
-        size ... Size of the chip, in bytes. For some drivers, this value is detected from the hardware.
-        chip_width ... Width of the flash chip, in bytes; ignored for most microcontroller drivers.
-        bus_width ... Width of the data bus used to access the chip, in bytes; ignored for most microcontroller drivers.
-        target ... Names the target used to issue commands to the flash controller.
-        driver_options ... drivers may support, or require, additional parameters. See the driver-specific documentation for more information.
-
-    flash write_image [erase] [unlock] filename [offset] [type]
-
-
-Memory Access
--------------
-http://openocd.sourceforge.net/doc/html/General-Commands.html#imageaccess
-    {mdw,mdh,mdb} addr [count]
-        dump {word, half-word, byte} data
-    {mww,mwh,mwb} addr data
-        write data
-
diff --git a/keyboard/infinity/Makefile b/keyboard/infinity/Makefile
index e97f759dfa..758296f335 100644
--- a/keyboard/infinity/Makefile
+++ b/keyboard/infinity/Makefile
@@ -11,6 +11,10 @@ vpath %.cpp .:$(MBED_DIR):$(TMK_DIR)
 OBJDIR = ./build
 
 OBJECTS = \
+	$(OBJDIR)/matrix.o \
+	$(OBJDIR)/keymap.o \
+	$(OBJDIR)/keymap_common.o \
+	$(OBJDIR)/led.o \
 	$(OBJDIR)/main.o
 
 CONFIG_H = config.h
@@ -29,5 +33,5 @@ include $(TMK_DIR)/tool/mbed/mbed.mk
 include $(TMK_DIR)/tool/mbed/common.mk
 include $(TMK_DIR)/tool/mbed/gcc.mk
 
-program:
+program: $(OBJDIR)/$(PROJECT).bin
 	dfu-util -D $(OBJDIR)/$(PROJECT).bin
diff --git a/keyboard/infinity/README b/keyboard/infinity/README
new file mode 100644
index 0000000000..53d1c91737
--- /dev/null
+++ b/keyboard/infinity/README
@@ -0,0 +1,81 @@
+Infinity
+========
+Massdrop Infinity Keyboard:
+https://www.massdrop.com/buy/infinity-keyboard-kit
+
+kiibohd controller(MD1):
+https://github.com/kiibohd/controller
+
+DFU bootloader:
+https://github.com/kiibohd/controller/tree/master/Bootloader
+
+Program with bootloader:
+    $ dfu-util -D kiibohd.dfu.bin
+
+Pinout:
+https://github.com/kiibohd/controller/blob/master/Scan/MD1/pinout
+
+MCHCK compatible:
+https://mchck.org/about/
+
+MCU Freescale MK20DX128VLF5 48-QFP:
+http://cache.freescale.com/files/32bit/doc/data_sheet/K20P48M50SF0.pdf
+
+
+
+Pin Usage
+=========
+Key Matrix:
+    Strobe(output high):            PTB0 PTB1 PTB2 PTB3 PTB16 PTB17 PTC4 PTC5 PTD0
+    Sense(input with pull-down):    PTD1 PTD2 PTD3 PTD4 PTD5 PTD6 PTD7
+
+
+SWD pinout:
+    SWD_CLK(PTA0) SWD_DIO(PTA3)
+    SWD pins are placed next to reset button; SWD_CLK, SWD_DIO, GND, VCC from top.
+    Note that RESET is also needed to get full control with OpenOCD.
+
+LED:
+    PTA19(turns on with output high)
+
+
+
+Memory map
+==========
+kiibohd bootloader: Lib/mk20dx128vlf5.bootloader.ld
+0x0000_0000 +-------------------+ -----------------+---------------+ Vector table
+            | .vectors          | ------------.    | StackPointer0 |     of Bootloader
+            | .startup          |              \   | ResetHandler1 |
+            | .rodata           |               `--+---------------+ 0xF8
+0x0000_0400 | .flashconfig(0x10)| 
+      _0410 | .text             |
+            | .init             |
+0x0000_1000 +-------------------+ -----------------+---------------+ Vector table
+            | _app_rom          | ------------.    |               |     of App
+            |                   |              \   |               |
+            |                   |               `--+---------------+
+            |                   |
+            ~                   ~
+            |                   |
+0x07FF_FFFF +-------------------+ 128KB
+
+
+0x1FFF_E000 +-------------------+ -----------------+---------------+ Vector table
+      _E0F8 |                   | ------------.    |               |     of App(copied)
+            |                   |              \   |               |  
+            |                   |               `--+---------------+ mbed NVIC
+            |                   |
+            | RAM               |
+            |                8KB|
+0x2000_0000 +-------------------+
+            |                   |
+            |                   |
+            |                   |
+            |                   |
+            | RAM               |
+            |                8KB|
+0x2000_2000 +-------------------+ _estack
+
+
+
+
diff --git a/keyboard/infinity/keymap.c b/keyboard/infinity/keymap.c
new file mode 100644
index 0000000000..100142f41c
--- /dev/null
+++ b/keyboard/infinity/keymap.c
@@ -0,0 +1,47 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* Layer 0: Default Layer
+     * ,-----------------------------------------------------------.
+     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  `|BSp|
+     * |-----------------------------------------------------------|
+     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+     * |-----------------------------------------------------------|
+     * |Contro|  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Enter   |
+     * |-----------------------------------------------------------|
+     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Fn0|
+     * |-----------------------------------------------------------'
+     * |     |Gui|Alt  |         Space         |Alt  |Gui|   |     |
+     * `-----------------------------------------------------------'
+     */
+    [0] =
+    KEYMAP(ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSLS, GRV, \
+           TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSPC, \
+           LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,  \
+           LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,FN0, \
+           NO,  LGUI,LALT,          SPC,                RALT,RGUI,NO, NO),
+    /* Layer 1: HHKB mode (HHKB Fn)
+     * ,-----------------------------------------------------------.
+     * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+     * |-----------------------------------------------------------|
+     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |Backs|
+     * |-----------------------------------------------------------|
+     * |      |VoD|VoU|Mut|   |   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
+     * |-----------------------------------------------------------|
+     * |        |   |   |   |   |   |  +|  -|End|PgD|Dow|      |   |
+     * `-----------------------------------------------------------'
+     * |     |Gui|Alt  |         Space         |Alt  |Gui|   |     |
+     * `-----------------------------------------------------------'
+     */ 
+    [1]= 
+    KEYMAP(PWR, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL,   \
+           CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC,      \
+           TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT,            \
+           TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS,            \
+           TRNS,TRNS,TRNS,          TRNS,               TRNS,TRNS,TRNS,TRNS),
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(1),
+};
+
diff --git a/keyboard/infinity/keymap_common.c b/keyboard/infinity/keymap_common.c
new file mode 100644
index 0000000000..fdb1769e1c
--- /dev/null
+++ b/keyboard/infinity/keymap_common.c
@@ -0,0 +1,30 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "keymap_common.h"
+
+
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+    return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
+}
diff --git a/keyboard/infinity/keymap_common.h b/keyboard/infinity/keymap_common.h
new file mode 100644
index 0000000000..7a5f778f2d
--- /dev/null
+++ b/keyboard/infinity/keymap_common.h
@@ -0,0 +1,58 @@
+/*
+Copyright 2014 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef KEYMAP_COMMON_H
+#define KEYMAP_COMMON_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "print.h"
+#include "debug.h"
+#include "keymap.h"
+
+
+extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+
+/* GH60 keymap definition macro
+ * K2C, K31 and  K3C are extra keys for ISO
+ */
+#define KEYMAP( \
+    K00, K10, K20, K30, K40, K50, K60, K70, K80, K01, K11, K21, K31, K41, K86, \
+    K51, K61, K71, K81, K02, K12, K22, K32, K42, K52, K62, K72, K82, K03, \
+    K13, K23, K33, K43, K53, K63, K73, K83, K04, K14, K24, K34, K44, \
+    K54, K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, \
+    K06, K16, K26,           K36,                K46, K56, K66, K76 \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06 }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16 }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36 }, \
+    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46 }, \
+    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56 }, \
+    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66 }, \
+    { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76 }, \
+    { KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86 }  \
+}
+
+#endif
+
diff --git a/keyboard/infinity/led.c b/keyboard/infinity/led.c
new file mode 100644
index 0000000000..b7e638b254
--- /dev/null
+++ b/keyboard/infinity/led.c
@@ -0,0 +1,25 @@
+/*
+Copyright 2011 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdint.h"
+#include "led.h"
+
+
+/* HHKB has no LEDs */
+void led_set(uint8_t usb_led)
+{
+}
diff --git a/keyboard/infinity/main.cpp b/keyboard/infinity/main.cpp
index f28840d3ef..847668a1de 100644
--- a/keyboard/infinity/main.cpp
+++ b/keyboard/infinity/main.cpp
@@ -1,20 +1,44 @@
-//#include "mbed.h"
 #include "MK20D5.h"
 #include "wait.h"
 #include "gpio_api.h"
 #include "PinNames.h"
+#include "matrix.h"
+#include "timer.h"
+
+#include "action.h"
+#include "keycode.h"
+#include "host.h"
+#include "host_driver.h"
+#include "mbed_driver.h"
 
 
 int main() {
     gpio_t led;
     gpio_init_out(&led, PTA19);
+
+    uint16_t t = 0;
+
+    host_set_driver(&mbed_driver);
+    keyboard_init();
+
     while(1) {
-        wait_ms(500);
-        uint32_t delay = 0xf;
-        while (delay--) {
-            uint32_t delay2 = 0xffff;
-            while (delay2--) ;
+        keyboard_task();
+
+        bool matrix_on = false;
+        matrix_scan();
+        for (int i = 0; i < MATRIX_ROWS; i++) {
+            if (matrix_get_row(i)) {
+                matrix_on = true;
+                break;
+            }
+        }
+        if (matrix_on)
+            gpio_write(&led, 1);
+        else {
+            if (timer_elapsed(t) > 500) {
+                gpio_write(&led, !gpio_read(&led));
+                t = timer_read();
+            }
         }
-        gpio_write(&led, !gpio_read(&led));
     }
 }
diff --git a/keyboard/infinity/matrix.c b/keyboard/infinity/matrix.c
new file mode 100644
index 0000000000..478a40fd9e
--- /dev/null
+++ b/keyboard/infinity/matrix.c
@@ -0,0 +1,107 @@
+#include <stdint.h>
+#include <stdbool.h>
+#include "gpio_api.h"
+#include "timer.h"
+#include "wait.h"
+#include "matrix.h"
+
+
+#ifndef DEBOUNCE
+#define DEBOUNCE    5
+#endif
+
+/*
+ * Infinity Pinusage:
+ * Column pins are input with internal pull-down. Row pins are output and strobe with high.
+ * Key is high or 1 when it turns on.
+ *
+ *     col: { PTD1, PTD2, PTD3, PTD4, PTD5, PTD6, PTD7 }
+ *     row: { PTB0, PTB1, PTB2, PTB3, PTB16, PTB17, PTC4, PTC5, PTD0 }
+ */
+static gpio_t col[MATRIX_COLS];
+static gpio_t row[MATRIX_ROWS];
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+static bool debouncing = false;
+static uint16_t debouncing_time = 0;
+
+
+void matrix_init(void)
+{
+    /* Column(sense) */
+    gpio_init_in_ex(&col[0], PTD1, PullDown);
+    gpio_init_in_ex(&col[1], PTD2, PullDown);
+    gpio_init_in_ex(&col[2], PTD3, PullDown);
+    gpio_init_in_ex(&col[3], PTD4, PullDown);
+    gpio_init_in_ex(&col[4], PTD5, PullDown);
+    gpio_init_in_ex(&col[5], PTD6, PullDown);
+    gpio_init_in_ex(&col[6], PTD7, PullDown);
+
+    /* Row(strobe) */
+    gpio_init_out_ex(&row[0], PTB0, 0);
+    gpio_init_out_ex(&row[1], PTB1, 0);
+    gpio_init_out_ex(&row[2], PTB2, 0);
+    gpio_init_out_ex(&row[3], PTB3, 0);
+    gpio_init_out_ex(&row[4], PTB16, 0);
+    gpio_init_out_ex(&row[5], PTB17, 0);
+    gpio_init_out_ex(&row[6], PTC4, 0);
+    gpio_init_out_ex(&row[7], PTC5, 0);
+    gpio_init_out_ex(&row[8], PTD0, 0);
+}
+
+uint8_t matrix_scan(void)
+{
+    for (int i = 0; i < MATRIX_ROWS; i++) {
+        matrix_row_t r = 0;
+
+        gpio_write(&row[i], 1);
+        wait_us(1); // need wait to settle pin state
+        for (int j = 0; j < MATRIX_COLS; j++) {
+            if (gpio_read(&col[j])) {
+                r |= (1<<j);
+            }
+        }
+        gpio_write(&row[i], 0);
+
+        if (matrix_debouncing[i] != r) {
+            matrix_debouncing[i] = r;
+            debouncing = true;
+            debouncing_time = timer_read();
+        }
+    }
+
+    if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
+        for (int i = 0; i < MATRIX_ROWS; i++) {
+            matrix[i] = matrix_debouncing[i];
+        }
+        debouncing = false;
+    }
+/*
+    if (debouncing) {
+        if (--debouncing) {
+            return 0;
+        } else {
+            for (int i = 0; i < MATRIX_ROWS; i++) {
+                matrix[i] = matrix_debouncing[i];
+            }
+        }
+    }
+*/
+    return 1;
+}
+
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+    return (matrix[row] & (1<<col));
+}
+
+matrix_row_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void matrix_print(void)
+{
+}
diff --git a/keyboard/infinity/mbed-infinity.mk b/keyboard/infinity/mbed-infinity.mk
index cd4434a230..f5fd2c9975 100644
--- a/keyboard/infinity/mbed-infinity.mk
+++ b/keyboard/infinity/mbed-infinity.mk
@@ -4,6 +4,7 @@
 CPU = -mcpu=cortex-m4 -mthumb
 
 CC_SYMBOLS += \
+	-DTARGET_INFINITY \
 	-DTARGET_K20D50M \
 	-DTARGET_M4 \
 	-DTARGET_CORTEX_M \
@@ -17,6 +18,7 @@ CC_SYMBOLS += \
 OBJECTS += \
 	$(OBJDIR)/mbed-infinity/cmsis_nvic.o \
 	$(OBJDIR)/mbed-infinity/system_MK20D5.o \
+	$(OBJDIR)/mbed-infinity/USBHAL_KL25Z.o \
 	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/startup_MK20D5.o \
 	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/analogin_api.o \
 	$(OBJDIR)/libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/gpio_api.o \
diff --git a/keyboard/infinity/mbed-infinity/README b/keyboard/infinity/mbed-infinity/README
new file mode 100644
index 0000000000..b0d226f793
--- /dev/null
+++ b/keyboard/infinity/mbed-infinity/README
@@ -0,0 +1,39 @@
+mbed fix for Infinity
+=====================
+Without linker script patch it doesn't place vector table in final binary.
+And clock is configured to 48MHz using internal clock reference and FLL multiplication.
+
+
+mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/system_MK20D5.c
+    Fix SystemInit: clock setup for internal clock. Inifinity has no external Xtal.
+
+mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/cmsis_nvic.c
+    Fix NVIC vector address of firmware 0x1000 instead of 0x0
+
+mbed/targets/cmsis/TARGET_Freescale/TARGET_K20D50M/TOOLCHAIN_GCC_ARM/MK20D5.ld
+    Fix memory map for Infinity bootloader
+        Flash starts at 0x1000
+        No flash config bytes sector
+
+USBDevice/USBDevice/USBHAL_KL25Z.cpp
+    Fix USB clock setup, see below.
+
+
+2015/01/04  Based on mbed-sdk @2f63fa7d78a26.
+
+
+
+Kinetis USB config
+==================
+Clock source: Internal reference clock wth FLL
+    SIM_SOPT[USBSRC] = 1(MCGPLLCLK/MCGFLLCLK)
+    SIM_SOPT[PLLSEL] = 0(MCGFLLCLK)
+
+Clock dividor:
+    SIM_CLKDIV2[USBDIV] = 0
+    SIM_CLKDIV2[USBFAC] = 0
+
+Clock enable:
+    SIM_SCGC4[USBOTG] = 1
+
+
diff --git a/keyboard/infinity/mbed-infinity/USBHAL_KL25Z.cpp b/keyboard/infinity/mbed-infinity/USBHAL_KL25Z.cpp
new file mode 100644
index 0000000000..90f02fa322
--- /dev/null
+++ b/keyboard/infinity/mbed-infinity/USBHAL_KL25Z.cpp
@@ -0,0 +1,557 @@
+/* Copyright (c) 2010-2011 mbed.org, MIT License
+*
+* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+* and associated documentation files (the "Software"), to deal in the Software without
+* restriction, including without limitation the rights to use, copy, modify, merge, publish,
+* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
+* Software is furnished to do so, subject to the following conditions:
+*
+* The above copyright notice and this permission notice shall be included in all copies or
+* substantial portions of the Software.
+*
+* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#if defined(TARGET_KL25Z) | defined(TARGET_KL43Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D50M) | defined(TARGET_K64F) | defined(TARGET_K22F)
+
+#include "USBHAL.h"
+
+USBHAL * USBHAL::instance;
+
+static volatile int epComplete = 0;
+
+// Convert physical endpoint number to register bit
+#define EP(endpoint) (1<<(endpoint))
+
+// Convert physical to logical
+#define PHY_TO_LOG(endpoint)    ((endpoint)>>1)
+
+// Get endpoint direction
+#define IN_EP(endpoint)     ((endpoint) & 1U ? true : false)
+#define OUT_EP(endpoint)    ((endpoint) & 1U ? false : true)
+
+#define BD_OWN_MASK        (1<<7)
+#define BD_DATA01_MASK     (1<<6)
+#define BD_KEEP_MASK       (1<<5)
+#define BD_NINC_MASK       (1<<4)
+#define BD_DTS_MASK        (1<<3)
+#define BD_STALL_MASK      (1<<2)
+
+#define TX    1
+#define RX    0
+#define ODD   0
+#define EVEN  1
+// this macro waits a physical endpoint number
+#define EP_BDT_IDX(ep, dir, odd) (((ep * 4) + (2 * dir) + (1 *  odd)))
+
+#define SETUP_TOKEN    0x0D
+#define IN_TOKEN       0x09
+#define OUT_TOKEN      0x01
+#define TOK_PID(idx)   ((bdt[idx].info >> 2) & 0x0F)
+
+// for each endpt: 8 bytes
+typedef struct BDT {
+    uint8_t   info;       // BD[0:7]
+    uint8_t   dummy;      // RSVD: BD[8:15]
+    uint16_t  byte_count; // BD[16:32]
+    uint32_t  address;    // Addr
+} BDT;
+
+
+// there are:
+//    * 16 bidirectionnal endpt -> 32 physical endpt
+//    * as there are ODD and EVEN buffer -> 32*2 bdt
+__attribute__((__aligned__(512))) BDT bdt[NUMBER_OF_PHYSICAL_ENDPOINTS * 2];
+uint8_t * endpoint_buffer[(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2];
+uint8_t * endpoint_buffer_iso[2*2];
+
+static uint8_t set_addr = 0;
+static uint8_t addr = 0;
+
+static uint32_t Data1  = 0x55555555;
+
+static uint32_t frameNumber() {
+    return((USB0->FRMNUML | (USB0->FRMNUMH << 8)) & 0x07FF);
+}
+
+uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
+    return 0;
+}
+
+USBHAL::USBHAL(void) {
+    // Disable IRQ
+    NVIC_DisableIRQ(USB0_IRQn);
+
+#if defined(TARGET_K64F)
+    MPU->CESR=0;
+#endif
+    // fill in callback array
+    epCallback[0] = &USBHAL::EP1_OUT_callback;
+    epCallback[1] = &USBHAL::EP1_IN_callback;
+    epCallback[2] = &USBHAL::EP2_OUT_callback;
+    epCallback[3] = &USBHAL::EP2_IN_callback;
+    epCallback[4] = &USBHAL::EP3_OUT_callback;
+    epCallback[5] = &USBHAL::EP3_IN_callback;
+    epCallback[6] = &USBHAL::EP4_OUT_callback;
+    epCallback[7] = &USBHAL::EP4_IN_callback;
+    epCallback[8] = &USBHAL::EP5_OUT_callback;
+    epCallback[9] = &USBHAL::EP5_IN_callback;
+    epCallback[10] = &USBHAL::EP6_OUT_callback;
+    epCallback[11] = &USBHAL::EP6_IN_callback;
+    epCallback[12] = &USBHAL::EP7_OUT_callback;
+    epCallback[13] = &USBHAL::EP7_IN_callback;
+    epCallback[14] = &USBHAL::EP8_OUT_callback;
+    epCallback[15] = &USBHAL::EP8_IN_callback;
+    epCallback[16] = &USBHAL::EP9_OUT_callback;
+    epCallback[17] = &USBHAL::EP9_IN_callback;
+    epCallback[18] = &USBHAL::EP10_OUT_callback;
+    epCallback[19] = &USBHAL::EP10_IN_callback;
+    epCallback[20] = &USBHAL::EP11_OUT_callback;
+    epCallback[21] = &USBHAL::EP11_IN_callback;
+    epCallback[22] = &USBHAL::EP12_OUT_callback;
+    epCallback[23] = &USBHAL::EP12_IN_callback;
+    epCallback[24] = &USBHAL::EP13_OUT_callback;
+    epCallback[25] = &USBHAL::EP13_IN_callback;
+    epCallback[26] = &USBHAL::EP14_OUT_callback;
+    epCallback[27] = &USBHAL::EP14_IN_callback;
+    epCallback[28] = &USBHAL::EP15_OUT_callback;
+    epCallback[29] = &USBHAL::EP15_IN_callback;
+
+#if defined(TARGET_KL43Z)
+    // enable USBFS clock
+    SIM->SCGC4 |= SIM_SCGC4_USBFS_MASK;
+
+    // enable the IRC48M clock
+    USB0->CLK_RECOVER_IRC_EN |= USB_CLK_RECOVER_IRC_EN_IRC_EN_MASK;
+
+    // enable the USB clock recovery tuning
+    USB0->CLK_RECOVER_CTRL |= USB_CLK_RECOVER_CTRL_CLOCK_RECOVER_EN_MASK;
+
+    // choose usb src clock
+    SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK;
+#elif defined(TARGET_INFINITY)
+    // USB clock source: FLL
+    SIM->SOPT2 |= SIM_SOPT2_USBSRC_MASK;
+
+    // enable OTG clock
+    SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK;
+#else
+    // choose usb src as PLL
+    SIM->SOPT2 &= ~SIM_SOPT2_PLLFLLSEL_MASK;
+    SIM->SOPT2 |= (SIM_SOPT2_USBSRC_MASK | (1 << SIM_SOPT2_PLLFLLSEL_SHIFT));
+
+    // enable OTG clock
+    SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK;
+#endif
+
+    // Attach IRQ
+    instance = this;
+    NVIC_SetVector(USB0_IRQn, (uint32_t)&_usbisr);
+    NVIC_EnableIRQ(USB0_IRQn);
+
+    // USB Module Configuration
+    // Reset USB Module
+    USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
+    while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
+
+    // Set BDT Base Register
+    USB0->BDTPAGE1 = (uint8_t)((uint32_t)bdt>>8);
+    USB0->BDTPAGE2 = (uint8_t)((uint32_t)bdt>>16);
+    USB0->BDTPAGE3 = (uint8_t)((uint32_t)bdt>>24);
+
+    // Clear interrupt flag
+    USB0->ISTAT = 0xff;
+
+    // USB Interrupt Enablers
+    USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK |
+                   USB_INTEN_SOFTOKEN_MASK |
+                   USB_INTEN_ERROREN_MASK  |
+                   USB_INTEN_USBRSTEN_MASK;
+
+    // Disable weak pull downs
+    USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK);
+
+    USB0->USBTRC0 |= 0x40;
+}
+
+USBHAL::~USBHAL(void) { }
+
+void USBHAL::connect(void) {
+    // enable USB
+    USB0->CTL |= USB_CTL_USBENSOFEN_MASK;
+    // Pull up enable
+    USB0->CONTROL |= USB_CONTROL_DPPULLUPNONOTG_MASK;
+}
+
+void USBHAL::disconnect(void) {
+    // disable USB
+    USB0->CTL &= ~USB_CTL_USBENSOFEN_MASK;
+    // Pull up disable
+    USB0->CONTROL &= ~USB_CONTROL_DPPULLUPNONOTG_MASK;
+
+    //Free buffers if required:
+    for (int i = 0; i<(NUMBER_OF_PHYSICAL_ENDPOINTS - 2) * 2; i++) {
+        free(endpoint_buffer[i]);
+        endpoint_buffer[i] = NULL;
+    }
+    free(endpoint_buffer_iso[2]);
+    endpoint_buffer_iso[2] = NULL;
+    free(endpoint_buffer_iso[0]);
+    endpoint_buffer_iso[0] = NULL;
+}
+
+void USBHAL::configureDevice(void) {
+    // not needed
+}
+
+void USBHAL::unconfigureDevice(void) {
+    // not needed
+}
+
+void USBHAL::setAddress(uint8_t address) {
+    // we don't set the address now otherwise the usb controller does not ack
+    // we set a flag instead
+    // see usbisr when an IN token is received
+    set_addr = 1;
+    addr = address;
+}
+
+bool USBHAL::realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t flags) {
+    uint32_t handshake_flag = 0;
+    uint8_t * buf;
+
+    if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
+        return false;
+    }
+
+    uint32_t log_endpoint = PHY_TO_LOG(endpoint);
+
+    if ((flags & ISOCHRONOUS) == 0) {
+        handshake_flag = USB_ENDPT_EPHSHK_MASK;
+        if (IN_EP(endpoint)) {
+            if (endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)] == NULL)
+                endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)] = (uint8_t *) malloc (64*2);
+            buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, TX, ODD)][0];
+        } else {
+            if (endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)] == NULL)
+                endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)] = (uint8_t *) malloc (64*2);
+            buf = &endpoint_buffer[EP_BDT_IDX(log_endpoint, RX, ODD)][0];
+        }
+    } else {
+        if (IN_EP(endpoint)) {
+            if (endpoint_buffer_iso[2] == NULL)
+                endpoint_buffer_iso[2] = (uint8_t *) malloc (1023*2);
+            buf = &endpoint_buffer_iso[2][0];
+        } else {
+            if (endpoint_buffer_iso[0] == NULL)
+                endpoint_buffer_iso[0] = (uint8_t *) malloc (1023*2);
+            buf = &endpoint_buffer_iso[0][0];
+        }
+    }
+
+    // IN endpt -> device to host (TX)
+    if (IN_EP(endpoint)) {
+        USB0->ENDPOINT[log_endpoint].ENDPT |= handshake_flag |        // ep handshaking (not if iso endpoint)
+                                              USB_ENDPT_EPTXEN_MASK;  // en TX (IN) tran
+        bdt[EP_BDT_IDX(log_endpoint, TX, ODD )].address = (uint32_t) buf;
+        bdt[EP_BDT_IDX(log_endpoint, TX, EVEN)].address = 0;
+    }
+    // OUT endpt -> host to device (RX)
+    else {
+        USB0->ENDPOINT[log_endpoint].ENDPT |= handshake_flag |        // ep handshaking (not if iso endpoint)
+                                              USB_ENDPT_EPRXEN_MASK;  // en RX (OUT) tran.
+        bdt[EP_BDT_IDX(log_endpoint, RX, ODD )].byte_count = maxPacket;
+        bdt[EP_BDT_IDX(log_endpoint, RX, ODD )].address    = (uint32_t) buf;
+        bdt[EP_BDT_IDX(log_endpoint, RX, ODD )].info       = BD_OWN_MASK | BD_DTS_MASK;
+        bdt[EP_BDT_IDX(log_endpoint, RX, EVEN)].info       = 0;
+    }
+
+    Data1 |= (1 << endpoint);
+
+    return true;
+}
+
+// read setup packet
+void USBHAL::EP0setup(uint8_t *buffer) {
+    uint32_t sz;
+    endpointReadResult(EP0OUT, buffer, &sz);
+}
+
+void USBHAL::EP0readStage(void) {
+    Data1 &= ~1UL;  // set DATA0
+    bdt[0].info = (BD_DTS_MASK | BD_OWN_MASK);
+}
+
+void USBHAL::EP0read(void) {
+    uint32_t idx = EP_BDT_IDX(PHY_TO_LOG(EP0OUT), RX, 0);
+    bdt[idx].byte_count = MAX_PACKET_SIZE_EP0;
+}
+
+uint32_t USBHAL::EP0getReadResult(uint8_t *buffer) {
+    uint32_t sz;
+    endpointReadResult(EP0OUT, buffer, &sz);
+    return sz;
+}
+
+void USBHAL::EP0write(uint8_t *buffer, uint32_t size) {
+    endpointWrite(EP0IN, buffer, size);
+}
+
+void USBHAL::EP0getWriteResult(void) {
+}
+
+void USBHAL::EP0stall(void) {
+    stallEndpoint(EP0OUT);
+}
+
+EP_STATUS USBHAL::endpointRead(uint8_t endpoint, uint32_t maximumSize) {
+    endpoint = PHY_TO_LOG(endpoint);
+    uint32_t idx = EP_BDT_IDX(endpoint, RX, 0);
+    bdt[idx].byte_count = maximumSize;
+    return EP_PENDING;
+}
+
+EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_t *bytesRead) {
+    uint32_t n, sz, idx, setup = 0;
+    uint8_t not_iso;
+    uint8_t * ep_buf;
+
+    uint32_t log_endpoint = PHY_TO_LOG(endpoint);
+
+    if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
+        return EP_INVALID;
+    }
+
+    // if read on a IN endpoint -> error
+    if (IN_EP(endpoint)) {
+        return EP_INVALID;
+    }
+
+    idx = EP_BDT_IDX(log_endpoint, RX, 0);
+    sz  = bdt[idx].byte_count;
+    not_iso = USB0->ENDPOINT[log_endpoint].ENDPT & USB_ENDPT_EPHSHK_MASK;
+
+    //for isochronous endpoint, we don't wait an interrupt
+    if ((log_endpoint != 0) && not_iso && !(epComplete & EP(endpoint))) {
+        return EP_PENDING;
+    }
+
+    if ((log_endpoint == 0) && (TOK_PID(idx) == SETUP_TOKEN)) {
+        setup = 1;
+    }
+
+    // non iso endpoint
+    if (not_iso) {
+        ep_buf = endpoint_buffer[idx];
+    } else {
+        ep_buf = endpoint_buffer_iso[0];
+    }
+
+    for (n = 0; n < sz; n++) {
+        buffer[n] = ep_buf[n];
+    }
+
+    if (((Data1 >> endpoint) & 1) == ((bdt[idx].info >> 6) & 1)) {
+        if (setup && (buffer[6] == 0))  // if no setup data stage,
+            Data1 &= ~1UL;              // set DATA0
+        else
+            Data1 ^= (1 << endpoint);
+    }
+
+    if (((Data1 >> endpoint) & 1)) {
+        bdt[idx].info = BD_DTS_MASK | BD_DATA01_MASK | BD_OWN_MASK;
+    }
+    else {
+        bdt[idx].info = BD_DTS_MASK | BD_OWN_MASK;
+    }
+
+    USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK;
+    *bytesRead = sz;
+
+    epComplete &= ~EP(endpoint);
+    return EP_COMPLETED;
+}
+
+EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size) {
+    uint32_t idx, n;
+    uint8_t * ep_buf;
+
+    if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
+        return EP_INVALID;
+    }
+
+    // if write on a OUT endpoint -> error
+    if (OUT_EP(endpoint)) {
+        return EP_INVALID;
+    }
+
+    idx = EP_BDT_IDX(PHY_TO_LOG(endpoint), TX, 0);
+    bdt[idx].byte_count = size;
+
+
+    // non iso endpoint
+    if (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPHSHK_MASK) {
+        ep_buf = endpoint_buffer[idx];
+    } else {
+        ep_buf = endpoint_buffer_iso[2];
+    }
+
+    for (n = 0; n < size; n++) {
+        ep_buf[n] = data[n];
+    }
+
+    if ((Data1 >> endpoint) & 1) {
+        bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK;
+    } else {
+        bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK | BD_DATA01_MASK;
+    }
+
+    Data1 ^= (1 << endpoint);
+
+    return EP_PENDING;
+}
+
+EP_STATUS USBHAL::endpointWriteResult(uint8_t endpoint) {
+    if (epComplete & EP(endpoint)) {
+        epComplete &= ~EP(endpoint);
+        return EP_COMPLETED;
+    }
+
+    return EP_PENDING;
+}
+
+void USBHAL::stallEndpoint(uint8_t endpoint) {
+    USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT |= USB_ENDPT_EPSTALL_MASK;
+}
+
+void USBHAL::unstallEndpoint(uint8_t endpoint) {
+    USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
+}
+
+bool USBHAL::getEndpointStallState(uint8_t endpoint) {
+    uint8_t stall = (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPSTALL_MASK);
+    return (stall) ? true : false;
+}
+
+void USBHAL::remoteWakeup(void) {
+    // [TODO]
+}
+
+
+void USBHAL::_usbisr(void) {
+    instance->usbisr();
+}
+
+
+void USBHAL::usbisr(void) {
+    uint8_t i;
+    uint8_t istat = USB0->ISTAT;
+
+    // reset interrupt
+    if (istat & USB_ISTAT_USBRST_MASK) {
+        // disable all endpt
+        for(i = 0; i < 16; i++) {
+            USB0->ENDPOINT[i].ENDPT = 0x00;
+        }
+
+        // enable control endpoint
+        realiseEndpoint(EP0OUT, MAX_PACKET_SIZE_EP0, 0);
+        realiseEndpoint(EP0IN, MAX_PACKET_SIZE_EP0, 0);
+
+        Data1 = 0x55555555;
+        USB0->CTL |=  USB_CTL_ODDRST_MASK;
+
+        USB0->ISTAT   =  0xFF;  // clear all interrupt status flags
+        USB0->ERRSTAT =  0xFF;  // clear all error flags
+        USB0->ERREN   =  0xFF;  // enable error interrupt sources
+        USB0->ADDR    =  0x00;  // set default address
+
+        return;
+    }
+
+    // resume interrupt
+    if (istat & USB_ISTAT_RESUME_MASK) {
+        USB0->ISTAT = USB_ISTAT_RESUME_MASK;
+    }
+
+    // SOF interrupt
+    if (istat & USB_ISTAT_SOFTOK_MASK) {
+        USB0->ISTAT = USB_ISTAT_SOFTOK_MASK;
+        // SOF event, read frame number
+        SOF(frameNumber());
+    }
+
+    // stall interrupt
+    if (istat & 1<<7) {
+        if (USB0->ENDPOINT[0].ENDPT & USB_ENDPT_EPSTALL_MASK)
+            USB0->ENDPOINT[0].ENDPT &= ~USB_ENDPT_EPSTALL_MASK;
+        USB0->ISTAT |= USB_ISTAT_STALL_MASK;
+    }
+
+    // token interrupt
+    if (istat & 1<<3) {
+        uint32_t num  = (USB0->STAT >> 4) & 0x0F;
+        uint32_t dir  = (USB0->STAT >> 3) & 0x01;
+        uint32_t ev_odd = (USB0->STAT >> 2) & 0x01;
+
+        // setup packet
+        if ((num == 0) && (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == SETUP_TOKEN)) {
+            Data1 &= ~0x02;
+            bdt[EP_BDT_IDX(0, TX, EVEN)].info &= ~BD_OWN_MASK;
+            bdt[EP_BDT_IDX(0, TX, ODD)].info  &= ~BD_OWN_MASK;
+
+            // EP0 SETUP event (SETUP data received)
+            EP0setupCallback();
+
+        } else {
+            // OUT packet
+            if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == OUT_TOKEN) {
+                if (num == 0)
+                    EP0out();
+                else {
+                    epComplete |= (1 << EP(num));
+                    if ((instance->*(epCallback[EP(num) - 2]))()) {
+                        epComplete &= ~(1 << EP(num));
+                    }
+                }
+            }
+
+            // IN packet
+            if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == IN_TOKEN) {
+                if (num == 0) {
+                    EP0in();
+                    if (set_addr == 1) {
+                        USB0->ADDR = addr & 0x7F;
+                        set_addr = 0;
+                    }
+                }
+                else {
+                    epComplete |= (1 << (EP(num) + 1));
+                    if ((instance->*(epCallback[EP(num) + 1 - 2]))()) {
+                        epComplete &= ~(1 << (EP(num) + 1));
+                    }
+                }
+            }
+        }
+
+        USB0->ISTAT = USB_ISTAT_TOKDNE_MASK;
+    }
+
+    // sleep interrupt
+    if (istat & 1<<4) {
+        USB0->ISTAT |= USB_ISTAT_SLEEP_MASK;
+    }
+
+    // error interrupt
+    if (istat & USB_ISTAT_ERROR_MASK) {
+        USB0->ERRSTAT = 0xFF;
+        USB0->ISTAT |= USB_ISTAT_ERROR_MASK;
+    }
+}
+
+
+#endif
diff --git a/keyboard/infinity/tool/README b/keyboard/infinity/tool/README
new file mode 100644
index 0000000000..3dd3316568
--- /dev/null
+++ b/keyboard/infinity/tool/README
@@ -0,0 +1,25 @@
+OpenOCD config files for Kinetis 
+================================
+http://nemuisan.blog.bai.ne.jp/?eid=192848#OPENOCD
+
+These are needed for SWD debug and programing bootloader. To flash keyboard firmware use 'dfu-util'.
+
+Flash security of Freescale kinetis
+-----------------------------------
+If FSEC of flash config is changed accidentally SWD/JTAG you can't get debug access until doing 'mdm mass_erase' with JTAG, CMSIS-DAP or OpenSAD adapter. HLA(high level adapter) like stlink doesn't work for this.
+
+
+Example
+-------
+Debug:
+    $ openocd -s tool -f tool/openocd.cfg
+    $ arm-none-eabi-gdb build/infinity.elf -ex "target remote localhost:3333"
+
+Flash bootloader:
+    $ openocd -s tool -f tool/openocd.cfg -c "mt_flash kiibohd_bootloader.bin"
+
+
+Infinity SWD pinout
+-------------------
+SWD pins are placed next to reset button; SWD_CLK, SWD_DIO, GND, VCC from top.
+Note that RESET is also needed to get full control with OpenOCD.
diff --git a/tool/mbed/lpc11u35_501.mk b/tool/mbed/lpc11u35_501.mk
index 15e14910ce..328d03d66a 100644
--- a/tool/mbed/lpc11u35_501.mk
+++ b/tool/mbed/lpc11u35_501.mk
@@ -17,6 +17,7 @@ CC_SYMBOLS = \
 	-D__MBED__=1
 
 OBJECTS += \
+	$(OBJDIR)/libraries/USBDevice/USBDevice/USBHAL_LPC11U.o \
 	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/TOOLCHAIN_GCC_ARM/startup_LPC11xx.o \
 	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/cmsis_nvic.o \
 	$(OBJDIR)/libraries/mbed/targets/cmsis/TARGET_NXP/TARGET_LPC11UXX/system_LPC11Uxx.o \
diff --git a/tool/mbed/mbed.mk b/tool/mbed/mbed.mk
index db322b260a..2657a0fd37 100644
--- a/tool/mbed/mbed.mk
+++ b/tool/mbed/mbed.mk
@@ -4,7 +4,9 @@
 OBJECTS += \
 	$(OBJDIR)/libraries/mbed/common/gpio.o \
 	$(OBJDIR)/libraries/mbed/common/us_ticker_api.o \
-	$(OBJDIR)/libraries/mbed/common/wait_api.o
+	$(OBJDIR)/libraries/mbed/common/wait_api.o \
+	$(OBJDIR)/libraries/USBDevice/USBDevice/USBDevice.o
+
 
 #	$(OBJDIR)/libraries/mbed/common/assert.o \
 #	$(OBJDIR)/libraries/mbed/common/board.o \
@@ -75,9 +77,9 @@ INCLUDE_PATHS += \
 	-I$(MBED_DIR)/libraries/USBDevice/USBSerial
 
 # TMK mbed protocol
-#OBJECTS += \
-#	$(OBJDIR)/protocol/mbed/mbed_driver.o \
-#	$(OBJDIR)/protocol/mbed/HIDKeyboard.o
+OBJECTS += \
+	$(OBJDIR)/protocol/mbed/mbed_driver.o \
+	$(OBJDIR)/protocol/mbed/HIDKeyboard.o
 
 INCLUDE_PATHS += \
 	-I$(TMK_DIR)/protocol/mbed

From 2de53795d6d816d9528f60f2c6c500c0f249e954 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 5 Jan 2015 13:11:34 -0500
Subject: [PATCH 31/95] Update keymap_jack.c

---
 keyboard/planck/keymap_jack.c | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/keyboard/planck/keymap_jack.c b/keyboard/planck/keymap_jack.c
index a1d7e36b9c..d2ad465d78 100644
--- a/keyboard/planck/keymap_jack.c
+++ b/keyboard/planck/keymap_jack.c
@@ -5,21 +5,30 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
   ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
   LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
-  FN26, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
-[1] = KEYMAP( /* Jack RAISE */
+  RSFT, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
+[1] = KEYMAP( /* Jack colemak */
+  TAB,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, BSPC,
+  ESC,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,     QUOT,
+  LSFT, Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH, ENT,
+  FN3, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
+[2] = KEYMAP( /* Jack RAISE */
   GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    BSPC,
-  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC, BSLS,
-  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS, TRNS,
+  TRNS, FN3, FN4, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC, BSLS,
+  TRNS, F11,  F12,  F13,  F14,  F15,  F16,  F17,  F18,  F19,  F20, TRNS,
   TRNS, TRNS, TRNS, TRNS, TRNS,    TRNS,   FN1,  MNXT, VOLD, VOLU, MPLY),
-[2] = KEYMAP( /* Jack LOWER */
+[3] = KEYMAP( /* Jack LOWER */
   FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
-  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN25,
-  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  TRNS, FN3, FN4, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+  TRNS, F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  TRNS,
   TRNS, TRNS, TRNS, TRNS, FN2,    TRNS,    TRNS, MNXT, VOLD, VOLU, MPLY),
 };
 const uint16_t PROGMEM fn_actions[] = {
-    [1] = ACTION_LAYER_MOMENTARY(1),  // to Fn overlay
-    [2] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
+    [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
+    [2] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay 
+    // [1] = ACTION_LAYER_ON_OFF(1),
+    // [2] = ACTION_LAYER_ON_OFF(2),
+    [3] = ACTION_DEFAULT_LAYER_SET(0), 
+    [4] = ACTION_DEFAULT_LAYER_SET(1),  
 
     [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
     [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
@@ -36,7 +45,5 @@ const uint16_t PROGMEM fn_actions[] = {
     [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
     [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
     [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
-    [25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
-
-    [26] = ACTION_MODS_KEY(MOD_LSFT, MOD_RSFT),
+    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
 };

From 33e2a6285f89a38bf15e933291bd118ebd857624 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 5 Jan 2015 16:27:03 -0500
Subject: [PATCH 32/95] dotcom

---
 keyboard/planck/keymap_dotcom.c  | 34 +++++++++++++++++++++
 keyboard/planck/keymap_peasant.c | 51 ++++++++++++++++++++++++++++++++
 2 files changed, 85 insertions(+)
 create mode 100644 keyboard/planck/keymap_dotcom.c
 create mode 100644 keyboard/planck/keymap_peasant.c

diff --git a/keyboard/planck/keymap_dotcom.c b/keyboard/planck/keymap_dotcom.c
new file mode 100644
index 0000000000..385a1453da
--- /dev/null
+++ b/keyboard/planck/keymap_dotcom.c
@@ -0,0 +1,34 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP( 
+  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  FN1,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
+  LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, LBRC,
+  LCTL, BSLS, QUOT, LALT, FN22, FN2,    SPC,     LEFT, UP, DOWN, RGHT,  RBRC),
+[1] = KEYMAP( 
+  GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    DEL,
+  TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17,  TRNS, TRNS, TRNS,
+  TRNS, FN18,  FN19,  FN22,  EQL,  MINS,  FN20,  TRNS,  TRNS,  TRNS,  TRNS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS,    TRNS,   FN1,  TRNS, VOLD, VOLU, TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_MOMENTARY(1),  // to Fn overlay
+
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+};
diff --git a/keyboard/planck/keymap_peasant.c b/keyboard/planck/keymap_peasant.c
new file mode 100644
index 0000000000..ddacb614e6
--- /dev/null
+++ b/keyboard/planck/keymap_peasant.c
@@ -0,0 +1,51 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = KEYMAP( /* Native */
+      ESC,     Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    FN2, 
+      BSPC,    A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
+      TAB,     Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
+      DEL,     LCTL, NO,   LSFT, LALT, SPC,        NO,   LEFT, DOWN, UP,  RGHT), 
+    [1] = KEYMAP( /* QWERTY->PHOTOSHOP */
+      DELETE,  0,    1,    2,    3,    4,    5,    6,    7,    8,    9,    FN1,
+      O,       G,    S,    U,    T,    FN27,  F21,  F10,  F11,  F7,   F8,   F9,
+      TAB,     FN4, FN5,  FN6,  F1,   FN7,  F18,  F19,  F23,  F20,  F22,  FN9,
+      COMM,    DOT,  FN10, FN11, FN3,  SPC,        FN12, F2,   FN8,  F3,   F14),
+    [2] = KEYMAP( /* 2: FN3 PHOTOSHOP */
+      ESC,    FN25, FN26,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,
+      NO,      NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   FN19, FN20, FN21, 
+      C,       NO,  FN22,  FN5,   NO,   FN23, NO,   NO,   NO,   NO,   FN13, NO,
+      FN14,    FN15, FN16, FN17, FN3,   SPC,        FN18, NO,   NO,   F24,  NO),
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_DEFAULT_LAYER_SET(0),                             // set Qwerty layout
+    [2] = ACTION_DEFAULT_LAYER_SET(1),                             // set Photoshop presets
+    [3] = ACTION_LAYER_ON_OFF(2),                                  // Photoshop function layer
+ 
+    [4] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F9),   // photo folder AHK
+    [5] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_I),              // select inverse
+    [6] = ACTION_MODS_KEY(MOD_LSFT, KC_M),                         // marquee select
+    [7] = ACTION_MODS_KEY(MOD_LALT, KC_BSPC),                      // fill 
+    [8] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_X),    // warp
+    [9] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT | MOD_LSFT, KC_F12),  // merge all new layer
+    [10] = ACTION_MODS_KEY(MOD_LCTL, KC_MINS),                     // zoom out
+    [11] = ACTION_MODS_KEY(MOD_LCTL, KC_H),                        // RBG sliders
+    [12] = ACTION_MODS_KEY(MOD_LCTL, KC_S),                        // save
+    [13] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F5),           // layer mask from transparancy 
+    [14] = ACTION_MODS_KEY(MOD_LALT, KC_LBRC),                     // prev layer
+    [15] = ACTION_MODS_KEY(MOD_LALT, KC_RBRC),                     // next layer
+    [16] = ACTION_MODS_KEY(MOD_LCTL, KC_EQL),                      // zoom in
+    [17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_H),             // HSV sliders
+    [18] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F11), // save as PNG
+    [19] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F7),  // gaussian blur
+    [20] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F8),  // motion blur
+    [21] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_X),            // liquify filter
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),                     // prev layer blending
+    [23] = ACTION_MODS_KEY(MOD_LSFT | MOD_LALT, KC_N),             // normal layer blending
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),                      // next layer blending
+    [25] = ACTION_MODS_KEY(MOD_LCTL, KC_Z),                        // step back
+    [26] = ACTION_MODS_KEY(MOD_LCTL, KC_Y),                        // step forward
+    [27] = ACTION_MODS_KEY(MOD_LCTL, KC_R),                        // rasterize
+     
+};

From d6f2f878f90ce033a2495aa9ad82cfa1578429b9 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 5 Jan 2015 16:32:15 -0500
Subject: [PATCH 33/95] dotcom

---
 keyboard/planck/Makefile        |  2 +-
 keyboard/planck/keymap_dotcom.c |  2 +-
 keyboard/planck/matrix.c        | 98 +++++++++++++--------------------
 3 files changed, 41 insertions(+), 61 deletions(-)

diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index 2ec324bd95..12431cdbed 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -55,7 +55,7 @@ SRC =	keymap_common.c \
 ifdef KEYMAP
     SRC := keymap_$(KEYMAP).c $(SRC)
 else
-    SRC := keymap_jack.c $(SRC)
+    SRC := keymap_dotcom.c $(SRC)
 endif
 
 CONFIG_H = config.h
diff --git a/keyboard/planck/keymap_dotcom.c b/keyboard/planck/keymap_dotcom.c
index 385a1453da..347f6dea91 100644
--- a/keyboard/planck/keymap_dotcom.c
+++ b/keyboard/planck/keymap_dotcom.c
@@ -5,7 +5,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
   FN1,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
   LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, LBRC,
-  LCTL, BSLS, QUOT, LALT, FN22, FN2,    SPC,     LEFT, UP, DOWN, RGHT,  RBRC),
+  LCTL, BSLS, QUOT, LALT, FN22,    SPC,     LEFT, UP, DOWN, RGHT,  RBRC),
 [1] = KEYMAP( 
   GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    DEL,
   TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17,  TRNS, TRNS, TRNS,
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c
index 720ac30043..ca59f7c73b 100644
--- a/keyboard/planck/matrix.c
+++ b/keyboard/planck/matrix.c
@@ -1,5 +1,6 @@
 /*
-Copyright 2012 Jun Wako <wakojun@gmail.com>
+Copyright 2012 Jun Wako 
+Generated by planckkeyboard.com (2014 Jack Humbert)
 
 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -22,7 +23,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <stdbool.h>
 #include <avr/io.h>
 #include <util/delay.h>
-#include "action_layer.h"
 #include "print.h"
 #include "debug.h"
 #include "util.h"
@@ -30,7 +30,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 #ifndef DEBOUNCE
-#   define DEBOUNCE	10
+#   define DEBOUNCE 10
 #endif
 static uint8_t debouncing = DEBOUNCE;
 
@@ -43,7 +43,6 @@ static void init_cols(void);
 static void unselect_rows(void);
 static void select_row(uint8_t row);
 
-
 inline
 uint8_t matrix_rows(void)
 {
@@ -95,19 +94,6 @@ uint8_t matrix_scan(void)
         }
     }
 
-    uint8_t layer = biton32(layer_state);
-    switch (layer) {
-        case 1:
-        case 2:
-            DDRC |= (1<<7);
-            PORTC |= (1<<7);
-            break;
-        case 0:
-            DDRC &= ~(1<<7);
-            PORTC &= ~(1<<7);
-            break;
-    }
-
     return 1;
 }
 
@@ -120,7 +106,7 @@ bool matrix_is_modified(void)
 inline
 bool matrix_is_on(uint8_t row, uint8_t col)
 {
-    return (matrix[row] & ((matrix_row_t)1<<col));
+    return (matrix[row] & ((matrix_row_t)1<col));
 }
 
 inline
@@ -148,68 +134,62 @@ uint8_t matrix_key_count(void)
     return count;
 }
 
-/* Column pin configuration
- * col: 0  1  2  3  4  5  6  7  8  9  10 11
- * pin: F0 F1 F4 F5 F6 F7 B6 B5 B4 D7 D5 D4
- */
-
 static void init_cols(void)
 {
-    DDRF  &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
-    PORTF |=  (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
-    DDRD  &= ~(1<<0);
-    PORTD |=  (1<<0);
-    DDRB  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
-    PORTB |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+    DDRB &= ~(1<<7 | 1<<4 | 1<<5 | 1<<6);
+    PORTB |= (1<<7 | 1<<4 | 1<<5 | 1<<6);
+    DDRC &= ~(1<<6);
+    PORTC |= (1<<6);
+    DDRD &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+    PORTD |= (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+    DDRF &= ~(1<<7 | 1<<6);
+    PORTF |= (1<<7 | 1<<6);
+    
 }
 
 static matrix_row_t read_cols(void)
 {
-    return (PINB&(1<<0) ? 0 : (1<< 0)) |
-           (PINB&(1<<1) ? 0 : (1<< 1)) |
-           (PINB&(1<<2) ? 0 : (1<< 2)) |
-           (PINB&(1<<3) ? 0 : (1<< 3)) |
-           (PINB&(1<<7) ? 0 : (1<< 4)) |
-           (PIND&(1<<0) ? 0 : (1<< 5)) |
-           (PINF&(1<<7) ? 0 : (1<< 6)) |
-           (PINF&(1<<6) ? 0 : (1<< 7)) |
-           (PINF&(1<<5) ? 0 : (1<< 8)) |
-           (PINF&(1<<4) ? 0 : (1<< 9)) |
-           (PINF&(1<<1) ? 0 : (1<<10)) |
-           (PINF&(1<<0) ? 0 : (1<<11));
+  return (PINB&(1<<7) ? 0 : (1<<0)) |
+         (PIND&(1<<0) ? 0 : (1<<1)) |
+         (PIND&(1<<1) ? 0 : (1<<2)) |
+         (PIND&(1<<2) ? 0 : (1<<3)) |
+         (PIND&(1<<3) ? 0 : (1<<4)) |
+         (PINC&(1<<6) ? 0 : (1<<5)) |
+         (PIND&(1<<7) ? 0 : (1<<6)) |
+         (PINB&(1<<4) ? 0 : (1<<7)) |
+         (PINB&(1<<5) ? 0 : (1<<8)) |
+         (PINB&(1<<6) ? 0 : (1<<9)) |
+         (PINF&(1<<7) ? 0 : (1<<10)) |
+         (PINF&(1<<6) ? 0 : (1<<11));
+         
 }
 
-/* Row pin configuration
- * row: 0  1  2  3
- * pin: B0 B1 B2 B3
- */
 static void unselect_rows(void)
 {
-    // Hi-Z(DDR:0, PORT:0) to unselect
-    DDRB  &= ~0b01110000;
-    PORTB &= ~0b01110000;
-    DDRD  &= ~0b10000000;
-    PORTD &= ~0b10000000;
+    DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5);
+    PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5);
+    
 }
 
 static void select_row(uint8_t row)
 {
     switch (row) {
         case 0:
-            DDRB  |= (1<<6);
-            PORTB &= ~(1<<6);
+            DDRF  |= (1<<0);
+            PORTF &= ~(1<<0);
             break;
         case 1:
-            DDRB  |= (1<<5);
-            PORTB &= ~(1<<5);
+            DDRF  |= (1<<1);
+            PORTF &= ~(1<<1);
             break;
         case 2:
-            DDRB  |= (1<<4);
-            PORTB &= ~(1<<4);
+            DDRF  |= (1<<4);
+            PORTF &= ~(1<<4);
             break;
         case 3:
-            DDRD  |= (1<<7);
-            PORTD &= ~(1<<7);
+            DDRF  |= (1<<5);
+            PORTF &= ~(1<<5);
             break;
+        
     }
-}
+}
\ No newline at end of file

From 10a6b2c7d8bc9c5d2657acdeefa1102be5035280 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Sun, 11 Jan 2015 01:54:17 +0900
Subject: [PATCH 34/95] hhkb: Add Makefile.jp for HHKB JP

---
 keyboard/hhkb/Makefile    | 10 +++++-----
 keyboard/hhkb/Makefile.jp |  2 ++
 keyboard/hhkb/README.md   |  7 ++++++-
 3 files changed, 13 insertions(+), 6 deletions(-)
 create mode 100644 keyboard/hhkb/Makefile.jp

diff --git a/keyboard/hhkb/Makefile b/keyboard/hhkb/Makefile
index 5cf02d194e..dc5c06a948 100644
--- a/keyboard/hhkb/Makefile
+++ b/keyboard/hhkb/Makefile
@@ -121,11 +121,6 @@ NKRO_ENABLE = yes		# USB Nkey Rollover
 #HHKB_JP = yes			# HHKB JP support
 
 
-ifdef HHKB_JP
-    OPT_DEFS += -DHHKB_JP
-endif
-
-
 #
 # Keymap file
 #
@@ -140,6 +135,11 @@ else
 endif
 
 
+ifneq (, $(or $(findstring keymap_jp.c, $(SRC)), $(findstring yes, $(HHKB_JP))))
+    OPT_DEFS += -DHHKB_JP
+endif
+
+
 # Search Path
 VPATH += $(TARGET_DIR)
 VPATH += $(TOP_DIR)
diff --git a/keyboard/hhkb/Makefile.jp b/keyboard/hhkb/Makefile.jp
new file mode 100644
index 0000000000..e04dbb2424
--- /dev/null
+++ b/keyboard/hhkb/Makefile.jp
@@ -0,0 +1,2 @@
+HHKB_JP = yes
+include Makefile
diff --git a/keyboard/hhkb/README.md b/keyboard/hhkb/README.md
index d4a2cd0223..f9fd165076 100644
--- a/keyboard/hhkb/README.md
+++ b/keyboard/hhkb/README.md
@@ -43,12 +43,15 @@ See [doc/HHKB.txt](doc/HHKB.txt) and files under [doc/](doc/) for internal of HH
 See [this document](../../doc/build.md) first.
 
 ### Configuration
-Set `MCU`, `BOOTLOADER_SIZE` and other build options in `Makefile` and `config.h`. If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile`.
+If your target is **HHKB JP** you need to set `HHKB_JP` build option in `Makefile` or use `Makefile.jp` instead of `Makefile`.
+
+If you use other than **TMK Alt Controller Board** set proper `MCU`, `BOOTLOADER_SIZE` and other build options in `Makefile` and `config.h`. At least PJRC Teensy requires changing `BOOTLOADER_SIZE` to 512.
 
 ### Build 
 Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like:
 
     $ make KEYMAP=[hasu|hhkb|spacefn|<name>]
+    $ make -f Makefile.jp KEYMAP=[jp|<name>]        # for HHKB JP
 
 
 ### Program
@@ -57,10 +60,12 @@ First, push reset button on board to start bootloader.
 This command programs the controller with [dfu-programmer] if the tool is installed and configured properly.
 
     $ make dfu
+    $ make -f Makefile.jp dfu       # for HHKB JP
 
 Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available.
 
     $ make flip
+    $ make -f Makefile.jp flip      # for HHKB JP
 
 Use [Teensy Loader] if your controller is Teensy/Teensy++.
 

From 42fe42274fe0ff2f10698100f28ab686822652ff Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 12 Jan 2015 12:37:16 -0500
Subject: [PATCH 35/95] names

---
 keyboard/planck/Makefile        | 2 +-
 keyboard/planck/keymap_common.h | 4 ++--
 keyboard/planck/keymap_jack.c   | 8 ++++----
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index 12431cdbed..0d84d8b472 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -39,7 +39,7 @@
 #----------------------------------------------------------------------------
 
 # Target file name (without extension).
-TARGET = gh60_lufa
+TARGET = planck_lufa
 
 # Directory common source filess exist
 TOP_DIR = ../..
diff --git a/keyboard/planck/keymap_common.h b/keyboard/planck/keymap_common.h
index 7c95fb8e7c..264870ef96 100644
--- a/keyboard/planck/keymap_common.h
+++ b/keyboard/planck/keymap_common.h
@@ -41,12 +41,12 @@ extern const uint16_t fn_actions[];
     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
     K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
-    K30, K31, K32, K33, K34,      K36, K37, K38, K39, K3A, K3B  \
+    K30, K31, K32, K33, K34, K35,      K37, K38, K39, K3A, K3B  \
 ) { \
     { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
     { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
     { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
-    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_NO,    KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_NO,    KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
 }
 
 #endif
diff --git a/keyboard/planck/keymap_jack.c b/keyboard/planck/keymap_jack.c
index d2ad465d78..fd30069ed2 100644
--- a/keyboard/planck/keymap_jack.c
+++ b/keyboard/planck/keymap_jack.c
@@ -2,13 +2,13 @@
 
 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 [0] = KEYMAP( /* Jack */
-  TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
-  ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
+  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  TAB,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
   LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
   RSFT, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
 [1] = KEYMAP( /* Jack colemak */
-  TAB,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, BSPC,
-  ESC,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,     QUOT,
+  ESC,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, BSPC,
+  TAB,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,     QUOT,
   LSFT, Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH, ENT,
   FN3, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
 [2] = KEYMAP( /* Jack RAISE */

From 98f486a633611764d5928fd52187155aabb33d63 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 12 Jan 2015 12:39:24 -0500
Subject: [PATCH 36/95] atomic

---
 keyboard/atomic/Makefile           | 135 +++++++++++++++++
 keyboard/atomic/Makefile.pjrc      | 116 +++++++++++++++
 keyboard/atomic/README 2.md        | 141 ++++++++++++++++++
 keyboard/atomic/config.h           |  70 +++++++++
 keyboard/atomic/keymap_common.c    |  30 ++++
 keyboard/atomic/keymap_common.h    |  51 +++++++
 keyboard/atomic/keymap_hasu.c      | 145 ++++++++++++++++++
 keyboard/atomic/keymap_hhkb.c      |  52 +++++++
 keyboard/atomic/keymap_plain.c     |  50 +++++++
 keyboard/atomic/keymap_planck.c    |  51 +++++++
 keyboard/atomic/keymap_poker.c     | 104 +++++++++++++
 keyboard/atomic/keymap_poker_bit.c |  50 +++++++
 keyboard/atomic/keymap_poker_set.c |  82 ++++++++++
 keyboard/atomic/keymap_spacefn.c   |  55 +++++++
 keyboard/atomic/led.c              |  34 +++++
 keyboard/atomic/matrix.c           | 230 +++++++++++++++++++++++++++++
 16 files changed, 1396 insertions(+)
 create mode 100644 keyboard/atomic/Makefile
 create mode 100644 keyboard/atomic/Makefile.pjrc
 create mode 100644 keyboard/atomic/README 2.md
 create mode 100644 keyboard/atomic/config.h
 create mode 100644 keyboard/atomic/keymap_common.c
 create mode 100644 keyboard/atomic/keymap_common.h
 create mode 100644 keyboard/atomic/keymap_hasu.c
 create mode 100644 keyboard/atomic/keymap_hhkb.c
 create mode 100644 keyboard/atomic/keymap_plain.c
 create mode 100644 keyboard/atomic/keymap_planck.c
 create mode 100644 keyboard/atomic/keymap_poker.c
 create mode 100644 keyboard/atomic/keymap_poker_bit.c
 create mode 100644 keyboard/atomic/keymap_poker_set.c
 create mode 100644 keyboard/atomic/keymap_spacefn.c
 create mode 100644 keyboard/atomic/led.c
 create mode 100644 keyboard/atomic/matrix.c

diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile
new file mode 100644
index 0000000000..0c407f703b
--- /dev/null
+++ b/keyboard/atomic/Makefile
@@ -0,0 +1,135 @@
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device.
+#                Please customize your programmer settings(PROGRAM_CMD)
+#
+# make teensy = Download the hex file to the device, using teensy_loader_cli.
+#               (must have teensy_loader_cli installed).
+#
+# make dfu = Download the hex file to the device, using dfu-programmer (must
+#            have dfu-programmer installed).
+#
+# make flip = Download the hex file to the device, using Atmel FLIP (must
+#             have Atmel FLIP installed).
+#
+# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
+#               (must have dfu-programmer installed).
+#
+# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
+#                (must have Atmel FLIP installed).
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+# Target file name (without extension).
+TARGET = gh60_lufa
+
+# Directory common source filess exist
+TOP_DIR = ../..
+
+# Directory keyboard dependent files exist
+TARGET_DIR = .
+
+# project specific files
+SRC =	keymap_common.c \
+	matrix.c \
+	led.c
+
+ifdef KEYMAP
+    SRC := keymap_$(KEYMAP).c $(SRC)
+else
+    SRC := keymap_plain.c $(SRC)
+endif
+
+CONFIG_H = config.h
+
+
+# MCU name
+#MCU = at90usb1287
+MCU = atmega32u4
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency in Hz. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+#
+#     This will be an integer division of F_USB below, as it is sourced by
+#     F_USB after it has run through any CPU prescalers. Note that this value
+#     does not *change* the processor frequency - it should merely be updated to
+#     reflect the processor speed set externally so that the code can use accurate
+#     software delays.
+F_CPU = 16000000
+
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+#     This will define a symbol, F_USB, in all source code files equal to the
+#     input clock frequency (before any prescaling is performed) in Hz. This value may
+#     differ from F_CPU if prescaling is used on the latter, and is required as the
+#     raw input clock is fed directly to the PLL sections of the AVR for high speed
+#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+#     at the end, this will be done automatically to create a 32-bit value in your
+#     source code.
+#
+#     If no clock division is performed on the input clock inside the AVR (via the
+#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Interrupt driven control endpoint task(+60)
+OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
+
+
+# Boot Section Size in *bytes*
+#   Teensy halfKay   512
+#   Teensy++ halfKay 1024
+#   Atmel DFU loader 4096
+#   LUFA bootloader  4096
+#   USBaspLoader     2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+
+# Build Options
+#   comment out to disable the options.
+#
+BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
+CONSOLE_ENABLE = yes	# Console for debug(+400)
+COMMAND_ENABLE = yes    # Commands for debug and configuration
+#SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
+NKRO_ENABLE = yes	# USB Nkey Rollover - not yet supported in LUFA
+
+
+# Optimize size but this may cause error "relocation truncated to fit"
+#EXTRALDFLAGS = -Wl,--relax
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol/lufa.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
diff --git a/keyboard/atomic/Makefile.pjrc b/keyboard/atomic/Makefile.pjrc
new file mode 100644
index 0000000000..9655ff65a9
--- /dev/null
+++ b/keyboard/atomic/Makefile.pjrc
@@ -0,0 +1,116 @@
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device.
+#                Please customize your programmer settings(PROGRAM_CMD)
+#
+# make teensy = Download the hex file to the device, using teensy_loader_cli.
+#               (must have teensy_loader_cli installed).
+#
+# make dfu = Download the hex file to the device, using dfu-programmer (must
+#            have dfu-programmer installed).
+#
+# make flip = Download the hex file to the device, using Atmel FLIP (must
+#             have Atmel FLIP installed).
+#
+# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
+#               (must have dfu-programmer installed).
+#
+# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
+#                (must have Atmel FLIP installed).
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+# Target file name (without extension).
+TARGET = gh60_pjrc
+
+# Directory common source filess exist
+TOP_DIR = ../..
+
+# Directory keyboard dependent files exist
+TARGET_DIR = .
+
+# project specific files
+SRC =	keymap_common.c \
+	matrix.c \
+	led.c
+
+ifdef KEYMAP
+    SRC := keymap_$(KEYMAP).c $(SRC)
+else
+    SRC := keymap_poker.c $(SRC)
+endif
+
+CONFIG_H = config.h
+
+
+# MCU name, you MUST set this to match the board you are using
+# type "make clean" after changing this, so all files will be rebuilt
+MCU = atmega32u4
+#MCU = at90usb1286
+
+
+# Processor frequency.
+#   Normally the first thing your program should do is set the clock prescaler,
+#   so your program will run at the correct speed.  You should also set this
+#   variable to same clock speed.  The _delay_ms() macro uses this, and many
+#   examples use this variable to calculate timings.  Do not add a "UL" here.
+F_CPU = 16000000
+
+
+# Boot Section Size in *bytes*
+#   Teensy halfKay   512
+#   Atmel DFU loader 4096
+#   LUFA bootloader  4096
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+
+# Build Options
+#   comment out to disable the options.
+#
+BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
+MOUSEKEY_ENABLE = yes	# Mouse keys(+5000)
+EXTRAKEY_ENABLE = yes	# Audio control and System control(+600)
+CONSOLE_ENABLE = yes    # Console for debug
+COMMAND_ENABLE = yes    # Commands for debug and configuration
+SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
+NKRO_ENABLE = yes	# USB Nkey Rollover(+500)
+#PS2_MOUSE_ENABLE = yes	# PS/2 mouse(TrackPoint) support
+
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol/pjrc.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
+
+plain: OPT_DEFS += -DKEYMAP_PLAIN
+plain: all
+
+poker: OPT_DEFS += -DKEYMAP_POKER
+poker: all
+
+poker_set: OPT_DEFS += -DKEYMAP_POKER_SET
+poker_set: all
+
+poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT
+poker_bit: all
diff --git a/keyboard/atomic/README 2.md b/keyboard/atomic/README 2.md
new file mode 100644
index 0000000000..510cb5c8b6
--- /dev/null
+++ b/keyboard/atomic/README 2.md	
@@ -0,0 +1,141 @@
+GH60 keyboard firmware
+======================
+DIY compact keyboard designed and run by komar007 and Geekhack community.
+
+- Both Rev.A and Rev.B PCB are supported by one firmware binary(issue #64)
+
+## GH60 Resources
+- [KOMAR's project page](http://blog.komar.be/projects/gh60-programmable-keyboard/)
+- [Prototyping](http://geekhack.org/index.php?topic=34959.0)
+- [Rev.A PCB test](http://geekhack.org/index.php?topic=37570.0)
+- [Rev.B PCB test](http://geekhack.org/index.php?topic=50685.0)
+- [Group buy](http://geekhack.org/index.php?topic=41464.0)
+
+
+## Build
+Move to this directory then just run `make` like:
+
+    $ make
+
+Use `make -f Makefile.pjrc` if you want to use PJRC stack but I find no reason to do so now.
+
+
+## Keymap
+Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. To define your own keymap create file named `keymap_<name>.c` and see keymap document(you can find in top README.md) and existent keymap files.
+
+To build firmware binary hex file with a certain keymap just do `make` with `KEYMAP` option like:
+
+    $ make KEYMAP=[poker|poker_set|poker_bit|plain|hasu|spacefn|hhkb|<name>]
+
+
+### 1  Poker
+[keymap_poker.c](keymap_poker.c) emulates original Poker layers
+while both [keymap_poker_bit.c](keymap_poker_bit.c) and [keymap_poker_set.c](keymap_poker_set.c) implements same layout in different way and they fix a minor issue of original Poker and enhance arrow keys.
+
+    Fn + Esc = `
+    Fn + {left, down, up, right}  = {home, pgdown, pgup, end}
+
+#### 1.0 Default layer
+    ,-----------------------------------------------------------.
+    |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+    |-----------------------------------------------------------|
+    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
+    |-----------------------------------------------------------|
+    |Ctrl|Gui |Alt |      Space             |Fn  |Gui |App |Ctrl|
+    `-----------------------------------------------------------'
+#### 1.1 Poker Fn layer
+    ,-----------------------------------------------------------.
+    |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|       |
+    |-----------------------------------------------------------|
+    |     |FnQ| Up|   |   |   |   |   |   |Cal|   |Hom|Ins|     |
+    |-----------------------------------------------------------|
+    |      |Lef|Dow|Rig|   |   |Psc|Slk|Pau|   |Tsk|End|        |
+    |-----------------------------------------------------------|
+    |        |Del|   |Web|Mut|VoU|VoD|   |PgU|PgD|Del|   Up     |
+    |-----------------------------------------------------------|
+    |    |    |    |         FnS            |Fn  |Left|Down|Righ|
+    `-----------------------------------------------------------'
+
+
+### 2. Plain
+Without any Fn layer this will be useful if you want to use key remapping tool like AHK on host.
+See [keymap_plain.c](keymap_plain.c) for detail.
+
+#### 1.0 Plain Default layer
+    ,-----------------------------------------------------------.
+    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+    |-----------------------------------------------------------|
+    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
+    |-----------------------------------------------------------|
+    |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |Ctrl|
+    `-----------------------------------------------------------'
+
+
+### 3. Hasu
+This is my favorite keymap with HHKB Fn, Vi cursor and Mousekey layer. See [keymap_hasu.c](keymap_hasu.c) for detail.
+
+
+### 4. SpaceFN
+This layout proposed by spiceBar uses space bar to change layer with using Dual role key technique. See [keymap_spacefn.c](keymap_spacefn.c) and [SpaceFN discussion](http://geekhack.org/index.php?topic=51069.0).
+
+#### 4.0 Default layer
+    ,-----------------------------------------------------------.
+    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+    |-----------------------------------------------------------|
+    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
+    |-----------------------------------------------------------|
+    |Ctrl|Gui |Alt |      Space/Fn          |Alt |Gui |App |Ctrl|
+    `-----------------------------------------------------------'
+#### 4.1 SpaceFN layer
+    ,-----------------------------------------------------------.
+    |`  | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
+    |-----------------------------------------------------------|
+    |     |   |   |   |   |   |   |Hom|Up |End|Psc|Slk|Pau|Ins  |
+    |-----------------------------------------------------------|
+    |      |   |   |   |   |   |PgU|Lef|Dow|Rig|   |   |        |
+    |-----------------------------------------------------------|
+    |        |   |   |   |   |Spc|PgD|`  |~  |   |   |          |
+    |-----------------------------------------------------------|
+    |    |    |    |            Fn          |    |    |    |    |
+    `-----------------------------------------------------------'
+
+
+### 5. HHKB
+[keymap_hhkb.c](keymap_hhkb.c) emulates original HHKB layers.
+#### 5.0: Default layer
+    ,-----------------------------------------------------------.
+    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|  `|
+    |-----------------------------------------------------------|
+    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Bspc |
+    |-----------------------------------------------------------|
+    |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Return  |
+    |-----------------------------------------------------------|
+    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Fn |
+    |-----------------------------------------------------------|
+    |    |Gui |Alt |      Space             |    |Alt |Gui |    |
+    `-----------------------------------------------------------'
+#### 5.1: HHKB Fn layer
+    ,-----------------------------------------------------------.
+    |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+    |-----------------------------------------------------------|
+    |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |     |
+    |-----------------------------------------------------------|
+    |      |VoD|VoU|Mut|Ejc|   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
+    |-----------------------------------------------------------|
+    |        |   |   |   |   |   |  +|  -|End|PgD|Dow|      |   |
+    |-----------------------------------------------------------|
+    |    |    |    |                        |    |    |    |    |
+    `-----------------------------------------------------------'
+
diff --git a/keyboard/atomic/config.h b/keyboard/atomic/config.h
new file mode 100644
index 0000000000..5ea953805f
--- /dev/null
+++ b/keyboard/atomic/config.h
@@ -0,0 +1,70 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0x6060
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    Ortholinear Keyboards
+#define PRODUCT         Atomic Keyboard
+#define DESCRIPTION     t.m.k. keyboard firmware for Atomic
+
+/* key matrix size */
+#define MATRIX_ROWS 5
+#define MATRIX_COLS 15
+
+/* define if matrix has ghost */
+//#define MATRIX_HAS_GHOST
+
+/* Set 0 if debouncing isn't needed */
+#define DEBOUNCE    5
+
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
+#define LOCKING_SUPPORT_ENABLE
+/* Locking resynchronize hack */
+#define LOCKING_RESYNC_ENABLE
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+
+
+/*
+ * Feature disable options
+ *  These options are also useful to firmware size reduction.
+ */
+
+/* disable debug print */
+//#define NO_DEBUG
+
+/* disable print */
+//#define NO_PRINT
+
+/* disable action features */
+//#define NO_ACTION_LAYER
+//#define NO_ACTION_TAPPING
+//#define NO_ACTION_ONESHOT
+//#define NO_ACTION_MACRO
+//#define NO_ACTION_FUNCTION
+
+#endif
diff --git a/keyboard/atomic/keymap_common.c b/keyboard/atomic/keymap_common.c
new file mode 100644
index 0000000000..fdb1769e1c
--- /dev/null
+++ b/keyboard/atomic/keymap_common.c
@@ -0,0 +1,30 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "keymap_common.h"
+
+
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+    return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
+}
diff --git a/keyboard/atomic/keymap_common.h b/keyboard/atomic/keymap_common.h
new file mode 100644
index 0000000000..f827480f0e
--- /dev/null
+++ b/keyboard/atomic/keymap_common.h
@@ -0,0 +1,51 @@
+/*
+Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef KEYMAP_COMMON_H
+#define KEYMAP_COMMON_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/pgmspace.h>
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "print.h"
+#include "debug.h"
+#include "keymap.h"
+
+
+extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+
+#define KEYMAP( \
+    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
+    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
+    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2C,   K2E, \
+    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3B,   K3D, K3E, \
+     K40,  K42,  K45,  K46,     K47,    K48,  K49,  K4A,  K4B,  K4C, K4D, K4E  \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO,    KC_##K0E }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_NO,    KC_##K2E }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_NO,    KC_##K3D, KC_##K3E }, \
+    { KC_##K40, KC_NO,    KC_##K42, KC_NO,    KC_NO,    KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
+}
+
+#endif
diff --git a/keyboard/atomic/keymap_hasu.c b/keyboard/atomic/keymap_hasu.c
new file mode 100644
index 0000000000..e6af28585b
--- /dev/null
+++ b/keyboard/atomic/keymap_hasu.c
@@ -0,0 +1,145 @@
+#include "keymap_common.h"
+
+/*
+ * Hasu
+ */
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* Keymap 0: Default Layer
+     * ,-----------------------------------------------------------.
+     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+     * |-----------------------------------------------------------|
+     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+     * |-----------------------------------------------------------|
+     * |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|Fn2|Shift     |
+     * |-----------------------------------------------------------|
+     * |Ctrl|Gui |Alt |      Space             |Alt |Fn4 |Fn4 |Fn1 |
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP_ANSI(
+        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
+        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   FN2, QUOT,     ENT,  \
+        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, FN1,           FN9,  \
+        LCTL,LGUI,LALT,          SPC,                     RALT,FN3, FN3, FN0),
+    /* Keymap 1: colemak */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   W,   F,   P,   G,   J,   L,   U,   Y,   SCLN,LBRC,RBRC,BSLS, \
+        BSPC,A,   R,   S,   T,   D,   H,   N,   E,   I,   O,   QUOT,     ENT,  \
+        LSFT,Z,   X,   C,   V,   B,   K,   M,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, FN0),
+    /* Keymap 2: dvorak */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   LBRC,RBRC,BSPC, \
+        TAB, QUOT,COMM,DOT, P,   Y,   F,   G,   C,   R,   L,   SLSH,EQL, BSLS, \
+        CAPS,A,   O,   E,   U,   I,   D,   H,   T,   N,   S,   MINS,     ENT,  \
+        LSFT,SCLN,Q,   J,   K,   X,   B,   M,   W,   V,   Z,             RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, FN0),
+    /* Keymap 3: workman */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   D,   R,   W,   B,   J,   F,   U,   P,   SCLN,LBRC,RBRC,BSLS, \
+        BSPC,A,   S,   H,   T,   G,   Y,   N,   E,   O,   I,   QUOT,     ENT,  \
+        LSFT,Z,   X,   M,   C,   V,   K,   L,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, FN0),
+
+    /* Overlay 4: HHKB mode
+     * ,-----------------------------------------------------------.
+     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
+     * |-----------------------------------------------------------|
+     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |Inser|
+     * |-----------------------------------------------------------|
+     * |Contro|VoD|VoU|Mut|   |   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
+     * |-----------------------------------------------------------|
+     * |Shift   |   |   |   |   |   |  +|  -|End|PgD|Dow|Shift     |
+     * |-----------------------------------------------------------|
+     * |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |    |
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP_ANSI(
+        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL,  \
+        CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP,  TRNS,INS,  \
+        LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,     ENT,  \
+        LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,FN4, TRNS),
+    /* Overlay 5: Vi mode (Slash)
+     * ,-----------------------------------------------------------.
+     * |  `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
+     * |-----------------------------------------------------------|
+     * |Tab  |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End|   |   |   |     |
+     * |-----------------------------------------------------------|
+     * |Contro|   |Lef|Dow|Rig|   |Lef|Dow|Up |Rig|   |   |Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |   |   |   |   |   |Hom|PgD|PgU|End|   |Shift     |
+     * |-----------------------------------------------------------|
+     * |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |Ctrl|
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP_ANSI(
+        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, BSPC, \
+        TAB, HOME,PGDN,UP,  PGUP,END, HOME,PGDN,PGUP,END, TRNS,TRNS,TRNS,TRNS, \
+        LCTL,TRNS,LEFT,DOWN,RGHT,TRNS,LEFT,DOWN,UP,  RGHT,TRNS,TRNS,     ENT,  \
+        LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGDN,PGUP,END, TRNS,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL),
+    /* Overlay 6: Mouse mode (Semicolon/App)
+     * ,-----------------------------------------------------------.
+     * |  `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
+     * |-----------------------------------------------------------|
+     * |Tab  |   |   |   |   |   |MwL|MwD|MwU|MwR|   |   |   |     |
+     * |-----------------------------------------------------------|
+     * |Contro|   |Ac0|Ac1|Ac1|   |McL|McD|McU|McR|   |   |Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift     |
+     * |-----------------------------------------------------------|
+     * |Ctrl|Gui |Alt |      Space             |    |    |    |    |
+     * `-----------------------------------------------------------'
+     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
+     */
+    KEYMAP_ANSI(
+        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, BSPC, \
+        TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,TRNS, \
+        LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,TRNS,     ENT,  \
+        LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,TRNS,          RSFT, \
+        LCTL,LGUI,LALT,          BTN1,                    TRNS,TRNS,TRNS,RCTL),
+    /* Overlay 7: Layout selector
+     * ,-----------------------------------------------------------.
+     * | Lq| Lc| Ld| Lw|   |   |   |   |   |   |   |   |   |       |
+     * |-----------------------------------------------------------|
+     * |     |Lq |Lw |   |   |   |   |   |   |   |   |   |   |     |
+     * |-----------------------------------------------------------|
+     * |      |   |   |Ld |   |   |   |   |   |   |   |   |        |
+     * |-----------------------------------------------------------|
+     * |        |   |   |Lc |   |   |   |   |   |   |   |          |
+     * |-----------------------------------------------------------|
+     * |    |    |    |                        |    |    |    |    |
+     * `-----------------------------------------------------------'
+     * Lq: set Qwerty layout
+     * Lc: set Colemak layout
+     * Ld: set Dvorak layout
+     * Lw: set Workman layout
+     */
+    KEYMAP_ANSI(
+        FN5, FN6, FN7, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,FN5, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,FN6, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
+};
+
+/*
+ * Fn action definition
+ */
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(4),
+    [1] = ACTION_LAYER_TAP_KEY(5, KC_SLASH),
+    [2] = ACTION_LAYER_TAP_KEY(6, KC_SCLN),
+    [3] = ACTION_LAYER_MOMENTARY(6),
+    [4] = ACTION_LAYER_MOMENTARY(7),   // to Layout selector
+    [5] = ACTION_DEFAULT_LAYER_SET(0),  // set qwerty layout
+    [6] = ACTION_DEFAULT_LAYER_SET(1),  // set colemak layout
+    [7] = ACTION_DEFAULT_LAYER_SET(2),  // set dvorak layout
+    [8] = ACTION_DEFAULT_LAYER_SET(3),  // set workman layout
+    [9] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV),
+};
diff --git a/keyboard/atomic/keymap_hhkb.c b/keyboard/atomic/keymap_hhkb.c
new file mode 100644
index 0000000000..ce1b816ecb
--- /dev/null
+++ b/keyboard/atomic/keymap_hhkb.c
@@ -0,0 +1,52 @@
+#include "keymap_common.h"
+
+/*
+ * HHKB Layout
+ */
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* 0: Default layer
+     * ,-----------------------------------------------------------.
+     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|  `|
+     * |-----------------------------------------------------------|
+     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Bspc |
+     * |-----------------------------------------------------------|
+     * |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Fn |
+     * |-----------------------------------------------------------|
+     * |    |Gui |Alt |      Space             |    |Alt |Gui |    |
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP_HHKB(
+        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSLS, GRV, \
+        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSPC,      \
+        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,       \
+        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,FN0,       \
+        NO,  LGUI,LALT,          SPC,                     NO,  RALT,RGUI,NO),
+    /* 1: HHKB Fn layer
+     * ,-----------------------------------------------------------.
+     * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
+     * |-----------------------------------------------------------|
+     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |     |
+     * |-----------------------------------------------------------|
+     * |      |VoD|VoU|Mut|Ejc|   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
+     * |-----------------------------------------------------------|
+     * |        |   |   |   |   |   |  +|  -|End|PgD|Dow|      |   |
+     * |-----------------------------------------------------------|
+     * |    |    |    |                        |    |    |    |    |
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP_HHKB(
+        PWR, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL,  \
+        CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP,  TRNS,TRNS,      \
+        TRNS,VOLD,VOLU,MUTE,EJCT,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,     PENT,      \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,     TRNS,TRNS,      \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
+};
+
+/*
+ * Fn action definition
+ */
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(1),
+};
diff --git a/keyboard/atomic/keymap_plain.c b/keyboard/atomic/keymap_plain.c
new file mode 100644
index 0000000000..d1e5c54871
--- /dev/null
+++ b/keyboard/atomic/keymap_plain.c
@@ -0,0 +1,50 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* 0: qwerty */
+    [0] = KEYMAP(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
+                 TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    LBRC, RBRC, BSLS, DEL, \
+                 ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,    ENT,     MPLY, \
+                 LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                 LCTL,    LALT,  LGUI,  FN2,    SPC,   FN1,  RGUI,   RALT,         LEFT, DOWN, UP,   RGHT),
+    [1] = KEYMAP(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
+                 TAB,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, LBRC, RBRC, BSLS, DEL, \
+                 ESC,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,    QUOT,    ENT,     MPLY, \
+                 LSFT, Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                 LCTL,    LALT,  LGUI,  FN2,    SPC,   FN1,  RGUI,   RALT,         LEFT, DOWN, UP,   RGHT),
+    [2] = KEYMAP(GRV,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,    BSPC, \
+                 TAB,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    LBRC, RBRC, BSLS, DEL, \
+                 ESC,  FN3, FN4, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC,   BSLS,    ENT,     MPLY, \
+                 LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                 LCTL,    LALT,  LGUI,  TRNS,   SPC,   FN1,  RGUI,   RALT,         MNXT, VOLD, VOLU, MPLY),
+    [3] = KEYMAP(GRV,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,    BSPC, \
+                 TAB,  FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, LBRC, RBRC, BSLS, DEL, \
+                 ESC,  FN3, FN4, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,    ENT,     MPLY, \
+                 LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                 LCTL,    LALT,  LGUI,  FN2,    SPC,   TRNS, RGUI,   RALT,         MNXT, VOLD, VOLU, MPLY),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
+    [2] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay 
+    // [1] = ACTION_LAYER_ON_OFF(1),
+    // [2] = ACTION_LAYER_ON_OFF(2),
+    [3] = ACTION_DEFAULT_LAYER_SET(0), 
+    [4] = ACTION_DEFAULT_LAYER_SET(1),  
+
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+};
diff --git a/keyboard/atomic/keymap_planck.c b/keyboard/atomic/keymap_planck.c
new file mode 100644
index 0000000000..ddacb614e6
--- /dev/null
+++ b/keyboard/atomic/keymap_planck.c
@@ -0,0 +1,51 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = KEYMAP( /* Native */
+      ESC,     Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    FN2, 
+      BSPC,    A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
+      TAB,     Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
+      DEL,     LCTL, NO,   LSFT, LALT, SPC,        NO,   LEFT, DOWN, UP,  RGHT), 
+    [1] = KEYMAP( /* QWERTY->PHOTOSHOP */
+      DELETE,  0,    1,    2,    3,    4,    5,    6,    7,    8,    9,    FN1,
+      O,       G,    S,    U,    T,    FN27,  F21,  F10,  F11,  F7,   F8,   F9,
+      TAB,     FN4, FN5,  FN6,  F1,   FN7,  F18,  F19,  F23,  F20,  F22,  FN9,
+      COMM,    DOT,  FN10, FN11, FN3,  SPC,        FN12, F2,   FN8,  F3,   F14),
+    [2] = KEYMAP( /* 2: FN3 PHOTOSHOP */
+      ESC,    FN25, FN26,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,
+      NO,      NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   FN19, FN20, FN21, 
+      C,       NO,  FN22,  FN5,   NO,   FN23, NO,   NO,   NO,   NO,   FN13, NO,
+      FN14,    FN15, FN16, FN17, FN3,   SPC,        FN18, NO,   NO,   F24,  NO),
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_DEFAULT_LAYER_SET(0),                             // set Qwerty layout
+    [2] = ACTION_DEFAULT_LAYER_SET(1),                             // set Photoshop presets
+    [3] = ACTION_LAYER_ON_OFF(2),                                  // Photoshop function layer
+ 
+    [4] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F9),   // photo folder AHK
+    [5] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_I),              // select inverse
+    [6] = ACTION_MODS_KEY(MOD_LSFT, KC_M),                         // marquee select
+    [7] = ACTION_MODS_KEY(MOD_LALT, KC_BSPC),                      // fill 
+    [8] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_X),    // warp
+    [9] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT | MOD_LSFT, KC_F12),  // merge all new layer
+    [10] = ACTION_MODS_KEY(MOD_LCTL, KC_MINS),                     // zoom out
+    [11] = ACTION_MODS_KEY(MOD_LCTL, KC_H),                        // RBG sliders
+    [12] = ACTION_MODS_KEY(MOD_LCTL, KC_S),                        // save
+    [13] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F5),           // layer mask from transparancy 
+    [14] = ACTION_MODS_KEY(MOD_LALT, KC_LBRC),                     // prev layer
+    [15] = ACTION_MODS_KEY(MOD_LALT, KC_RBRC),                     // next layer
+    [16] = ACTION_MODS_KEY(MOD_LCTL, KC_EQL),                      // zoom in
+    [17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_H),             // HSV sliders
+    [18] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F11), // save as PNG
+    [19] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F7),  // gaussian blur
+    [20] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F8),  // motion blur
+    [21] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_X),            // liquify filter
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),                     // prev layer blending
+    [23] = ACTION_MODS_KEY(MOD_LSFT | MOD_LALT, KC_N),             // normal layer blending
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),                      // next layer blending
+    [25] = ACTION_MODS_KEY(MOD_LCTL, KC_Z),                        // step back
+    [26] = ACTION_MODS_KEY(MOD_LCTL, KC_Y),                        // step forward
+    [27] = ACTION_MODS_KEY(MOD_LCTL, KC_R),                        // rasterize
+     
+};
diff --git a/keyboard/atomic/keymap_poker.c b/keyboard/atomic/keymap_poker.c
new file mode 100644
index 0000000000..7a612ee44d
--- /dev/null
+++ b/keyboard/atomic/keymap_poker.c
@@ -0,0 +1,104 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* 0: qwerty */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
+        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
+        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
+    /* 1: colemak */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   W,   F,   P,   G,   J,   L,   U,   Y,   SCLN,LBRC,RBRC,BSLS, \
+        BSPC,A,   R,   S,   T,   D,   H,   N,   E,   I,   O,   QUOT,     ENT,  \
+        LSFT,Z,   X,   C,   V,   B,   K,   M,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
+    /* 2: dvorak */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   LBRC,RBRC,BSPC, \
+        TAB, QUOT,COMM,DOT, P,   Y,   F,   G,   C,   R,   L,   SLSH,EQL, BSLS, \
+        CAPS,A,   O,   E,   U,   I,   D,   H,   T,   N,   S,   MINS,     ENT,  \
+        LSFT,SCLN,Q,   J,   K,   X,   B,   M,   W,   V,   Z,             RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
+    /* 3: workman */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   D,   R,   W,   B,   J,   F,   U,   P,   SCLN,LBRC,RBRC,BSLS, \
+        BSPC,A,   S,   H,   T,   G,   Y,   N,   E,   O,   I,   QUOT,     ENT,  \
+        LSFT,Z,   X,   M,   C,   V,   K,   L,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
+    /* 4: Poker with Arrow */
+    KEYMAP_ANSI(
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,LEFT,DOWN,RGHT),
+    /* 5: Poker with Esc */
+    KEYMAP_ANSI(
+        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
+    /* 6: Poker Fn
+     * ,-----------------------------------------------------------.
+     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|       |
+     * |-----------------------------------------------------------|
+     * |     |FnQ| Up|   |   |   |   |   |   |Cal|   |Hom|Ins|FnL  |
+     * |-----------------------------------------------------------|
+     * |      |Lef|Dow|Rig|   |   |Psc|Slk|Pau|   |Tsk|End|        |
+     * |-----------------------------------------------------------|
+     * |        |Del|   |Web|Mut|VoU|VoD|   |PgU|PgD|Del|          |
+     * |-----------------------------------------------------------|
+     * |    |    |    |         FnS            |    |    |    |    |
+     * `-----------------------------------------------------------'
+     * Fn:  to Fn overlay
+     * FnL: to Layout selector overaly
+     * FnQ: toggle Esc overlay
+     * FnS: toggle Arrow overlay
+     */
+    KEYMAP_ANSI(
+        ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
+        TRNS,FN2, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, FN4,  \
+        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN3, END,      TRNS, \
+        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
+        TRNS,TRNS,TRNS,          FN1,                     TRNS,TRNS,TRNS,TRNS),
+    /* 7: Layout selector
+     * ,-----------------------------------------------------------.
+     * | Lq| Lc| Ld| Lw|   |   |   |   |   |   |   |   |   |       |
+     * |-----------------------------------------------------------|
+     * |     |Lq |Lw |   |   |   |   |   |   |   |   |   |   |     |
+     * |-----------------------------------------------------------|
+     * |      |   |   |Ld |   |   |   |   |   |   |   |   |        |
+     * |-----------------------------------------------------------|
+     * |        |   |   |Lc |   |   |   |   |   |   |   |          |
+     * |-----------------------------------------------------------|
+     * |    |    |    |                        |    |    |    |    |
+     * `-----------------------------------------------------------'
+     * Lq: set Qwerty layout
+     * Lc: set Colemak layout
+     * Ld: set Dvorak layout
+     * Lw: set Workman layout
+     */
+    KEYMAP_ANSI(
+        FN5, FN6, FN7, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,FN5, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,FN6, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    /* Poker Layout */
+    [0] = ACTION_LAYER_MOMENTARY(6),  // to Fn overlay
+    [1] = ACTION_LAYER_TOGGLE(4),     // toggle arrow overlay
+    [2] = ACTION_LAYER_TOGGLE(5),     // toggle Esc overlay
+    [3] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // Task(RControl,RShift+Esc)
+    [4] = ACTION_LAYER_MOMENTARY(7),  // to Layout selector
+    [5] = ACTION_DEFAULT_LAYER_SET(0),  // set qwerty layout
+    [6] = ACTION_DEFAULT_LAYER_SET(1),  // set colemak layout
+    [7] = ACTION_DEFAULT_LAYER_SET(2),  // set dvorak layout
+    [8] = ACTION_DEFAULT_LAYER_SET(3),  // set workman layout
+};
diff --git a/keyboard/atomic/keymap_poker_bit.c b/keyboard/atomic/keymap_poker_bit.c
new file mode 100644
index 0000000000..b8870fdd81
--- /dev/null
+++ b/keyboard/atomic/keymap_poker_bit.c
@@ -0,0 +1,50 @@
+#include "keymap_common.h"
+
+// Poker fix with toggle and bit operation
+// Fn + Esc = `
+// Fn + {left, down, up, right}  = {home, pgdown, pgup, end}
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* 0: qwerty */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
+        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
+        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
+    /* 4: Poker Default + Fn'd */
+    [4] = KEYMAP_ANSI(
+        TRNS,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
+        CAPS,FN2, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
+        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN4, END,      TRNS, \
+        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
+        TRNS,TRNS,TRNS,          FN1,                     TRNS,TRNS,TRNS,TRNS),
+    /* 5: Poker with Arrow */
+    KEYMAP_ANSI(
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          PGUP, \
+        TRNS,TRNS,TRNS,          TRNS,                    FN3, HOME,PGDN,END),
+    /* 6: Poker with Esc */
+    KEYMAP_ANSI(
+        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
+    /* 7: Poker with Arrow + Fn'd */
+    KEYMAP_ANSI(
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,LEFT,DOWN,RGHT),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    /* Poker Layout */
+    [0] = ACTION_LAYER_BIT_XOR(1, 0b0101, ON_BOTH),   // Poker Fn(with fix for Esc)
+    [1] = ACTION_LAYER_TOGGLE(5),                     // Poker Arrow toggle
+    [2] = ACTION_LAYER_TOGGLE(6),                     // Poker Esc toggle
+    [3] = ACTION_LAYER_BIT_XOR(1, 0b1101, ON_BOTH),   // Poker Fn(with fix for Arrow)
+    [4] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // FN3 Task(RControl,RShift+Esc)
+};
diff --git a/keyboard/atomic/keymap_poker_set.c b/keyboard/atomic/keymap_poker_set.c
new file mode 100644
index 0000000000..aaa31fc571
--- /dev/null
+++ b/keyboard/atomic/keymap_poker_set.c
@@ -0,0 +1,82 @@
+#include "keymap_common.h"
+
+// Poker fix with set(state transition)
+// Fn + Esc = `
+// Fn + {left, down, up, right}  = {home, pgdown, pgup, end}
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* 0: qwerty */
+    KEYMAP_ANSI(
+        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
+        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
+        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
+    /* 1: Poker with Arrow */
+    KEYMAP_ANSI(
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
+        TRNS,TRNS,TRNS,          TRNS,                    FN1, LEFT,DOWN,RGHT),
+    /* 2: Poker with Esc */
+    KEYMAP_ANSI(
+        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
+        TRNS,TRNS,TRNS,          TRNS,                    FN2, TRNS,TRNS,TRNS),
+    /* 3: Poker with Arrow and Esc */
+    KEYMAP_ANSI(
+        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
+        TRNS,TRNS,TRNS,          TRNS,                    FN3, LEFT,DOWN,RGHT),
+    /* 4: Poker Fn'd */
+    KEYMAP_ANSI(
+        ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
+        TRNS,FN6, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
+        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
+        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
+        TRNS,TRNS,TRNS,          FN5,                     FN4, TRNS,TRNS,TRNS),
+    /* 5: Poker Fn'd arrow */
+    KEYMAP_ANSI(
+        ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
+        TRNS,FN7, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
+        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
+        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           PGUP, \
+        TRNS,TRNS,TRNS,          FN4,                     FN5, HOME,PGDN,END),
+    /* 6: Poker Fn'd Esc */
+    KEYMAP_ANSI(
+        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
+        TRNS,FN4, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
+        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
+        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
+        TRNS,TRNS,TRNS,          FN7,                     FN6, TRNS,TRNS,TRNS),
+    /* 7: Poker Fn'd Arrow + Esc */
+    KEYMAP_ANSI(
+        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
+        TRNS,FN5, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
+        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
+        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           PGUP, \
+        TRNS,TRNS,TRNS,          FN6,                     FN7, HOME,PGDN,END),
+};
+
+/*
+ * Fn action definition
+ */
+const uint16_t PROGMEM fn_actions[] = {
+    /* Poker Layout */
+    [0] = ACTION_LAYER_SET(4, ON_PRESS),     // FN0 move to Fn'd             when press
+    [1] = ACTION_LAYER_SET(5, ON_PRESS),     // FN1 move to Fn'd arrow       when press
+    [2] = ACTION_LAYER_SET(6, ON_PRESS),     // FN2 move to Fn'd Esc         when press
+    [3] = ACTION_LAYER_SET(7, ON_PRESS),     // FN3 move to Fn'd arrow + Esc when press
+
+    //[4] = ACTION_LAYER_CLEAR(ON_RELEASE),    // FN4 clear overlay            when release
+    [4] = ACTION_LAYER_SET(0, ON_RELEASE),   // FN4 clear overlay            when release
+    [5] = ACTION_LAYER_SET(1, ON_RELEASE),   // FN5 move to arrow            when release
+    [6] = ACTION_LAYER_SET(2, ON_RELEASE),   // FN6 move to Esc              when release
+    [7] = ACTION_LAYER_SET(3, ON_RELEASE),   // FN7 move to arrow + Esc      when release
+
+    [8] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // FN8 Task(RControl,RShift+Esc)
+};
diff --git a/keyboard/atomic/keymap_spacefn.c b/keyboard/atomic/keymap_spacefn.c
new file mode 100644
index 0000000000..8077dcee7b
--- /dev/null
+++ b/keyboard/atomic/keymap_spacefn.c
@@ -0,0 +1,55 @@
+#include "keymap_common.h"
+
+/*
+ * SpaceFN
+ * http://geekhack.org/index.php?topic=51069.0
+ */
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* Keymap 0: Default Layer
+     * ,-----------------------------------------------------------.
+     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
+     * |-----------------------------------------------------------|
+     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
+     * |-----------------------------------------------------------|
+     * |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
+     * |-----------------------------------------------------------|
+     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
+     * |-----------------------------------------------------------|
+     * |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |Ctrl|
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP_ANSI(
+        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
+        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
+        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
+        LCTL,LGUI,LALT,          FN0,                     RALT,RGUI,APP, RCTL),
+
+    /* Overlay 1: SpaceFN
+     * ,-----------------------------------------------------------.
+     * |`  | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
+     * |-----------------------------------------------------------|
+     * |     |   |   |   |   |   |   |Hom|Up |End|Psc|Slk|Pau|Ins  |
+     * |-----------------------------------------------------------|
+     * |      |   |   |   |   |   |PgU|Lef|Dow|Rig|   |   |        |
+     * |-----------------------------------------------------------|
+     * |        |   |   |   |   |Spc|PgD|`  |~  |   |   |          |
+     * |-----------------------------------------------------------|
+     * |    |    |    |                        |    |    |    |    |
+     * `-----------------------------------------------------------'
+     */
+    KEYMAP_ANSI(
+        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL,  \
+        TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP,  END, PSCR,SLCK,PAUS,INS,  \
+        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS,     TRNS, \
+        TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,TRNS,          TRNS, \
+        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
+};
+
+/*
+ * Fn action definition
+ */
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE),
+    [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),    // tilde
+};
diff --git a/keyboard/atomic/led.c b/keyboard/atomic/led.c
new file mode 100644
index 0000000000..7c98510801
--- /dev/null
+++ b/keyboard/atomic/led.c
@@ -0,0 +1,34 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <avr/io.h>
+#include "stdint.h"
+#include "led.h"
+
+
+void led_set(uint8_t usb_led)
+{
+    if (usb_led & (1<<USB_LED_FUNCTION)) {
+        // Output high.
+        DDRF |= (1<<0);
+        PORTF |= (1<<0);
+    } else {
+        // Output low.
+        DDRF &= ~(1<<0);
+        PORTF &= ~(1<<0);
+    }
+}
diff --git a/keyboard/atomic/matrix.c b/keyboard/atomic/matrix.c
new file mode 100644
index 0000000000..435e08952a
--- /dev/null
+++ b/keyboard/atomic/matrix.c
@@ -0,0 +1,230 @@
+/*
+Copyright 2012 Jun Wako <wakojun@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * scan matrix
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "action_layer.h"
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+
+
+#ifndef DEBOUNCE
+#   define DEBOUNCE 10
+#endif
+static uint8_t debouncing = DEBOUNCE;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static matrix_row_t read_cols(void);
+static void init_cols(void);
+static void unselect_rows(void);
+static void select_row(uint8_t row);
+
+
+inline
+uint8_t matrix_rows(void)
+{
+    return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+    return MATRIX_COLS;
+}
+
+static
+void setup_leds(void) {
+  DDRF  |=  0x00;
+  PORTF |=  0x00;
+}
+
+
+void matrix_init(void)
+{
+    // initialize row and col
+    unselect_rows();
+    init_cols();
+
+    setup_leds();
+
+    // initialize matrix state: all keys off
+    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+        matrix[i] = 0;
+        matrix_debouncing[i] = 0;
+    }
+}
+
+uint8_t matrix_scan(void)
+{
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        select_row(i);
+        _delay_us(30);  // without this wait read unstable value.
+        matrix_row_t cols = read_cols();
+        if (matrix_debouncing[i] != cols) {
+            matrix_debouncing[i] = cols;
+            if (debouncing) {
+                debug("bounce!: "); debug_hex(debouncing); debug("\n");
+            }
+            debouncing = DEBOUNCE;
+        }
+        unselect_rows();
+    }
+
+    if (debouncing) {
+        if (--debouncing) {
+            _delay_ms(1);
+        } else {
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+                matrix[i] = matrix_debouncing[i];
+            }
+        }
+    }
+
+    // uint8_t layer = biton32(default_layer_state);
+    switch (default_layer_state) {
+        case 1:
+            DDRF &= ~(1<<0);
+            PORTF &= ~(1<<0);
+            break;
+        case 2:
+            DDRF |= (1<<0);
+            PORTF |= (1<<0);
+            break;
+    }
+
+    return 1;
+}
+
+bool matrix_is_modified(void)
+{
+    if (debouncing) return false;
+    return true;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+    return (matrix[row] & ((matrix_row_t)1<<col));
+}
+
+inline
+matrix_row_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void matrix_print(void)
+{
+    print("\nr/c 0123456789ABCDEF\n");
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+        phex(row); print(": ");
+        pbin_reverse16(matrix_get_row(row));
+        print("\n");
+    }
+}
+
+uint8_t matrix_key_count(void)
+{
+    uint8_t count = 0;
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        count += bitpop16(matrix[i]);
+    }
+    return count;
+}
+
+/* Column pin configuration
+ * col: 0  1  2  3  4  5  6  7  8  9  10 11
+ * pin: F0 F1 F4 F5 F6 F7 B6 B5 B4 D7 D5 D4
+ */
+
+static void init_cols(void)
+{
+    DDRC  &= ~(1<<6 | 1<<7);
+    PORTC |=  (1<<6 | 1<<7);
+    DDRD  &= ~(1<<4 | 1<<5 | 1<<6 | 1<<7);
+    PORTD |=  (1<<4 | 1<<5 | 1<<6 | 1<<7);
+    DDRB  &= ~(1<<4 | 1<<5 | 1<<6);
+    PORTB |=  (1<<4 | 1<<5 | 1<<6);
+    DDRF  &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    PORTF |=  (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+}
+
+static matrix_row_t read_cols(void)
+{
+    return (PINC&(1<<6) ? 0 : (1<< 0)) |
+           (PINC&(1<<7) ? 0 : (1<< 1)) |
+           (PIND&(1<<5) ? 0 : (1<< 2)) |
+           (PIND&(1<<4) ? 0 : (1<< 3)) |
+           (PIND&(1<<6) ? 0 : (1<< 4)) |
+           (PIND&(1<<7) ? 0 : (1<< 5)) |
+           (PINB&(1<<4) ? 0 : (1<< 6)) |
+           (PINB&(1<<5) ? 0 : (1<< 7)) |
+           (PINB&(1<<6) ? 0 : (1<< 8)) |
+           (PINF&(1<<7) ? 0 : (1<< 9)) |
+           (PINF&(1<<6) ? 0 : (1<<10)) |
+           (PINF&(1<<5) ? 0 : (1<<11)) |
+           (PINF&(1<<4) ? 0 : (1<<12)) |
+           (PINF&(1<<1) ? 0 : (1<<13)) |
+           (PINF&(1<<0) ? 0 : (1<<14));
+}
+
+/* Row pin configuration
+ * row: 0  1  2  3
+ * pin: B0 B1 B2 B3
+ */
+static void unselect_rows(void)
+{
+    // Hi-Z(DDR:0, PORT:0) to unselect
+    DDRB  &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+    PORTB |=  (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
+}
+
+static void select_row(uint8_t row)
+{
+    switch (row) {
+        case 0:
+            DDRB  |= (1<<0);
+            PORTB &= ~(1<<0);
+            break;
+        case 1:
+            DDRB  |= (1<<1);
+            PORTB &= ~(1<<1);
+            break;
+        case 2:
+            DDRB  |= (1<<2);
+            PORTB &= ~(1<<2);
+            break;
+        case 3:
+            DDRB  |= (1<<3);
+            PORTB &= ~(1<<3);
+            break;
+        case 4:
+            DDRB  |= (1<<7);
+            PORTB &= ~(1<<7);
+            break;
+    }
+}

From 2e0d872ab7ba8446cb7a9536acafd59d1db57f14 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Tue, 13 Jan 2015 18:05:37 -0500
Subject: [PATCH 37/95] sean

---
 keyboard/atomic/Makefile        |  2 +-
 keyboard/atomic/keymap_common.h | 12 +++----
 keyboard/atomic/keymap_plain.c  | 18 ++++------
 keyboard/atomic/matrix.c        | 11 -------
 keyboard/planck/Makefile        |  2 +-
 keyboard/planck/keymap_sean.c   | 50 ++++++++++++++++++++++++++++
 keyboard/planck/matrix.c        | 58 ++++++++++++++++-----------------
 7 files changed, 92 insertions(+), 61 deletions(-)
 create mode 100644 keyboard/planck/keymap_sean.c

diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile
index 0c407f703b..a018b6cab8 100644
--- a/keyboard/atomic/Makefile
+++ b/keyboard/atomic/Makefile
@@ -39,7 +39,7 @@
 #----------------------------------------------------------------------------
 
 # Target file name (without extension).
-TARGET = gh60_lufa
+TARGET = atomic_lufa
 
 # Directory common source filess exist
 TOP_DIR = ../..
diff --git a/keyboard/atomic/keymap_common.h b/keyboard/atomic/keymap_common.h
index f827480f0e..76864aae47 100644
--- a/keyboard/atomic/keymap_common.h
+++ b/keyboard/atomic/keymap_common.h
@@ -37,15 +37,15 @@ extern const uint16_t fn_actions[];
 #define KEYMAP( \
     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
-    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2C,   K2E, \
-    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3B,   K3D, K3E, \
-     K40,  K42,  K45,  K46,     K47,    K48,  K49,  K4A,  K4B,  K4C, K4D, K4E  \
+    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2D,   K2E, \
+    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3C,   K3D, K3E, \
+     K40,  K41,  K43,           K46,                  K4A, K4B, K4C, K4D, K4E  \
 ) { \
     { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO,    KC_##K0E }, \
     { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
-    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_NO,    KC_##K2E }, \
-    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_NO,    KC_##K3D, KC_##K3E }, \
-    { KC_##K40, KC_NO,    KC_##K42, KC_NO,    KC_NO,    KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO,    KC_##K2D, KC_##K2E }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO,    KC_##K3C, KC_##K3D, KC_##K3E }, \
+    { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_NO,    KC_NO,    KC_##K46, KC_NO,    KC_NO,    KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
 }
 
 #endif
diff --git a/keyboard/atomic/keymap_plain.c b/keyboard/atomic/keymap_plain.c
index d1e5c54871..c335fbe16f 100644
--- a/keyboard/atomic/keymap_plain.c
+++ b/keyboard/atomic/keymap_plain.c
@@ -6,31 +6,25 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
                  TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    LBRC, RBRC, BSLS, DEL, \
                  ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,    ENT,     MPLY, \
                  LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
-                 LCTL,    LALT,  LGUI,  FN2,    SPC,   FN1,  RGUI,   RALT,         LEFT, DOWN, UP,   RGHT),
+                 LCTL,    LALT,  LGUI,          SPC,                         FN1,  LEFT, DOWN, UP,   RGHT),
     [1] = KEYMAP(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
                  TAB,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, LBRC, RBRC, BSLS, DEL, \
                  ESC,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,    QUOT,    ENT,     MPLY, \
                  LSFT, Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
-                 LCTL,    LALT,  LGUI,  FN2,    SPC,   FN1,  RGUI,   RALT,         LEFT, DOWN, UP,   RGHT),
+                 LCTL,    LALT,  LGUI,          SPC,                         FN1,  LEFT, DOWN, UP,   RGHT),
     [2] = KEYMAP(GRV,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,    BSPC, \
                  TAB,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    LBRC, RBRC, BSLS, DEL, \
                  ESC,  FN3, FN4, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC,   BSLS,    ENT,     MPLY, \
-                 LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
-                 LCTL,    LALT,  LGUI,  TRNS,   SPC,   FN1,  RGUI,   RALT,         MNXT, VOLD, VOLU, MPLY),
-    [3] = KEYMAP(GRV,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,    BSPC, \
-                 TAB,  FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, LBRC, RBRC, BSLS, DEL, \
-                 ESC,  FN3, FN4, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,    ENT,     MPLY, \
-                 LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
-                 LCTL,    LALT,  LGUI,  FN2,    SPC,   TRNS, RGUI,   RALT,         MNXT, VOLD, VOLU, MPLY),
+                 LSFT, FN9,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                 LCTL,    LALT,  LGUI,          SPC,                         TRNS,  MNXT, VOLD, VOLU, MPLY),
 };
 const uint16_t PROGMEM fn_actions[] = {
     [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
-    [2] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay 
-    // [1] = ACTION_LAYER_ON_OFF(1),
-    // [2] = ACTION_LAYER_ON_OFF(2),
     [3] = ACTION_DEFAULT_LAYER_SET(0), 
     [4] = ACTION_DEFAULT_LAYER_SET(1),  
 
+    [9] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
+ 
     [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
     [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
     [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
diff --git a/keyboard/atomic/matrix.c b/keyboard/atomic/matrix.c
index 435e08952a..86803c9ed0 100644
--- a/keyboard/atomic/matrix.c
+++ b/keyboard/atomic/matrix.c
@@ -104,17 +104,6 @@ uint8_t matrix_scan(void)
         }
     }
 
-    // uint8_t layer = biton32(default_layer_state);
-    switch (default_layer_state) {
-        case 1:
-            DDRF &= ~(1<<0);
-            PORTF &= ~(1<<0);
-            break;
-        case 2:
-            DDRF |= (1<<0);
-            PORTF |= (1<<0);
-            break;
-    }
 
     return 1;
 }
diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index 0d84d8b472..22101096e9 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -55,7 +55,7 @@ SRC =	keymap_common.c \
 ifdef KEYMAP
     SRC := keymap_$(KEYMAP).c $(SRC)
 else
-    SRC := keymap_dotcom.c $(SRC)
+    SRC := keymap_sean.c $(SRC)
 endif
 
 CONFIG_H = config.h
diff --git a/keyboard/planck/keymap_sean.c b/keyboard/planck/keymap_sean.c
new file mode 100644
index 0000000000..4029846640
--- /dev/null
+++ b/keyboard/planck/keymap_sean.c
@@ -0,0 +1,50 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = KEYMAP( /* Matrix Dvorak */
+      QUOT, COMM, DOT,  P,    Y,    SLSH, EQL,  F,    G,    C,    R,   L,
+      A,    O,    E,    U,    I,    ESC,  BSPC, D,    H,    T,    N,   S,
+      SCLN, Q,    J,    K,    X,    TAB,  ENT,  B,    M,    W,    V,   Z,
+      LSFT, LCTL, LALT, LGUI, FN1,  SPC,        FN2,  LEFT, DOWN, UP,  RGHT),
+
+    [1] = KEYMAP( /* Matrix Qwerty */
+      Q,    W,    E,    R,    T,    SLSH, EQL,  Y,    U,    I,    O,    P,
+      A,    S,    D,    F,    G,    ESC,  BSPC, H,    J,    K,    L,    SCLN,
+      Z,    X,    C,    V,    B,    TAB,  ENT,  N,    M,    COMM, DOT,  SLSH,
+      LSFT, LCTL, LALT, LGUI, FN1,  SPC,        FN2,  LEFT, DOWN, UP,  RGHT),
+      
+    [2] = KEYMAP( /* fn1 */
+      F1,   F2,   F3,   F4,   F5,   NO,   NO,   F6,   F7,   F8,   F9,   F10,
+      1,    2,    3,    4,    5,    ESC,  DEL,  6,    7,    8,    9,    0,
+      FN3,   FN4,   NO,  GRV,   MINS, F18,  INS,  BSLS, LBRC, RBRC, NO,   NO,
+      TRNS, TRNS, TRNS, TRNS, FN1,  TRNS,       FN3,  HOME, PGDN, PGUP, END),
+
+    [3] = KEYMAP( /* fn2 */
+      F11,  F12,  F13,  F14,  F15,  NO,   NO,   F16,  F17,  F18,  F19,  F20,
+      F1,   F2,   F3,   F4,   F5,   ESC,  DEL,  F6,   F7,   F8,   F9,   F10,
+      FN3,  FN4,  NO,   GRV,  MINS, F18,  INS,  INS,  PSCR, SLCK, PAUS, TRNS,
+      TRNS, TRNS, TRNS, TRNS, FN3,  TRNS,       FN2,  MUTE, VOLD, VOLU, MPLY),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
+    [2] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay 
+    [3] = ACTION_DEFAULT_LAYER_SET(0), 
+    [4] = ACTION_DEFAULT_LAYER_SET(1),  
+
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+};
\ No newline at end of file
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c
index ca59f7c73b..38d35e3e07 100644
--- a/keyboard/planck/matrix.c
+++ b/keyboard/planck/matrix.c
@@ -136,38 +136,36 @@ uint8_t matrix_key_count(void)
 
 static void init_cols(void)
 {
-    DDRB &= ~(1<<7 | 1<<4 | 1<<5 | 1<<6);
-    PORTB |= (1<<7 | 1<<4 | 1<<5 | 1<<6);
-    DDRC &= ~(1<<6);
-    PORTC |= (1<<6);
-    DDRD &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
-    PORTD |= (1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<7);
-    DDRF &= ~(1<<7 | 1<<6);
-    PORTF |= (1<<7 | 1<<6);
+    DDRB &= ~(1<<6 | 1<<5 | 1<<4);
+    PORTB |= (1<<6 | 1<<5 | 1<<4);
+    DDRD &= ~(1<<7 | 1<<6 | 1<<4);
+    PORTD |= (1<<7 | 1<<6 | 1<<4);
+    DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
     
 }
 
 static matrix_row_t read_cols(void)
 {
-  return (PINB&(1<<7) ? 0 : (1<<0)) |
-         (PIND&(1<<0) ? 0 : (1<<1)) |
-         (PIND&(1<<1) ? 0 : (1<<2)) |
-         (PIND&(1<<2) ? 0 : (1<<3)) |
-         (PIND&(1<<3) ? 0 : (1<<4)) |
-         (PINC&(1<<6) ? 0 : (1<<5)) |
-         (PIND&(1<<7) ? 0 : (1<<6)) |
-         (PINB&(1<<4) ? 0 : (1<<7)) |
-         (PINB&(1<<5) ? 0 : (1<<8)) |
-         (PINB&(1<<6) ? 0 : (1<<9)) |
-         (PINF&(1<<7) ? 0 : (1<<10)) |
-         (PINF&(1<<6) ? 0 : (1<<11));
+  return (PIND&(1<<4) ? 0 : (1<<0)) |
+         (PIND&(1<<6) ? 0 : (1<<1)) |
+         (PIND&(1<<7) ? 0 : (1<<2)) |
+         (PINB&(1<<4) ? 0 : (1<<3)) |
+         (PINB&(1<<5) ? 0 : (1<<4)) |
+         (PINB&(1<<6) ? 0 : (1<<5)) |
+         (PINF&(1<<7) ? 0 : (1<<6)) |
+         (PINF&(1<<6) ? 0 : (1<<7)) |
+         (PINF&(1<<5) ? 0 : (1<<8)) |
+         (PINF&(1<<4) ? 0 : (1<<9)) |
+         (PINF&(1<<1) ? 0 : (1<<10)) |
+         (PINF&(1<<0) ? 0 : (1<<11));
          
 }
 
 static void unselect_rows(void)
 {
-    DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5);
-    PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5);
+    DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
+    PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3);
     
 }
 
@@ -175,20 +173,20 @@ static void select_row(uint8_t row)
 {
     switch (row) {
         case 0:
-            DDRF  |= (1<<0);
-            PORTF &= ~(1<<0);
+            DDRB  |= (1<<0);
+            PORTB &= ~(1<<0);
             break;
         case 1:
-            DDRF  |= (1<<1);
-            PORTF &= ~(1<<1);
+            DDRB  |= (1<<1);
+            PORTB &= ~(1<<1);
             break;
         case 2:
-            DDRF  |= (1<<4);
-            PORTF &= ~(1<<4);
+            DDRB  |= (1<<2);
+            PORTB &= ~(1<<2);
             break;
         case 3:
-            DDRF  |= (1<<5);
-            PORTF &= ~(1<<5);
+            DDRB  |= (1<<3);
+            PORTB &= ~(1<<3);
             break;
         
     }

From 173dbe3b283ad4bb9bca2f2ac781eadd5c413bb3 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Wed, 14 Jan 2015 21:36:25 -0500
Subject: [PATCH 38/95] Create keymap_shane.c

---
 keyboard/planck/keymap_shane.c | 100 +++++++++++++++++++++++++++++++++
 1 file changed, 100 insertions(+)
 create mode 100644 keyboard/planck/keymap_shane.c

diff --git a/keyboard/planck/keymap_shane.c b/keyboard/planck/keymap_shane.c
new file mode 100644
index 0000000000..d4e40fe63a
--- /dev/null
+++ b/keyboard/planck/keymap_shane.c
@@ -0,0 +1,100 @@
+// https://github.com/shanecelis/tmk_keyboard/blob/master/keyboard/planck/keymap_shane.c
+
+#include "keymap_common.h"
+#include "action_layer.h"
+#include "action.h"
+#include "action_util.h"
+
+/*
+  Shane's Planck Layout
+  http://www.keyboard-layout-editor.com/#/layouts/015d9011102619d7695c86ffe57cf441
+*/
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+  [0] = KEYMAP_AND_SWAP( /* Base */
+    TAB,	Q,	W,	E,	R,	T,	Y,	U,	I,	O,	P,	MINS,
+    LCTL,	A,	S,	D,	F,	G,	H,	J,	K,	L,	SCLN,	BSPC,
+    LSFT,	Z,	X,	C,	V,	B,	N,	M,	COMM,	DOT,	SLSH,	FN5,
+    /*ALPHA*/FN3,	/*HYPER*/	/*SUPER*/LGUI, /*META*/LALT, LCTL,	FN2,	FN6,	FN1,	LEFT,	DOWN,	UP,	RGHT),
+  [2] = KEYMAP_AND_SWAP( /* More modifiers */
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS, RCTL, RALT, RGUI,	TRNS),
+  [4] = KEYMAP_AND_SWAP( /* WASD */
+    TRNS,	TRNS,	UP,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,
+    TRNS,	LEFT,	DOWN,	RIGHT,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS, TRNS, TRNS, TRNS, TRNS),
+  [6] = KEYMAP_AND_SWAP( /* Raise/FN1 */
+    FN23,	1,	2,	3,	4,	5,	6,	7,	8,	9,	0,	EQL,
+    TRNS,	F1,	F2,	F3,	F4,	F5,	F6,	F7,	F8,	F9,	F10,	ENT,
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	BSLS,	TRNS,
+    PAUS,	TRNS,	TRNS,	TRNS,	TRNS,	BSPC,	TRNS,	MUTE,	PGUP,	PGDN,	MNXT),
+  [8] = KEYMAP_AND_SWAP( /* Lower/FN2 */
+    ESC,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	FN19,	FN20,	TRNS,
+    TRNS,	TRNS,	TRNS,	TRNS,	CAPS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	QUOT,
+    TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	TRNS,	FN24,	FN25,	LBRC,	RBRC,	TRNS,	TRNS,
+    FN4,	TRNS,	TRNS,	TRNS,	TRNS,	ENT,	TRNS,	MPLY,	VOLD,	VOLU,	MPRV),
+};
+
+enum function_id {
+  SPACE_FN,
+};
+
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+  switch (id) {
+  case SPACE_FN:
+    if (record->event.pressed) {
+      // Change the keyboard maps.
+      // Whatever even layer's are on, turn on the odd one's too.
+      for (uint8_t i = 0; i < 9; i += 2) {
+        if (layer_state & (1UL << i))
+          layer_on(i + 1);
+      }
+      layer_on(1);
+    } else {
+      // turn off all the even layers.
+      for (uint8_t i = 0; i < 9; i += 2)
+        layer_off(i + 1);
+
+      if (record->tap.count != 0) {
+        // Space was tapped rather than used like a modifier.
+        // So send a space up and down event.
+        add_key(KC_SPC);
+        send_keyboard_report();
+        del_key(KC_SPC);
+        send_keyboard_report();
+      }
+    }
+    break;
+  }
+}
+
+
+
+const uint16_t PROGMEM fn_actions[] = {
+  [1] = ACTION_LAYER_MOMENTARY(6),  // to fist Fn overlay
+  [2] = ACTION_LAYER_MOMENTARY(8),  // to second Fn overlay
+  [3] = ACTION_LAYER_TOGGLE(2), // toggle more modifiers
+  [4] = ACTION_LAYER_TOGGLE(4), // toggle wasd
+  [5] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT),
+  [6] = ACTION_FUNCTION_TAP(SPACE_FN),
+
+  [11] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+  [12] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+  [13] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+  [14] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+  [15] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+  [16] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+  [17] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+  [18] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+  [19] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+  [20] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+  [21] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+  [22] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+  [23] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+  [24] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+  [25] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+  [26] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+};

From 05795cb0034e885bec37f782cfc6bddcae262637 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Wed, 26 Nov 2014 11:25:45 +0900
Subject: [PATCH 39/95] Compensate timer during prower down

---
 common/avr/suspend.c           | 27 ++++++++++++++++-----------
 common/suspend.h               |  2 +-
 keyboard/hhkb_rn42/MEMO.txt    |  7 +++++++
 keyboard/hhkb_rn42/matrix.c    |  2 +-
 keyboard/hhkb_rn42/rn42/main.c |  2 +-
 protocol/lufa/lufa.c           |  2 +-
 6 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/common/avr/suspend.c b/common/avr/suspend.c
index 66a579fd78..80243f02bc 100644
--- a/common/avr/suspend.c
+++ b/common/avr/suspend.c
@@ -7,6 +7,7 @@
 #include "backlight.h"
 #include "suspend_avr.h"
 #include "suspend.h"
+#include "timer.h"
 #ifdef PROTOCOL_LUFA
 #include "lufa.h"
 #endif
@@ -52,11 +53,13 @@ void suspend_idle(uint8_t time)
  *          WDTO_4S
  *          WDTO_8S
  */
-void suspend_power_down(uint8_t wdto)
+static uint8_t wdt_timeout = 0;
+static void power_down(uint8_t wdto)
 {
 #ifdef PROTOCOL_LUFA
     if (USB_DeviceState == DEVICE_STATE_Configured) return;
 #endif
+    wdt_timeout = wdto;
 
     // Watchdog Interrupt Mode
     wdt_intr_enable(wdto);
@@ -67,7 +70,6 @@ void suspend_power_down(uint8_t wdto)
     // - prescale clock
     // - BOD disable
     // - Power Reduction Register PRR
-
     set_sleep_mode(SLEEP_MODE_PWR_DOWN);
     sleep_enable();
     sei();
@@ -78,6 +80,11 @@ void suspend_power_down(uint8_t wdto)
     wdt_disable();
 }
 
+void suspend_power_down(void)
+{
+    power_down(WDTO_15MS);
+}
+
 bool suspend_wakeup_condition(void)
 {
     matrix_power_up();
@@ -103,15 +110,13 @@ void suspend_wakeup_init(void)
 /* watchdog timeout */
 ISR(WDT_vect)
 {
-    /* wakeup from MCU sleep mode */
-/*
-    // blink LED
-    static uint8_t led_state = 0;
-    static uint8_t led_count = 0;
-    led_count++;
-    if ((led_count & 0x07) == 0) {
-        led_set((led_state ^= (1<<USB_LED_CAPS_LOCK)));
+    // compensate timer for sleep
+    switch (wdt_timeout) {
+        case WDTO_15MS:
+            timer_count += 15 + 2;  // WDTO_15MS + 2(from observation)
+            break;
+        default:
+            ;
     }
-*/
 }
 #endif
diff --git a/common/suspend.h b/common/suspend.h
index f339c670ac..80617a8244 100644
--- a/common/suspend.h
+++ b/common/suspend.h
@@ -6,7 +6,7 @@
 
 
 void suspend_idle(uint8_t timeout);
-void suspend_power_down(uint8_t timeout);
+void suspend_power_down(void);
 bool suspend_wakeup_condition(void);
 void suspend_wakeup_init(void);
 
diff --git a/keyboard/hhkb_rn42/MEMO.txt b/keyboard/hhkb_rn42/MEMO.txt
index 337dad6039..062ee3399a 100644
--- a/keyboard/hhkb_rn42/MEMO.txt
+++ b/keyboard/hhkb_rn42/MEMO.txt
@@ -9,10 +9,15 @@ Bug:
     - Do not power-down during USB connection is active - DONE 11/11
         (USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection
         matrix_power_down() matrix.c - 11/23
+- timer is slow while power down - DONE 11/26
+    - time out interrupt is lost while power down?
+    - interrupt of watchdog timer compensates timer counter(avr/suspend.c)
 
 Todo:
 
 Design:
+- suspend.h - DONE 11/26
+    - remove argument from suspend_power_down() for backward compatitibility
 - remove MCU dependent power saving code from core/keyboard
     - it should be located in project matrix.c - DONE 11/23
 - HHKB matrix.c needs matrix_prev?
@@ -47,6 +52,8 @@ Power saving:
 - During USB suspend change clock source to internal RC from external Xtal(6.8)
 - FRZCLK: you can freeze clock for power saving. still WAKEUPI and VBUSTI interrupts are available while freezing.(21.7.3)
 - Suspend: Clear Suspend Bit, Freeze clock, disable PLL, MCU sleep(21.13)
+- Voltage reference(8.1.1)
+    - to reduce power consumption while power down mode
 
 Improving:
 - BT LED; connecting, linked, sleeping, deep sleeping
diff --git a/keyboard/hhkb_rn42/matrix.c b/keyboard/hhkb_rn42/matrix.c
index c6c444ff52..513a271e4e 100644
--- a/keyboard/hhkb_rn42/matrix.c
+++ b/keyboard/hhkb_rn42/matrix.c
@@ -186,6 +186,6 @@ void matrix_power_down(void) {
     if (USB_DeviceState == DEVICE_STATE_Configured) return;
     if (timer_elapsed32(matrix_last_modified) <= MATRIX_POWER_SAVE) return;
     KEY_POWER_OFF();
-    suspend_power_down(WDTO_15MS);
+    suspend_power_down();
     matrix_power = false;
 }
diff --git a/keyboard/hhkb_rn42/rn42/main.c b/keyboard/hhkb_rn42/rn42/main.c
index 43d887067d..a3a37c0747 100644
--- a/keyboard/hhkb_rn42/rn42/main.c
+++ b/keyboard/hhkb_rn42/rn42/main.c
@@ -85,7 +85,7 @@ int main(void)
     print("Keyboard start.\n");
     while (1) {
         while (USB_DeviceState == DEVICE_STATE_Suspended) {
-            suspend_power_down(WDTO_120MS);
+            suspend_power_down();
             if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
                     USB_Device_SendRemoteWakeup();
             }
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index 6802f3b631..ee15b7f455 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -587,7 +587,7 @@ int main(void)
     print("Keyboard start.\n");
     while (1) {
         while (USB_DeviceState == DEVICE_STATE_Suspended) {
-            suspend_power_down(WDTO_120MS);
+            suspend_power_down();
             if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
                     USB_Device_SendRemoteWakeup();
             }

From 9179246a1d69024449829218aa7fb967d8ccc3f5 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Wed, 26 Nov 2014 11:42:53 +0900
Subject: [PATCH 40/95] Fix USB plug-in while BT mode falls to be enumerated

---
 keyboard/hhkb_rn42/matrix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/keyboard/hhkb_rn42/matrix.c b/keyboard/hhkb_rn42/matrix.c
index 513a271e4e..22becd1050 100644
--- a/keyboard/hhkb_rn42/matrix.c
+++ b/keyboard/hhkb_rn42/matrix.c
@@ -183,7 +183,7 @@ void matrix_power_up(void) {
 void matrix_power_down(void) {
     if (!matrix_power) return;
     // doesn't power save while USB connection is active
-    if (USB_DeviceState == DEVICE_STATE_Configured) return;
+    if (USB_DeviceState != DEVICE_STATE_Unattached) return;
     if (timer_elapsed32(matrix_last_modified) <= MATRIX_POWER_SAVE) return;
     KEY_POWER_OFF();
     suspend_power_down();

From 20caf673d8ba7fb7675e2559bfebad6ddb9d6fd0 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Sat, 29 Nov 2014 20:47:15 +0900
Subject: [PATCH 41/95] Fix lufa sendchar() infinite wait loop

- FrameNumber is not updated when adapter powered
- can be blocked in sendchar() when pluged into AC adapter
---
 keyboard/hhkb_rn42/rn42/main.c |  3 ++-
 protocol/lufa/lufa.c           | 36 +++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/keyboard/hhkb_rn42/rn42/main.c b/keyboard/hhkb_rn42/rn42/main.c
index a3a37c0747..42b09d8c8c 100644
--- a/keyboard/hhkb_rn42/rn42/main.c
+++ b/keyboard/hhkb_rn42/rn42/main.c
@@ -17,8 +17,8 @@
 
 static int8_t sendchar_func(uint8_t c)
 {
-    sendchar(c);    // LUFA
     xmit(c);        // SUART
+    sendchar(c);    // LUFA
     return 0;
 }
 
@@ -85,6 +85,7 @@ int main(void)
     print("Keyboard start.\n");
     while (1) {
         while (USB_DeviceState == DEVICE_STATE_Suspended) {
+            print("[s]");
             suspend_power_down();
             if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
                     USB_Device_SendRemoteWakeup();
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index ee15b7f455..3d6b3ea00c 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -148,6 +148,7 @@ static void Console_Task(void)
 */
 void EVENT_USB_Device_Connect(void)
 {
+    print("[C]");
     /* For battery powered device */
     if (!USB_IsInitialized) {
         USB_Init();
@@ -157,6 +158,7 @@ void EVENT_USB_Device_Connect(void)
 
 void EVENT_USB_Device_Disconnect(void)
 {
+    print("[D]");
     /* For battery powered device */
 /* TODO: This doesn't work. After several plug in/outs can not be enumerated. 
     if (USB_IsInitialized) {
@@ -169,10 +171,12 @@ void EVENT_USB_Device_Disconnect(void)
 
 void EVENT_USB_Device_Reset(void)
 {
+    print("[R]");
 }
 
 void EVENT_USB_Device_Suspend()
 {
+    print("[S]");
 #ifdef SLEEP_LED_ENABLE
     sleep_led_enable();
 #endif
@@ -180,6 +184,7 @@ void EVENT_USB_Device_Suspend()
 
 void EVENT_USB_Device_WakeUp()
 {
+    print("[W]");
     suspend_wakeup_init();
 
 #ifdef SLEEP_LED_ENABLE
@@ -489,37 +494,28 @@ int8_t sendchar(uint8_t c)
     uint8_t ep = Endpoint_GetCurrentEndpoint();
     Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM);
     if (!Endpoint_IsEnabled() || !Endpoint_IsConfigured()) {
-        Endpoint_SelectEndpoint(ep);
-        return -1;
+        goto ERROR_EXIT;
     }
 
     if (timeouted && !Endpoint_IsReadWriteAllowed()) {
-        Endpoint_SelectEndpoint(ep);
-        return - 1;
+        goto ERROR_EXIT;
     }
 
     timeouted = false;
 
     uint8_t timeout = SEND_TIMEOUT;
-    uint16_t prevFN = USB_Device_GetFrameNumber();
     while (!Endpoint_IsReadWriteAllowed()) {
-        switch (USB_DeviceState) {
-        case DEVICE_STATE_Unattached:
-        case DEVICE_STATE_Suspended:
-            return -1;
+        if (USB_DeviceState != DEVICE_STATE_Configured) {
+            goto ERROR_EXIT;
         }
         if (Endpoint_IsStalled()) {
-            Endpoint_SelectEndpoint(ep);
-            return -1;
+            goto ERROR_EXIT;
         }
-        if (prevFN != USB_Device_GetFrameNumber()) {
-            if (!(timeout--)) {
-                timeouted = true;
-                Endpoint_SelectEndpoint(ep);
-                return -1;
-            }
-            prevFN = USB_Device_GetFrameNumber();
+        if (!(timeout--)) {
+            timeouted = true;
+            goto ERROR_EXIT;
         }
+        _delay_ms(1);
     }
 
     Endpoint_Write_8(c);
@@ -530,6 +526,9 @@ int8_t sendchar(uint8_t c)
 
     Endpoint_SelectEndpoint(ep);
     return 0;
+ERROR_EXIT:
+    Endpoint_SelectEndpoint(ep);
+    return -1;
 }
 #else
 int8_t sendchar(uint8_t c)
@@ -587,6 +586,7 @@ int main(void)
     print("Keyboard start.\n");
     while (1) {
         while (USB_DeviceState == DEVICE_STATE_Suspended) {
+            print("[s]");
             suspend_power_down();
             if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
                     USB_Device_SendRemoteWakeup();

From 570bcb2ed112b3435a09b974c20138f13de6aaaa Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Sat, 29 Nov 2014 21:12:47 +0900
Subject: [PATCH 42/95] Add LUFA device state to command info

---
 keyboard/hhkb_rn42/rn42/rn42_task.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.c b/keyboard/hhkb_rn42/rn42/rn42_task.c
index c3359ed506..6686268624 100644
--- a/keyboard/hhkb_rn42/rn42/rn42_task.c
+++ b/keyboard/hhkb_rn42/rn42/rn42_task.c
@@ -197,6 +197,8 @@ bool command_extra(uint8_t code)
             xprintf("rn42_linked(): %X\n", rn42_linked());
             xprintf("rn42_rts(): %X\n", rn42_rts());
             xprintf("config_mode: %X\n", config_mode);
+            xprintf("USB_DeviceState: %X\n", USB_DeviceState);
+            xprintf("USB_Device_RemoteWakeupEnabled: %X\n", USB_Device_RemoteWakeupEnabled);
             xprintf("VBUS: %X\n", USBSTA&(1<<VBUS));
             xprintf("battery_charging: %X\n", battery_charging());
             xprintf("battery_status: %X\n", battery_status());

From de29f986a73860abfa930cd1b91cec60b02ee7a7 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Sat, 29 Nov 2014 21:14:00 +0900
Subject: [PATCH 43/95] Update MEMO

---
 keyboard/hhkb_rn42/MEMO.txt | 58 +++++++++++++++++++++++++++++++++++--
 1 file changed, 56 insertions(+), 2 deletions(-)

diff --git a/keyboard/hhkb_rn42/MEMO.txt b/keyboard/hhkb_rn42/MEMO.txt
index 062ee3399a..e623c00133 100644
--- a/keyboard/hhkb_rn42/MEMO.txt
+++ b/keyboard/hhkb_rn42/MEMO.txt
@@ -9,33 +9,84 @@ Bug:
     - Do not power-down during USB connection is active - DONE 11/11
         (USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection
         matrix_power_down() matrix.c - 11/23
+
+- When given power only from wall wart adapter
+    - it sleeps. it should not sleep
+    - Configured state without USB connection?
+
 - timer is slow while power down - DONE 11/26
     - time out interrupt is lost while power down?
     - interrupt of watchdog timer compensates timer counter(avr/suspend.c)
 
+- USB plug-in while BT failes
+    - it ends in suspend state
+    - maybe, not responsive to host enumeration process due to power-down.
+    - matrix_power_down() only when state is unattached - 11/26
+        - need to observe a while
+- repeated CHARGING/FULL_CHARGED
+    - In LTC sharp pulses are observed.
+    - MCP has no pulse but still has a problem.
+    - needs more wait before read pin state?
+- wrongly suspended when powered from adapter without USB connection
+    - suspend event may occur when plug into adapter
+    - and never wake until conected to real USB line
+    - without debug print via USB no problem; CSW(wake just after suspend as real USB line)
+    - seems like USB print causes this problem after suspended
+
 Todo:
+- sendchar() in lufa.c block loop   - 11/29
+    - block loop when powered with AC adapter
+    - FrameNumber is not updated when adapter powered
+- sendchar() in lufa.c no buffer
+    - no buffering. character lost can be caused.
 
 Design:
 - suspend.h - DONE 11/26
     - remove argument from suspend_power_down() for backward compatitibility
-- remove MCU dependent power saving code from core/keyboard
-    - it should be located in project matrix.c - DONE 11/23
+- remove MCU dependent power saving code from core/keyboard - DONE 11/23
+    - it should be located in project matrix.c
 - HHKB matrix.c needs matrix_prev?
     - is_modified() is obsolete now. really needs?
+- ADC: removing AREF capacitor C10
+    - seems to be better while usb powered
+    - still bad while battery powered
+    http://electronics.stackexchange.com/questions/105849/avcc-and-capacitor-using-adc
+- ADC: smaller resistors for voltage dividor
+    - 1K + 1K: not improved. - 11/27
 
 
 LUFA:
 USB connection check: state of USB deivce
 - USB_DeviceState:
     USB_Deivce_State_t { Unattached, Powered, Default, Addressed, Configured*, Suspended* }
+    Unattached: unpluged
+    Powered:    pluged with power adapter
+    Default:    enumerate process bigin
+    Addressed:  addressed
+    Configured: enumerated
+    Suspended:  suspended
+
 - USB_IsInitialized: state of LUFA core setup
     becomes true in USB_Init()  USBController_AVR8.c
     becomes false in USB_Disable()  USBController_AVR8.c
 - USB_VBUS_GetStatus(): state of VBUS(power/connection)
 - USB_Disable() detaches, disables all interrupts, controller, PLL, regulater.
 
+- When connect to power adapter
+    - event happened: CW or CSW or C or DDC
+    - USB state: not configured
+
+- USB evnets
+    - USB connect: CSWRWRW
+    - USB connect but fail to enumeration: CWRWRWRWS
+    - USB disconnect: D
+    - Power adapter connect: CW, CSW, C
+    - Power adapter disconnect: D
+
 
 Power saving:
+- matrix power saving
+    - power saving while externally powered and not while unpluged
 - confirm suspend mode lufa.c: matrix_power_*, suspend_wakeup_condition
 - 8MHz clock
 - When not connected in a few minutes get into deep sleep to save battery life
@@ -63,6 +114,9 @@ Improving:
 - ADC resolution
     AVR120
     AVR32138
+    - Enhancing ADC resolution by oversampling 
+        AVR121  http://www.atmel.com/images/doc8003.pdf
+
 
 Testing:
 - Factroy reset doesn't work; need to **test again** 10K pull-up is too high?

From 825be9d121a9c698bf60bbdc384f2eeaf66f60d0 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Tue, 2 Dec 2014 22:47:59 +0900
Subject: [PATCH 44/95] Disable input buffer for ADC

---
 keyboard/hhkb_rn42/rn42/battery.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/keyboard/hhkb_rn42/rn42/battery.c b/keyboard/hhkb_rn42/rn42/battery.c
index 0320e1baf1..720d63bebb 100644
--- a/keyboard/hhkb_rn42/rn42/battery.c
+++ b/keyboard/hhkb_rn42/rn42/battery.c
@@ -21,6 +21,10 @@ void battery_init(void)
     ADMUX = (1<<REFS1) | (1<<REFS0);
     ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
     ADCSRA |= (1<<ADEN);
+    // digital input buffer disable(24.9.5)
+    DIDR0 = (1<<ADC0D) | (1<<ADC4D) | (1<<ADC5D) | (1<<ADC7D);
+    DIDR1 = (1<<AIN0D);
+    DIDR2 = (1<<ADC8D) | (1<<ADC9D) | (1<<ADC11D) | (1<<ADC12D) | (1<<ADC13D);
 
     // ADC disable voltate divider(PF4)
     DDRF  |=  (1<<4);

From 25aee431bd83b46d694293c85a939d476943a5aa Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Wed, 3 Dec 2014 02:08:27 +0900
Subject: [PATCH 45/95] Clean ADC code of battery_voltage()

---
 keyboard/hhkb_rn42/rn42/battery.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/keyboard/hhkb_rn42/rn42/battery.c b/keyboard/hhkb_rn42/rn42/battery.c
index 720d63bebb..3ecde52234 100644
--- a/keyboard/hhkb_rn42/rn42/battery.c
+++ b/keyboard/hhkb_rn42/rn42/battery.c
@@ -20,7 +20,6 @@ void battery_init(void)
     // Ref:2.56V band-gap, Input:ADC0(PF0), Prescale:128(16MHz/128=125KHz)
     ADMUX = (1<<REFS1) | (1<<REFS0);
     ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
-    ADCSRA |= (1<<ADEN);
     // digital input buffer disable(24.9.5)
     DIDR0 = (1<<ADC0D) | (1<<ADC4D) | (1<<ADC5D) | (1<<ADC7D);
     DIDR1 = (1<<AIN0D);
@@ -92,23 +91,13 @@ uint16_t battery_voltage(void)
     PORTF |=  (1<<4);
 
     volatile uint16_t bat;
-    //ADCSRA |= (1<<ADEN);
-
-    // discard first result
-    ADCSRA |= (1<<ADSC);
-    while (ADCSRA & (1<<ADSC)) ;
-    bat = ADC;
-
-    // discard second result
-    ADCSRA |= (1<<ADSC);
-    while (ADCSRA & (1<<ADSC)) ;
-    bat = ADC;
+    ADCSRA |= (1<<ADEN);
 
     ADCSRA |= (1<<ADSC);
     while (ADCSRA & (1<<ADSC)) ;
     bat = ADC;
 
-    //ADCSRA &= ~(1<<ADEN);
+    ADCSRA &= ~(1<<ADEN);
 
     // ADC disable voltate divider(PF4)
     DDRF  |=  (1<<4);

From 2d7973fc3fa27b74379ba08392e2487e208b770a Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Wed, 3 Dec 2014 02:17:54 +0900
Subject: [PATCH 46/95] Fix: enable digital input for PF5

---
 keyboard/hhkb_rn42/rn42/battery.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/keyboard/hhkb_rn42/rn42/battery.c b/keyboard/hhkb_rn42/rn42/battery.c
index 3ecde52234..34aa18446c 100644
--- a/keyboard/hhkb_rn42/rn42/battery.c
+++ b/keyboard/hhkb_rn42/rn42/battery.c
@@ -21,7 +21,7 @@ void battery_init(void)
     ADMUX = (1<<REFS1) | (1<<REFS0);
     ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
     // digital input buffer disable(24.9.5)
-    DIDR0 = (1<<ADC0D) | (1<<ADC4D) | (1<<ADC5D) | (1<<ADC7D);
+    DIDR0 = (1<<ADC0D) | (1<<ADC4D) | (1<<ADC7D);
     DIDR1 = (1<<AIN0D);
     DIDR2 = (1<<ADC8D) | (1<<ADC9D) | (1<<ADC11D) | (1<<ADC12D) | (1<<ADC13D);
 

From 86f82dd02db577cd658ca4284cae15e9664db0f2 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Wed, 3 Dec 2014 14:22:10 +0900
Subject: [PATCH 47/95] Add wait for charging capacitance of ADC S/H

---
 keyboard/hhkb_rn42/rn42/battery.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/keyboard/hhkb_rn42/rn42/battery.c b/keyboard/hhkb_rn42/rn42/battery.c
index 34aa18446c..7e868c9646 100644
--- a/keyboard/hhkb_rn42/rn42/battery.c
+++ b/keyboard/hhkb_rn42/rn42/battery.c
@@ -92,6 +92,7 @@ uint16_t battery_voltage(void)
 
     volatile uint16_t bat;
     ADCSRA |= (1<<ADEN);
+    _delay_ms(1);   // wait for charging S/H capacitance
 
     ADCSRA |= (1<<ADSC);
     while (ADCSRA & (1<<ADSC)) ;

From ebe437325872045e0b99469f83cb9e877e98112c Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Wed, 3 Dec 2014 15:50:02 +0900
Subject: [PATCH 48/95] Fix power saving while USB suspended

- doesn't pwoer save while Bluetooth turns on
---
 keyboard/hhkb_rn42/hhkb_avr.h  |  4 +++-
 keyboard/hhkb_rn42/matrix.c    | 21 ++++++++++-----------
 keyboard/hhkb_rn42/rn42/main.c | 14 +++++++++++---
 protocol/lufa/lufa.c           |  3 +++
 4 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/keyboard/hhkb_rn42/hhkb_avr.h b/keyboard/hhkb_rn42/hhkb_avr.h
index f007d7667a..0321977d11 100644
--- a/keyboard/hhkb_rn42/hhkb_avr.h
+++ b/keyboard/hhkb_rn42/hhkb_avr.h
@@ -53,9 +53,11 @@ static inline void KEY_POWER_OFF(void) {
     DDRB = 0x00; PORTB = 0xFF;          // change pins input with pull-up
     DDRD |= (1<<4); PORTD &= ~(1<<4);   // MOS FET switch off
 }
+static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
 #else
 static inline void KEY_POWER_ON(void) {}
 static inline void KEY_POWER_OFF(void) {}
+static inline bool KEY_POWER_STATE(void) { return true; }
 #endif
 static inline void KEY_INIT(void)
 {
@@ -73,7 +75,7 @@ static inline void KEY_INIT(void)
     KEY_UNABLE();
     KEY_PREV_OFF();
 
-    KEY_POWER_ON();
+    KEY_POWER_OFF();
 }
 static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
 {
diff --git a/keyboard/hhkb_rn42/matrix.c b/keyboard/hhkb_rn42/matrix.c
index 22becd1050..fb96997944 100644
--- a/keyboard/hhkb_rn42/matrix.c
+++ b/keyboard/hhkb_rn42/matrix.c
@@ -35,7 +35,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // matrix power saving
 #define MATRIX_POWER_SAVE       10000
 static uint32_t matrix_last_modified = 0;
-static bool matrix_power = true;
 
 // matrix state buffer(1:on, 0:off)
 static matrix_row_t *matrix;
@@ -80,7 +79,8 @@ uint8_t matrix_scan(void)
     matrix_prev = matrix;
     matrix = tmp;
 
-    matrix_power_up();
+    // power on
+    if (!KEY_POWER_STATE()) KEY_POWER_ON();
     for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
         for (uint8_t col = 0; col < MATRIX_COLS; col++) {
             KEY_SELECT(row, col);
@@ -136,7 +136,14 @@ uint8_t matrix_scan(void)
         }
         if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32();
     }
-    matrix_power_down();
+    // power off
+    if (KEY_POWER_STATE() &&
+            (USB_DeviceState == DEVICE_STATE_Suspended ||
+             USB_DeviceState == DEVICE_STATE_Unattached ) &&
+            timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) {
+        KEY_POWER_OFF();
+        suspend_power_down();
+    }
     return 1;
 }
 
@@ -176,16 +183,8 @@ void matrix_print(void)
 }
 
 void matrix_power_up(void) {
-    if (matrix_power) return;
     KEY_POWER_ON();
-    matrix_power = true;
 }
 void matrix_power_down(void) {
-    if (!matrix_power) return;
-    // doesn't power save while USB connection is active
-    if (USB_DeviceState != DEVICE_STATE_Unattached) return;
-    if (timer_elapsed32(matrix_last_modified) <= MATRIX_POWER_SAVE) return;
     KEY_POWER_OFF();
-    suspend_power_down();
-    matrix_power = false;
 }
diff --git a/keyboard/hhkb_rn42/rn42/main.c b/keyboard/hhkb_rn42/rn42/main.c
index 42b09d8c8c..83d9950388 100644
--- a/keyboard/hhkb_rn42/rn42/main.c
+++ b/keyboard/hhkb_rn42/rn42/main.c
@@ -63,7 +63,7 @@ int main(void)
         USB_USBTask();
 #endif
     }
-    print("USB configured.\n");
+    print("\nUSB init\n");
 
     rn42_init();
     rn42_task_init();
@@ -82,10 +82,18 @@ int main(void)
     sleep_led_init();
 #endif
 
-    print("Keyboard start.\n");
+    print("Keyboard start\n");
     while (1) {
-        while (USB_DeviceState == DEVICE_STATE_Suspended) {
+        while (rn42_rts() && // RN42 is off
+                USB_DeviceState == DEVICE_STATE_Suspended) {
             print("[s]");
+            matrix_power_down();
+            suspend_power_down();
+            suspend_power_down();
+            suspend_power_down();
+            suspend_power_down();
+            suspend_power_down();
+            suspend_power_down();
             suspend_power_down();
             if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
                     USB_Device_SendRemoteWakeup();
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index 3d6b3ea00c..cdfc7bc6ad 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -151,6 +151,7 @@ void EVENT_USB_Device_Connect(void)
     print("[C]");
     /* For battery powered device */
     if (!USB_IsInitialized) {
+        USB_Disable();
         USB_Init();
         USB_Device_EnableSOFEvents();
     }
@@ -160,6 +161,7 @@ void EVENT_USB_Device_Disconnect(void)
 {
     print("[D]");
     /* For battery powered device */
+    USB_IsInitialized = false;
 /* TODO: This doesn't work. After several plug in/outs can not be enumerated. 
     if (USB_IsInitialized) {
         USB_Disable();  // Disable all interrupts
@@ -177,6 +179,7 @@ void EVENT_USB_Device_Reset(void)
 void EVENT_USB_Device_Suspend()
 {
     print("[S]");
+    matrix_power_down();
 #ifdef SLEEP_LED_ENABLE
     sleep_led_enable();
 #endif

From 160e02d06a11682d994da905adb1345bc1dde249 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Mon, 8 Dec 2014 12:22:33 +0900
Subject: [PATCH 49/95] Change RN42 state display

---
 keyboard/hhkb_rn42/rn42/rn42_task.c | 42 ++++++++++++++++-------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.c b/keyboard/hhkb_rn42/rn42/rn42_task.c
index 6686268624..1ad38d3722 100644
--- a/keyboard/hhkb_rn42/rn42/rn42_task.c
+++ b/keyboard/hhkb_rn42/rn42/rn42_task.c
@@ -96,18 +96,6 @@ void rn42_task(void)
             battery_led(LED_CHARGER);
         }
 
-        static uint8_t prev_status = UNKNOWN;
-        if (bs != prev_status) {
-            prev_status = bs;
-            switch (bs) {
-                case FULL_CHARGED:  xprintf("FULL_CHARGED\n"); break;
-                case CHARGING:      xprintf("CHARGING\n"); break;
-                case DISCHARGING:   xprintf("DISCHARGING\n"); break;
-                case LOW_VOLTAGE:   xprintf("LOW_VOLTAGE\n"); break;
-                default:            xprintf("UNKNOWN STATUS\n"); break;
-            };
-        }
-
         /* every minute */
         uint32_t t = timer_read32()/1000;
         if (t%60 == 0) {
@@ -193,15 +181,33 @@ bool command_extra(uint8_t code)
             print("\n----- RN-42 info -----\n");
             xprintf("protocol: %s\n", (host_get_driver() == &rn42_driver) ? "RN-42" : "LUFA");
             xprintf("force_usb: %X\n", force_usb);
+            xprintf("rn42: %s\n", rn42_rts() ? "OFF" : (rn42_linked() ? "CONN" : "ON"));
             xprintf("rn42_autoconnecting(): %X\n", rn42_autoconnecting());
-            xprintf("rn42_linked(): %X\n", rn42_linked());
-            xprintf("rn42_rts(): %X\n", rn42_rts());
             xprintf("config_mode: %X\n", config_mode);
-            xprintf("USB_DeviceState: %X\n", USB_DeviceState);
-            xprintf("USB_Device_RemoteWakeupEnabled: %X\n", USB_Device_RemoteWakeupEnabled);
+            xprintf("USB State: %s\n",
+                    (USB_DeviceState == DEVICE_STATE_Unattached) ? "Unattached" :
+                    (USB_DeviceState == DEVICE_STATE_Powered) ? "Powered" :
+                    (USB_DeviceState == DEVICE_STATE_Default) ? "Default" :
+                    (USB_DeviceState == DEVICE_STATE_Addressed) ? "Addressed" :
+                    (USB_DeviceState == DEVICE_STATE_Configured) ? "Configured" :
+                    (USB_DeviceState == DEVICE_STATE_Suspended) ? "Suspended" : "?");
+            xprintf("battery: ");
+            switch (battery_status()) {
+                case FULL_CHARGED:  xprintf("FULL"); break;
+                case CHARGING:      xprintf("CHARG"); break;
+                case DISCHARGING:   xprintf("DISCHG"); break;
+                case LOW_VOLTAGE:   xprintf("LOW"); break;
+                default:            xprintf("?"); break;
+            };
+            xprintf("\n");
+            xprintf("RemoteWakeupEnabled: %X\n", USB_Device_RemoteWakeupEnabled);
             xprintf("VBUS: %X\n", USBSTA&(1<<VBUS));
-            xprintf("battery_charging: %X\n", battery_charging());
-            xprintf("battery_status: %X\n", battery_status());
+            t = timer_read32()/1000;
+            uint8_t d = t/3600/24;
+            uint8_t h = t/3600;
+            uint8_t m = t%3600/60;
+            uint8_t s = t%60;
+            xprintf("uptime: %02ud%02u:%02u:%02u\n", d, h, m, s);
             return true;
         case KC_B:
             // battery monitor

From 884c2ab0f20e62ebd01ca0fd634f7f60558e3088 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Fri, 12 Dec 2014 08:25:16 +0900
Subject: [PATCH 50/95] Update doc

---
 keyboard/hhkb_rn42/MEMO.txt      | 548 ++++++-------------------------
 keyboard/hhkb_rn42/PowerSave.txt |  13 +
 2 files changed, 119 insertions(+), 442 deletions(-)

diff --git a/keyboard/hhkb_rn42/MEMO.txt b/keyboard/hhkb_rn42/MEMO.txt
index e623c00133..f2aaa7c046 100644
--- a/keyboard/hhkb_rn42/MEMO.txt
+++ b/keyboard/hhkb_rn42/MEMO.txt
@@ -4,7 +4,7 @@ Roving RN-42
 Bug:
 - with Nexus5 keyboard and mouse are very laggy.
 
-- lose USB connection during power-down mode
+- lose USB connection during power-down mode - DONE
     - USB initialize code in main() causes this - WRONG
     - Do not power-down during USB connection is active - DONE 11/11
         (USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection
@@ -18,7 +18,7 @@ Bug:
     - time out interrupt is lost while power down?
     - interrupt of watchdog timer compensates timer counter(avr/suspend.c)
 
-- USB plug-in while BT failes
+- USB plug-in fails while BT
     - it ends in suspend state
     - maybe, not responsive to host enumeration process due to power-down.
     - matrix_power_down() only when state is unattached - 11/26
@@ -26,19 +26,49 @@ Bug:
 - repeated CHARGING/FULL_CHARGED
     - In LTC sharp pulses are observed.
     - MCP has no pulse but still has a problem.
-    - needs more wait before read pin state?
-- wrongly suspended when powered from adapter without USB connection
+    - needs more wait before read pin state? - NO
+- wrongly suspended when powered from adapter without USB connection - DONE
     - suspend event may occur when plug into adapter
     - and never wake until conected to real USB line
     - without debug print via USB no problem; CSW(wake just after suspend as real USB line)
     - seems like USB print causes this problem after suspended
 
+- Factory Reset PIO4 doesn't work
+    - the reason is unclear - 12/08 NOT LOOK INTO ANY MORE
+    - WORKAROUND: use serial pins(3.3V, GND, RX and TX)
+        - SF,1 and R,1 to set factory defalult
+    
+
 Todo:
-- sendchar() in lufa.c block loop   - 11/29
-    - block loop when powered with AC adapter
-    - FrameNumber is not updated when adapter powered
+- LED cover and switch knob and new Slide Switch
+- RN42 auto configuration
+    - configure the module as HID device every time powering up
+    - this'll reduce work load of assembly
+
+- move rn42 to protocol directory when it becomes reusable stack
+
 - sendchar() in lufa.c no buffer
     - no buffering. character lost can be caused.
+- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
+
+- switch BT host connections
+- BT operations
+    - disconnect
+    - new connection
+    - switch next connection
+    - remove connection
+
+- sendchar() in lufa.c block loop   - DONE 11/29
+    - block loop when powered with AC adapter
+    - FrameNumber is not updated when adapter powered
+
+Improving:
+- ADC resolution
+    AVR120
+    AVR32138
+    - Enhancing ADC resolution by oversampling
+        AVR121  http://www.atmel.com/images/doc8003.pdf
+    - disable digital input buffer DIDR(7.8.6)
 
 Design:
 - suspend.h - DONE 11/26
@@ -85,6 +115,24 @@ USB connection check: state of USB deivce
 
 
 Power saving:
+- Pro2 current consumption
+    - active: 138.2mA(no device on Hub)
+    - suspended: 30.9mA(WakeUp enabled DIPSW6)
+    - suspended: 0mA->46.0mA(WakeUp disabled DIPSW6)
+- Pro current consumption
+    - active: 54.0mA
+    - suspended: 40.5mA(WakeUp enabled DIPSW6)
+    - suspended: 0.3mA(WakeUp disabled DIPSW6)
+
+- RN42 3.3V
+    - disconnected(Idle): 5mA (config mode)
+    - connected(Active):
+        SW,0000:  23-26mA
+        SW,0010:  27-29mA worse than 0000 for unknown reason
+        SW,0020:  17-19mA mouse NG
+        SW,0030:  13-16mA laggy mouse NG
+        SW,0050:  10-13mA laggy mouse NG
+
 - matrix power saving
     - power saving while externally powered and not while unpluged
 - confirm suspend mode lufa.c: matrix_power_*, suspend_wakeup_condition
@@ -105,136 +153,12 @@ Power saving:
 - Suspend: Clear Suspend Bit, Freeze clock, disable PLL, MCU sleep(21.13)
 - Voltage reference(8.1.1)
     - to reduce power consumption while power down mode
-
-Improving:
-- BT LED; connecting, linked, sleeping, deep sleeping
-- Battry LED; blink(using timer?)
-- move rn42 to protocol directory when it becomes reusable stack
-- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
-- ADC resolution
-    AVR120
-    AVR32138
-    - Enhancing ADC resolution by oversampling 
-        AVR121  http://www.atmel.com/images/doc8003.pdf
-
-
-Testing:
-- Factroy reset doesn't work; need to **test again** 10K pull-up is too high?
-- Lipo voltage ADC value is not stabilized
-- DCDC converter: squeaky inducter; try other inductors
-
-- Keymap layer bug: during space is pressed(mousekey) press Fn(HHKB) then release space before Fn, in result HHKB layer is locked(toggled) unintentionally.
-
-
-Done:
-- low battery alert(solid light) 09/04
-
-
-Power routing
--------------
-Current:
-(USB)   +---(Lipo)
- |      |     |
- |      |  +------+     DPDT
- |      |  |Switch/-----------------------+
- |      |  +------+                       |
- | +-------+  |                           |
- +-|Charger|  |                           |
- | +-------+  |     +---+                 |
- |            |     |MCU|                 |
- |            |     +---+                 |
- |            |      |                    |
- |            |      |                    |
-+--------------+  +-----+  +------+   +---/--+    +-----+
-|Power Selector|--|DC 5V|--|DC3.3V|---|Switch|----|RN-42|
-+--------------+  +-----+  +------+   +------+    +-----+
-USB Power is boosted unnecessarily, not harmful?
-
-Idea 1:
-(USB)   +---(Lipo)
- |      |     |
- |      |  +------+     DPDT
- |      |  |Switch/----------+
- |      |  +------+          |
- | +-------+  |              |
- +-|Charger|  |              |
- | +-------+  |     +---+    |
- |         +-----+  |MCU|    |
- |         |DC 5V|  +---+    |
- |         +-----+   |       |
- |            |      |       |
-+--------------+     |   +---/--+    +------+     +-----+
-|Power Selector|-----+---|Switch|----|DC3.3V|-----|RN-42|
-+--------------+         +------+    +------+     +-----+
-To enable BT when USB powered it still needs to turn siwtch on, Lipo consumes quinscent current at 5V converter in vain.(Not good)
-
-Idea 2:
-(USB)   +---(Lipo)
- |      |     |
- |      |  +------+
- |      |  |Switch|
- |      |  +------+
- | +-------+  |
- +-|Charger|  |
- | +-------+  |     +---+
- |         +-----+  |MCU|----+ Controlled by firmware
- |         |DC 5V|  +---+    | On: Lipo powered
- |         +-----+   |       | Off: USB powered
- |            |      |       |enable
-+--------------+     |   +------+     +-----+
-|Power Selector|-----+---|DC3.3V|-----|RN-42|
-+--------------+         +------+     +-----+
-MCU can controlled power of RN-42 without hardware switch.
-When USB powered and switch is on Lipo consumes quinscent current at 5V converter in vain.(Not good)
-
-Idea 3:
-(USB)   +---(Lipo)
- |      |     |
- |      |  +------+
- |      |  |Switch|SPST(or without)
- |      |  +------+
- | +-------+  |
- +-|Charger|  |
- | +-------+  |     +---+
- |            |     |MCU|----+ Controlled by firmware
- |            |     +---+    | On: Lipo powered
- |            |      |       | Off: USB powered
- |            |      |       |enable
-+--------------+ +-----+ +------+     +-----+
-|Power Selector|-|DC 5V|-|DC3.3V|-----|RN-42|
-+--------------+ +-----+ +------+     +-----+
-Switch is needed to save Lipo when not used because decent power saving is not available now. If firmware can turn off BT module completely and make MCU deep sleep the switch will be not even needed.
+- unset ADEN before sleep(24.7)
 
 
 
 
 
-DONE:
-- BT_INDICATOR LED turns on wrongly when touching line or pin.  -- pull-up enabled on PF6/GPIO2 08/30
-- Lipo charger configuration: fast charge time:  USB charger spec? -- used 2kohm
-- use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB
-- Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done
-- CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done
-- add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24
-- LINKED: add trace on PIO2 to PF6   07.24
-- Lipo voltage ADC sensing
-- Lipo charger MCP73831: needs capacitor 4.7uF *2
-- USB connection check - 07.01
-- BT on/off check: whether RX line is pulled up? - checking RTS 07.01
-- USB/BT switching  BT is on -> BT, BT is off -> USB - 07.01
-- Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V    07.01
-- Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough   07.01
-- Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04
-
-
-
-TROUBLE SHOOT
--------------
-07/16   After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive.
-        Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before.
-
-07/18   On Linux, had an USB related trouble; keyobard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
-
 
 
 Lipo
@@ -249,7 +173,7 @@ Protection spec:
 http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Prototyping/BatteryProtection.pdf
                                 min     typical max
     over-charge                 4.255   4.280   4.305
-    over-charge discover?       4.030   4.080   4.130        
+    over-charge discover?       4.030   4.080   4.130
     over-discharge              2.827   2.900   2.973
     over-discharge discover     3.022   3.100   3.178
 
@@ -260,325 +184,65 @@ ADC voltage monitor:    voltage divider 10K+10K(0.5)
     ------------------
     4.20    0x347(839)
     3.10    0x26b(619)
-    
 
 
 
-Configuration
+
+TROUBLE SHOOT
 -------------
-Ver 6.15 04/26/2013
-(c) Roving Networks
-***Settings***
-BTA=0006664B3AE3
-BTName=tmkBT-3AE3
-Baudrt(SW4)=115K
-Mode  =DTR
-Authen=2
-Bonded=0
-Rem=000000000000
-***ADVANCED Settings***
-SrvName= keyboard/mouse
-SrvClass=0000
-DevClass=0000
-InqWindw=0100
-PagWindw=0100
-CfgTimer=255
-StatuStr=NULL
-HidFlags=3c
-DTRtimer=8
-KeySwapr=0
-***OTHER Settings***
-Profile= HID
-CfgChar= $
-SniffEna=8010
-LowPower=0
-TX Power=0
-IOPorts= 0
-IOValues=0
-Sleeptmr=0
-DebugMod=0
-RoleSwch=0
+07/16   After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive.
+        Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before.
 
+07/18   On Linux, had an USB related trouble; keyobard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
 
-
-Serial connection
------------------
-Serial line:    115200bps, 8bit, 1-stopbit, non-parity, no flow control
-SSP:            115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
-
-To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD')
-To exit type '---'(you will see 'END') and '+' to get local echo.
-
-
-
-Setting command mode
---------------------
-S-,tmkBT            // Device name
-SS,keyboard/mouse   // service name
-SM,4                // Auto Connect DTR mode
-SW,8010             // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
-S~,6                // HID profile
-SH,003C             // HID register
-SY,0004             // Transmit power
+12/07   rn42_rts() read 1 every time. R12 broke in open mode(no coductive), idk why, too much heat with soldering? and PF1 pin was not soldered.
+        It resolved with resoldering PF1 and new resistor on R12.
 
 
 
 
-Other options:
-SC,0000         // COD: 000005C0    (see HID spec/Bluegiga doc)
-SD,05C0         //     bit 12-8         7           6           5-0
-                //         00101        1           1           0
-                //         peripheral   pointing    keybaord    joystick, gamepad, ...
-SM,6                // Pairing mode: auto connect
-SM,4                // Master mode: Connection can be controled with GPIO6
+Done:
+- low battery alert(solid light) 09/04
+- *** Rev.E BT test *** - DONE
+    - with MCP73832, new Schottky, tantalum caps - DONE 12/07
+        * MCP73832 doesn't leak from Vcc pin when unpluged and battery powered
+            34mV vs 2.07V(MCP73831) at Vcc pin
+            MCP73832 doesn't need revese protection diode D5
+        * PMEG2010ER is very low VF while reverse current/voltage is high
+            VF=0.96 vs 1.98(RB160M-30TR)with Fluke 175
+            Anode of D11 is 680mV vs 20mV(RB160M-30TR)
+            780mV is still low < 1.4V VBUS plugin detection(21.11)
+                this doesn't cause false VBUS detect
+                and 780mV on MCP73832 Vcc pin is also no problem.
+            D5 can be removed.
+    - ADC divider switching - DONE 12/07
+        * Drain and Source of Q4 Pch was reversed wrongly on Rev.E.
+
+    - reverse current from Lipo charger - DONE 12/07
+        * MCP73832 has no recverse current from Vcc pin unlike MCP73831
+
+
+- Rev.F design - DONE
+    - current measure point - DONE 12/08
+    - change value of cap 68->47    - DONE 12/08
+    - PPTC land pattern: no solder jumper, use 0Ohm resistor instead - CANCEL 12/08
+    - Q4 Pch FET: wrong Drain and Source - DONE 12/08
+    - D5 can be removed.    - DONE 12/08
 
 
 
-
-HID profile
------------
-S~,6    HID profile
-S~,0    SPP profile
-R,1     reboot
-
-
-Apple iOS
----------
-Keyboard can be used with iPhone, but mouse cannot.
-To operate iOS with keyboard is not so useful, though.
-There may be iOS specific scancodes?
-
-
-HID flag register
------------------
-SH,0200
-GH
-
-10 0000 0000(0200)  default
-00 0011 1000(0038)  Combo
-|| |  | |\_\____ number of paired devices to which the module can reconnect
-|| |  | \_______ send out reports over UART (0xFF <len> <data>)
-|| \__\_________ descriptor type
-|\______________ toggle virtual keyboard on iOS when first connected
-\_______________ Force HID mode if GPIO11 is high on power-up
-
-    Descriptor type:
-    0000:   keybaord
-    0001:   Game Pad
-    0010:   Mouse
-    0011:   Combo
-    0100:   Joystick
-    1xxx:   reserved
-
-
-Out report - Indicator
-----------------------
-0xFE 0x02 0x01 <LED_state>
-
-
-LED Status
-----------
-Configuring                     10 times per sec
-Startup/configuration timer     2 times per sec
-Discoverable/Inquiring/Idle     once per sec
-Connected                       solid on
-
-
-Pairing
--------
-First, host initiates pairing process and once it is done, auto connect will work thereafter.
-SM,3        Master mode
-SM,4        Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
-                confirm: auto connect works and control connection with GPIO6
-SM,5        Auto Connect ANY Mode (Mode =ANY)
-                each time GPIO is set, make inquiry and connect to the first found device
-SM,6        automatically reconnect(Mode =Pair)
-                confirm: auto connect works well but difficult to enter command mode.
-
-SR,Z        removes all remote addresses for reconnecting.
-                can be used to connect another host
-SR,I        registers last inquiry address
-
-
-Fast data mode
---------------
-The module enters fast data mode after 'remote configuration timer' window is passed from power on.
-In this mode the module does not accept '$$$' to enter command mode.
-
-Power Management
-----------------
-Inquiry and Page window     Idle or Active  (3.1.1)
-    Downside: delay in discovery or connection time
-    SI,         // set inquiry scan window(discovery) on/off duty?
-    SJ,         // set page scan window(connection)
-    This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
-
-Sniff mode                  Transmit
-    Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
-    In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
-    SW,<val>    // set interval timer(*0.625ms) 0000-7FFF
-
-Deep sleep                  Idle            (3.1.2)
-    In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer.
-    SW,8320     // deep sleep enable(interval=0x320*0.625=500ms)
-    In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second.
-    To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
-        *send a charactor to the UART(first charactor will be lost)
-        *toggle CTS low to high and wait 5ms
-        *wake automatically every slot time(<val>*0.625ms)
-    Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
-    Downside: latency and data loss
-
-Disable Output driver       Idle or Active  (3.1.3)
-    S%,1000     // set all GPIO pins(0-11) to inputs.
-
-Lower Transmit Power        Idle or Active  (3.1.4)
-    SY,<hex>    // transmit power setting(takes effect after a power cycle and reboot)
-    Downside: reducing effective range
-
-
-Optimizig for Latency
----------------------
-By default the firmware is optimized for throughput.
-SQ,16           // set latency bit
-SQ,0            // unset latency bit
-
-
-Configuration timer settings
-----------------------------
-Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
-
-The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.)
-    ST,0        // no remote, no local when connected
-    ST,<1-252>  // local and remote with timeout in seconds from power up
-    ST,253      // local only       without timeout
-    ST,254      // remote only      without timeout
-    ST,255      // local and remote without timeout
-
-
-Android
--------
-3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
-
-
-Commands
---------
-SC,
-SM,<val>
-SD,         
-SP,<string>             Pin code(alpahnumeric)
-SQ,<mask>               Special configuration(GPIO, discovery mode, low latency, reboot, UART)
-SR,<hex>                Store remote address
-SR,Z                    Erase all address
-SS,<string>             Set service name(1-20)**
-ST,<val>                Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
-SU,<val>                UART baud rate
-SW,<val>                low-power sniff mode** deep sleep and wake up every 625us * <val>
-SX,<0|1>                bonding enable  only acceps device that matches the stored address
-SY,<hex>                power setting** 
-SZ,<val>                non-standard raw baud rate  <val>=baud*0.004096
-S~,<val>                Profile     0:SPP, 5:APL, 6:HID
-S-,<string>             Device name     -15 alphanumeric charactors
-S?,<0|1>                role switch enable
-S$,<char>               command mode char
-$|,<hex>                low-power connect mode  deep sleep/active(discoverable and connectable) cycle
-D                       display basic setting
-E                       display extended setting
-GB                      display the device's Bluetooth address
-GF                      display Bluetooth address of connected device
-GK                      show connection status
-GR                      show remote address for reconnecting
-G&                      show GPIO pin
-G<char>                 show stored setting
-+                       toggle local echo on/off
-&                       show GPIO 3,4,6,7(DIP switch)
-C                       connect to stored remote address
-C,<address>             connect last address
-CFI                     connect and go into fast data mode
-CFR                     connect and go into fast data mode
-CT,<address>,<val>      connect to the address and disconnect after val?
-F,1                     fast data mod:
-H                       display help
-I,<time>,<cod>          inquiry scan with <cod>
-IN
-IQ                      scan
-IS                      inquiry scan with 001F00
-J                       hide pin code
-K,                      kill    disconnects current connection
-L                       link quality
-M                       show modem signlal status
-O                       display other settings
-P,<car>                 pass through?
-Q                       quiet mode  make the module not discoverable
-Q,0                     discoverable and connectable
-Q,1                     not discoverable and not connectable
-Q,2                     not discoverable and connectable
-Q,?                     display current quiet mode
-R,1                     reboot
-T,<0|1>                 pass received data while in command mode
-U,<baud>,<parity>       change UART setting tentatively
-V                       display firmware version
-W                       wake from quiet mode    enable discovery and connection
-Z                       deep sleep mode(<2mA)
-
-
-
-help
-----
-*** SET COMMANDS ***
-SA,<3,0>   - Authentication
-SC,<hex>   - Service Class
-SD,<hex>   - Device Class
-SE,<1-16>  - UUID
-SF,1       - Factory Defaults
-SH,<hex>   - HID flags
-SI,<hex>   - Inquiry Scan Window
-SJ,<hex>   - Page Scan Window
-SL,<E,O,N> - Parity
-SM,<0-5>   - Mode (0=slav,1=mstr,2=trig,3=auto,4=DTR,5=Any)
-SN,<name>  - Name
-SO,<text>  - conn/discon Status
-SP,<text>  - Pin Code
-SR,<adr>   - Remote Address
-SS,<text>  - Service Name
-ST,<num>   - Config Timer
-SU,<rate>  - Baudrate
-SW,<hex>   - Sniff Rate
-SX,<1,0>   - Bonding
-SY,<hex>   - TX power
-SZ,<num>   - Raw Baudrate
-S~,<0-6>   - Profile (0=SPP,1=DCE,2=DTE,3=MDM,4=D&S,6=HID
-S?,<0-1>   - role switch
-S$,<char>  - CMD mode char
-S@,<hex>   - io port dir
-S&,<hex>   - io port val
-S%,<hex>   - io boot dir
-S^,<hex>   - io boot val
-S*,<hex>   - pio(8-11) set
-S|,<hex>   - low power timers
-S+,<num>   - DTR timer
-S=,<hex>   - Key mapper
-S:,<num>   - sleep timer
-*** DISPLAY      ***
-D     - Basic Settings
-E     - Extended Settings
-G<X>  - Stored setting
-GB    - BT Address
-GF    - BT Address of Last Connection
-GK    - Connect Status
-G&    - I/O Ports
-V     - Firmare version
-*** OTHER        ***
-C,<adr>    - Connect
-F,1        - Fast Mode
-I,<time>,<cod> - Device Scan Inquiry
-J          - Hide Pin Code
-K,         - Kill (disconnect)
-L,         - toggle local echo
-P,<text>   - Pass Thru
-Q          - Quiet (no discovery)
-R,1        - Reboot
-T,<0,1>    - send data in CMD mode
-U,<rate>,<E,O,N> - Temp Uart Change
-Z          - low power sleep
-&          - Read switches
+- BT_INDICATOR LED turns on wrongly when touching line or pin.  -- pull-up enabled on PF6/GPIO2 08/30
+- Lipo charger configuration: fast charge time:  USB charger spec? -- used 2kohm
+- use LED of charger to alarm low battery. LED should be powered directly from Lipo? - cancel; powered from VUSB
+- Use RTS in serial_uart.c to resolve missing chars from help message of RN-42 - done
+- CTS/RTS lines are needed? just connect in loop back if no flow control is needed. - done
+- add IO pin to charger status CHRG; LED control(low) and detect charge status(input HiZ) 07.24
+- LINKED: add trace on PIO2 to PF6   07.24
+- Lipo voltage ADC sensing
+- Lipo charger MCP73831: needs capacitor 4.7uF *2
+- USB connection check - 07.01
+- BT on/off check: whether RX line is pulled up? - checking RTS 07.01
+- USB/BT switching  BT is on -> BT, BT is off -> USB - 07.01
+- Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V    07.01
+- Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough   07.01
+- Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04
diff --git a/keyboard/hhkb_rn42/PowerSave.txt b/keyboard/hhkb_rn42/PowerSave.txt
index 943923c336..9aa89f4416 100644
--- a/keyboard/hhkb_rn42/PowerSave.txt
+++ b/keyboard/hhkb_rn42/PowerSave.txt
@@ -1,6 +1,19 @@
 RN-42
 =====
 
+
+12/11
+Power Comsumption
+MCU+HHKB
+--------
+Battery drive:
+    idle    18.9mA
+    active  35.8mA
+
+USB powered:
+    40.0mA
+
+
 HHKB key switch power control
 -----------------------------
 MOS FET Nch: BSS138 or IRLML6344T, either works and no apparent difference.

From a679928620c68e346fcfc864e8de632ce8c997c3 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Tue, 6 Jan 2015 03:22:41 +0900
Subject: [PATCH 51/95] Fxi layer stuck of keymap_hasu

- In mouse key layer with holding semicolon, press Fn0, release
  semicolon and release Fn0 now layer 1 is stuck.
---
 keyboard/hhkb_rn42/keymap_hasu.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/keyboard/hhkb_rn42/keymap_hasu.c b/keyboard/hhkb_rn42/keymap_hasu.c
index 7b93789082..433f9cb270 100644
--- a/keyboard/hhkb_rn42/keymap_hasu.c
+++ b/keyboard/hhkb_rn42/keymap_hasu.c
@@ -47,7 +47,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
            CAPS,NO,  NO,  NO,  NO,  NO,  NO,  NO,  PSCR,SLCK,PAUS, UP,  NO,  BSPC, \
            LCTL,VOLD,VOLU,MUTE,NO,  NO,  PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
            LSFT,NO,  NO,  NO,  NO,  NO,  PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
-                LGUI,LALT,          SPC,                RALT,RGUI),
+                LGUI,LALT,          TRNS,               RALT,RGUI),
 
     /* Layer 2: Vi mode[Slash]
      * ,-----------------------------------------------------------.
@@ -66,7 +66,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
            TAB, HOME,PGDN,UP,  PGUP,END, HOME,PGDN,PGUP,END, NO,  NO,  NO,  BSPC, \
            LCTL,NO,  LEFT,DOWN,RGHT,NO,  LEFT,DOWN,UP,  RGHT,NO,  NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, TRNS,RSFT,NO, \
+           LSFT,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \
                 LGUI,LALT,          SPC,                RALT,RGUI),
 
     /* Layer 3: Mouse mode(IJKL)[Semicolon]
@@ -81,16 +81,16 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * `-----------------------------------------------------------'
      *      |Gui |Alt  |          Mb1          |Fn   |Fn |
      *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
+     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
      */
     [3] = \
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  LEFT,WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
-           LCTL,ACL0,ACL1,ACL2,ACL2,NO,  NO,  MS_L,MS_D,MS_R,TRNS,NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,NO, \
+           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
+           LCTL,ACL0,ACL1,ACL2,ACL2,NO,  NO,  MS_L,MS_D,MS_R,FN3, NO,  ENT, \
+           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,TRNS, \
                 LGUI,LALT,          BTN1,               TRNS,TRNS),
 
-    /* Layer 5: Mouse mode(IJKL)[Space]
+    /* Layer 4: Mouse mode(IJKL)[Space]
      * ,-----------------------------------------------------------.
      * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
      * |-----------------------------------------------------------|
@@ -102,13 +102,13 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * `-----------------------------------------------------------'
      *      |Gui |Alt  |          Mb1          |Fn   |Fn |
      *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
+     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
      */
     [4] = \
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  LEFT,WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
+           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
            LCTL,VOLD,VOLU,MUTE,NO,  NO,  NO,  MS_L,MS_D,MS_R,BTN1,NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,NO, \
+           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,TRNS, \
                 LGUI,LALT,          TRNS,               TRNS,TRNS),
 
 #if 0
@@ -127,7 +127,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel 
      */
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           TAB, NO,  NO,  NO,  NO,  NO,  LEFT,WH_D,WH_U,RGHT,NO,  NO,  NO,  BSPC, \
+           TAB, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,WH_U,RGHT,NO,  NO,  NO,  BSPC, \
            LCTL,NO,  ACL0,ACL1,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
            LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \
                 LGUI,LALT,          BTN1,               RALT,TRNS),
@@ -147,7 +147,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel 
      */
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  LEFT,WH_D,WH_U,RGHT,NO,  FN9, FN10,FN8, \
+           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,WH_U,RGHT,NO,  FN9, FN10,FN8, \
            LCTL,NO,  ACL0,ACL1,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,BTN1,NO,  ENT, \
            LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,NO, \
                 LGUI,LALT,          TRNS,               RALT,RGUI),

From 4f121de7ad7782cde7d9d5c04adb3ef2561c5eaf Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Sun, 11 Jan 2015 02:39:32 +0900
Subject: [PATCH 52/95] rn42: Add rn42_getc and rn42_gets

---
 keyboard/hhkb_rn42/rn42/rn42.c | 29 +++++++++++++++++++++++++++++
 keyboard/hhkb_rn42/rn42/rn42.h |  3 +++
 2 files changed, 32 insertions(+)

diff --git a/keyboard/hhkb_rn42/rn42/rn42.c b/keyboard/hhkb_rn42/rn42/rn42.c
index 1565b4cf14..aa6015cbf2 100644
--- a/keyboard/hhkb_rn42/rn42/rn42.c
+++ b/keyboard/hhkb_rn42/rn42/rn42.c
@@ -4,6 +4,7 @@
 #include "serial.h"
 #include "rn42.h"
 #include "print.h"
+#include "timer.h"
 #include "wait.h"
 
 
@@ -47,11 +48,39 @@ void rn42_init(void)
     serial_init();
 }
 
+int16_t rn42_getc(void)
+{
+    return serial_recv2();
+}
+
+char *rn42_gets(uint16_t timeout)
+{
+    static char s[16];
+    uint16_t t = timer_read();
+    uint8_t i = 0;
+    int16_t c;
+    while (i < 15 && timer_elapsed(t) < timeout) {
+               if ((c = rn42_getc()) != -1) {
+            if ((char)c == '\r') continue;
+            if ((char)c == '\n') break;
+            s[i++] = c;
+        }
+    }
+    s[i] = '\0';
+    return s;
+}
+
 void rn42_putc(uint8_t c)
 {
     serial_send(c);
 }
 
+void rn42_puts(char *s)
+{
+    while (*s)
+	serial_send(*s++);
+}
+
 bool rn42_autoconnecting(void)
 {
     // GPIO6 for control connection(high: auto connect, low: disconnect)
diff --git a/keyboard/hhkb_rn42/rn42/rn42.h b/keyboard/hhkb_rn42/rn42/rn42.h
index 5283a3648c..86090be7c5 100644
--- a/keyboard/hhkb_rn42/rn42/rn42.h
+++ b/keyboard/hhkb_rn42/rn42/rn42.h
@@ -7,7 +7,10 @@ host_driver_t rn42_driver;
 host_driver_t rn42_config_driver;
 
 void rn42_init(void);
+int16_t rn42_getc(void);
+char *rn42_gets(uint16_t timeout);
 void rn42_putc(uint8_t c);
+void rn42_puts(char *s);
 bool rn42_autoconnecting(void);
 void rn42_autoconnect(void);
 void rn42_disconnect(void);

From 1b95b3c51a0eee5c8e47b189ece68ac55d7e4069 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Sun, 11 Jan 2015 07:00:41 +0900
Subject: [PATCH 53/95] rn42: Add commands for RN-42

---
 keyboard/hhkb_rn42/rn42/rn42_task.c | 234 ++++++++++++++++++----------
 1 file changed, 153 insertions(+), 81 deletions(-)

diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.c b/keyboard/hhkb_rn42/rn42/rn42_task.c
index 1ad38d3722..e58bb427a1 100644
--- a/keyboard/hhkb_rn42/rn42/rn42_task.c
+++ b/keyboard/hhkb_rn42/rn42/rn42_task.c
@@ -1,4 +1,5 @@
 #include <stdint.h>
+#include <string.h>
 #include "keycode.h"
 #include "serial.h"
 #include "host.h"
@@ -9,6 +10,7 @@
 #include "print.h"
 #include "debug.h"
 #include "timer.h"
+#include "wait.h"
 #include "command.h"
 #include "battery.h"
 
@@ -34,39 +36,34 @@ void rn42_task_init(void)
 void rn42_task(void)
 {
     int16_t c;
-    if (config_mode) {
-        // Config mode: print output from RN-42
-        while ((c = serial_recv2()) != -1) {
-            // without flow control it'll fail to receive data when flooded
-            xprintf("%c", c);
-        }
-    } else {
-        // Raw mode: interpret output report of LED state
-        while ((c = serial_recv2()) != -1) {
-            // LED Out report: 0xFE, 0x02, 0x01, <leds>
-            // To get the report over UART set bit3 with SH, command.
-            static enum {LED_INIT, LED_FE, LED_02, LED_01} state = LED_INIT;
-            switch (state) {
-                case LED_INIT:
-                    if (c == 0xFE) state = LED_FE;
-                    else           state = LED_INIT;
-                    break;
-                case LED_FE:
-                    if (c == 0x02) state = LED_02;
-                    else           state = LED_INIT;
-                    break;
-                case LED_02:
-                    if (c == 0x01) state = LED_01;
-                    else           state = LED_INIT;
-                    break;
-                case LED_01:
-                    dprintf("LED status: %02X\n", c);
-                    rn42_set_leds(c);
-                    state = LED_INIT;
-                    break;
-                default:
-                    state = LED_INIT;
-            }
+    // Raw mode: interpret output report of LED state
+    while ((c = rn42_getc()) != -1) {
+        // LED Out report: 0xFE, 0x02, 0x01, <leds>
+        // To get the report over UART set bit3 with SH, command.
+        static enum {LED_INIT, LED_FE, LED_02, LED_01} state = LED_INIT;
+        switch (state) {
+            case LED_INIT:
+                if (c == 0xFE) state = LED_FE;
+                else {
+                    if (0x0 <= c && c <= 0x7f) xprintf("%c", c);
+                    else xprintf(" %02X", c);
+                }
+                break;
+            case LED_FE:
+                if (c == 0x02) state = LED_02;
+                else           state = LED_INIT;
+                break;
+            case LED_02:
+                if (c == 0x01) state = LED_01;
+                else           state = LED_INIT;
+                break;
+            case LED_01:
+                dprintf("LED status: %02X\n", c);
+                rn42_set_leds(c);
+                state = LED_INIT;
+                break;
+            default:
+                state = LED_INIT;
         }
     }
 
@@ -103,7 +100,7 @@ void rn42_task(void)
             uint8_t h = t/3600;
             uint8_t m = t%3600/60;
             uint8_t s = t%60;
-            xprintf("%02u:%02u:%02u\t%umV\n", h, m, s, v);
+            dprintf("%02u:%02u:%02u\t%umV\n", h, m, s, v);
             /* TODO: xprintf doesn't work for this.
             xprintf("%02u:%02u:%02u\t%umV\n", (t/3600), (t%3600/60), (t%60), v);
             */
@@ -124,59 +121,105 @@ void rn42_task(void)
 /******************************************************************************
  * Command
  ******************************************************************************/
+static host_driver_t *prev_driver = &rn42_driver;
+
+static void print_rn42(void)
+{
+    int16_t c;
+    while ((c = rn42_getc()) != -1) {
+        xprintf("%c", c);
+    }
+}
+
+static void clear_rn42(void)
+{
+    while (rn42_getc() != -1) ;
+}
+
+static void enter_command_mode(void)
+{
+    // RN-42 disconnect
+    prev_driver = host_get_driver();
+    clear_keyboard();
+    host_set_driver(&rn42_config_driver);   // null driver; not to send a key to host
+    rn42_disconnect();
+    print("\nRN-42: disconnect\n");
+
+    print("Entering config mode ...\n");
+    wait_ms(1000);
+    rn42_puts("$$$");   // Command mode
+    wait_ms(1000);
+    rn42_puts("+\r\n"); // Local echo on
+    print_rn42();
+}
+
+static void exit_command_mode(void)
+{
+    print("Exiting config mode ...\n");
+    rn42_puts("+\r\n"); // Local echo off
+    wait_ms(500);
+    rn42_puts("---\r\n");
+    wait_ms(500);
+    print_rn42();
+
+    rn42_autoconnect();
+    print("RN-42: auto_connect\n");
+    host_set_driver(prev_driver);
+}
+
+static void init_rn42(void)
+{
+    // RN-42 configure
+    if (!config_mode) enter_command_mode();
+    rn42_puts("SF,1\r\n");  // factory defaults
+    wait_ms(500); print_rn42();
+    rn42_puts("S-,TmkBT\r\n");
+    wait_ms(500); print_rn42();
+    rn42_puts("SS,Keyboard/Mouse\r\n");
+    wait_ms(500); print_rn42();
+    rn42_puts("SM,4\r\n");  // auto connect(DTR)
+    wait_ms(500); print_rn42();
+    rn42_puts("SW,8000\r\n");   // Sniff disable
+    wait_ms(500); print_rn42();
+    rn42_puts("S~,6\r\n");   // HID profile
+    wait_ms(500); print_rn42();
+    rn42_puts("SH,003C\r\n");   // combo device, out-report, 4-reconnect
+    wait_ms(500); print_rn42();
+    rn42_puts("SY,FFF4\r\n");   // transmit power -12
+    wait_ms(500); print_rn42();
+    rn42_puts("R,1\r\n");
+    wait_ms(500); print_rn42();
+    if (!config_mode) exit_command_mode();
+}
+
+static void connect(uint8_t *addr)
+{
+    enter_command_mode();
+}
+
+static void pairng(void)
+{
+}
+
 bool command_extra(uint8_t code)
 {
     uint32_t t;
     uint16_t b;
-    static host_driver_t *prev_driver = &rn42_driver;
     switch (code) {
         case KC_H:
         case KC_SLASH: /* ? */
             print("\n\n----- Bluetooth RN-42 Help -----\n");
-            print("Del: enter/exit config mode(auto_connect/disconnect)\n");
-            print("i:   RN-42 info\n");
-            print("b:   battery voltage\n");
+            print("i:       RN-42 info\n");
+            print("b:       battery voltage\n");
+            print("Del:     enter/exit RN-42 config mode\n");
+            print("Slck:    RN-42 initialize\n");
 
             if (config_mode) {
                 return true;
             } else {
-                print("u:   Force USB mode\n");
+                print("u:       toggle Force USB mode\n");
                 return false;   // to display default command help
             }
-        case KC_DELETE:
-            if (rn42_autoconnecting()) {
-                prev_driver = host_get_driver();
-                clear_keyboard();
-                _delay_ms(500);
-                host_set_driver(&rn42_config_driver);   // null driver; not to send a key to host
-                rn42_disconnect();
-                print("\nRN-42: disconnect\n");
-                print("Enter config mode\n");
-                print("type $$$ to start and + for local echo\n");
-                command_state = CONSOLE;
-                config_mode = true;
-            } else {
-                rn42_autoconnect();
-                print("\nRN-42: auto_connect\n");
-                print("Exit config mode\n");
-                command_state = ONESHOT;
-                config_mode = false;
-                //clear_keyboard();
-                host_set_driver(prev_driver);
-            }
-            return true;
-        case KC_U:
-            if (config_mode) return false;
-            if (force_usb) {
-                print("Auto mode\n");
-                force_usb = false;
-            } else {
-                print("USB mode\n");
-                force_usb = true;
-                clear_keyboard();
-                host_set_driver(&lufa_driver);
-            }
-            return true;
         case KC_I:
             print("\n----- RN-42 info -----\n");
             xprintf("protocol: %s\n", (host_get_driver() == &rn42_driver) ? "RN-42" : "LUFA");
@@ -207,7 +250,7 @@ bool command_extra(uint8_t code)
             uint8_t h = t/3600;
             uint8_t m = t%3600/60;
             uint8_t s = t%60;
-            xprintf("uptime: %02ud%02u:%02u:%02u\n", d, h, m, s);
+            xprintf("uptime: %02u %02u:%02u:%02u\n", d, h, m, s);
             return true;
         case KC_B:
             // battery monitor
@@ -218,24 +261,53 @@ bool command_extra(uint8_t code)
             xprintf("%02u:",   t%3600/60);
             xprintf("%02u\n",  t%60);
             return true;
+        case KC_U:
+            if (config_mode) return false;
+            if (force_usb) {
+                print("Auto mode\n");
+                force_usb = false;
+            } else {
+                print("USB mode\n");
+                force_usb = true;
+                clear_keyboard();
+                host_set_driver(&lufa_driver);
+            }
+            return true;
+        case KC_DELETE:
+            /* RN-42 Command mode */
+            if (rn42_autoconnecting()) {
+                enter_command_mode();
+
+                command_state = CONSOLE;
+                config_mode = true;
+            } else {
+                exit_command_mode();
+
+                command_state = ONESHOT;
+                config_mode = false;
+            }
+            return true;
+        case KC_SCROLLLOCK:
+            init_rn42();
+            return true;
         default:
             if (config_mode)
                 return true;
             else
-                return false;   // exec default command
+                return false;   // yield to default command
     }
     return true;
 }
 
+/*
+ * RN-42 Command mode
+ * sends charactors to the module
+ */
 static uint8_t code2asc(uint8_t code);
 bool command_console_extra(uint8_t code)
 {
-    switch (code) {
-        default:
-            rn42_putc(code2asc(code));
-            return true;
-    }
-    return false;
+    rn42_putc(code2asc(code));
+    return true;
 }
 
 // convert keycode into ascii charactor

From 3b3af3bae0deac7831c85847bae7729b0e281b8d Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Mon, 12 Jan 2015 04:32:53 +0900
Subject: [PATCH 54/95] Increase buffer of rn42_gets() and change rn42_linked()

---
 keyboard/hhkb_rn42/rn42/rn42.c | 10 +++++-----
 keyboard/hhkb_rn42/rn42/rn42.h |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/keyboard/hhkb_rn42/rn42/rn42.c b/keyboard/hhkb_rn42/rn42/rn42.c
index aa6015cbf2..756285d7bb 100644
--- a/keyboard/hhkb_rn42/rn42/rn42.c
+++ b/keyboard/hhkb_rn42/rn42/rn42.c
@@ -53,14 +53,14 @@ int16_t rn42_getc(void)
     return serial_recv2();
 }
 
-char *rn42_gets(uint16_t timeout)
+const char *rn42_gets(uint16_t timeout)
 {
-    static char s[16];
+    static char s[24];
     uint16_t t = timer_read();
     uint8_t i = 0;
     int16_t c;
-    while (i < 15 && timer_elapsed(t) < timeout) {
-               if ((c = rn42_getc()) != -1) {
+    while (i < 23 && timer_elapsed(t) < timeout) {
+        if ((c = rn42_getc()) != -1) {
             if ((char)c == '\r') continue;
             if ((char)c == '\n') break;
             s[i++] = c;
@@ -126,7 +126,7 @@ bool rn42_linked(void)
     //   Hi-Z:  Not powered
     //   High:  Linked
     //   Low:   Connecting
-    return !rn42_rts() && PINF&(1<<6);
+    return PINF&(1<<6);
 }
 
 
diff --git a/keyboard/hhkb_rn42/rn42/rn42.h b/keyboard/hhkb_rn42/rn42/rn42.h
index 86090be7c5..db6916fe86 100644
--- a/keyboard/hhkb_rn42/rn42/rn42.h
+++ b/keyboard/hhkb_rn42/rn42/rn42.h
@@ -8,7 +8,7 @@ host_driver_t rn42_config_driver;
 
 void rn42_init(void);
 int16_t rn42_getc(void);
-char *rn42_gets(uint16_t timeout);
+const char *rn42_gets(uint16_t timeout);
 void rn42_putc(uint8_t c);
 void rn42_puts(char *s);
 bool rn42_autoconnecting(void);

From 2626a3226023a9d0bb7add6dadae46205990c6d2 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Mon, 12 Jan 2015 04:35:00 +0900
Subject: [PATCH 55/95] Use pgmspace for RN-42 commands

---
 keyboard/hhkb_rn42/rn42/rn42_task.c | 170 ++++++++++++++++++++++------
 1 file changed, 137 insertions(+), 33 deletions(-)

diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.c b/keyboard/hhkb_rn42/rn42/rn42_task.c
index e58bb427a1..5107fef483 100644
--- a/keyboard/hhkb_rn42/rn42/rn42_task.c
+++ b/keyboard/hhkb_rn42/rn42/rn42_task.c
@@ -1,5 +1,7 @@
 #include <stdint.h>
 #include <string.h>
+#include <avr/pgmspace.h>
+#include <avr/eeprom.h>
 #include "keycode.h"
 #include "serial.h"
 #include "host.h"
@@ -109,7 +111,7 @@ void rn42_task(void)
 
 
     /* Connection monitor */
-    if (rn42_linked()) {
+    if (!rn42_rts() && rn42_linked()) {
         status_led(true);
     } else {
         status_led(false);
@@ -136,34 +138,51 @@ static void clear_rn42(void)
     while (rn42_getc() != -1) ;
 }
 
+#define SEND_STR(str)       send_str(PSTR(str))
+#define SEND_COMMAND(cmd)   send_command(PSTR(cmd))
+
+static void send_str(const char *str)
+{
+    uint8_t c;
+    while ((c = pgm_read_byte(str++)))
+        rn42_putc(c);
+}
+
+static const char *send_command(const char *cmd)
+{
+    static const char *s;
+    send_str(cmd);
+    wait_ms(500);
+    s = rn42_gets(100);
+    xprintf("%s\r\n", s);
+    print_rn42();
+    return s;
+}
+
 static void enter_command_mode(void)
 {
-    // RN-42 disconnect
     prev_driver = host_get_driver();
     clear_keyboard();
     host_set_driver(&rn42_config_driver);   // null driver; not to send a key to host
     rn42_disconnect();
-    print("\nRN-42: disconnect\n");
+    while (rn42_linked()) ;
 
     print("Entering config mode ...\n");
-    wait_ms(1000);
-    rn42_puts("$$$");   // Command mode
-    wait_ms(1000);
-    rn42_puts("+\r\n"); // Local echo on
+    wait_ms(1100);          // need 1 sec
+    SEND_COMMAND("$$$");
+    wait_ms(600);           // need 1 sec
     print_rn42();
+    const char *s = SEND_COMMAND("v\r\n");
+    if (strncmp("v", s, 1) != 0) SEND_COMMAND("+\r\n"); // local echo on
 }
 
 static void exit_command_mode(void)
 {
     print("Exiting config mode ...\n");
-    rn42_puts("+\r\n"); // Local echo off
-    wait_ms(500);
-    rn42_puts("---\r\n");
-    wait_ms(500);
-    print_rn42();
+    SEND_COMMAND("---\r\n");    // exit
 
     rn42_autoconnect();
-    print("RN-42: auto_connect\n");
+    clear_keyboard();
     host_set_driver(prev_driver);
 }
 
@@ -171,34 +190,77 @@ static void init_rn42(void)
 {
     // RN-42 configure
     if (!config_mode) enter_command_mode();
-    rn42_puts("SF,1\r\n");  // factory defaults
-    wait_ms(500); print_rn42();
-    rn42_puts("S-,TmkBT\r\n");
-    wait_ms(500); print_rn42();
-    rn42_puts("SS,Keyboard/Mouse\r\n");
-    wait_ms(500); print_rn42();
-    rn42_puts("SM,4\r\n");  // auto connect(DTR)
-    wait_ms(500); print_rn42();
-    rn42_puts("SW,8000\r\n");   // Sniff disable
-    wait_ms(500); print_rn42();
-    rn42_puts("S~,6\r\n");   // HID profile
-    wait_ms(500); print_rn42();
-    rn42_puts("SH,003C\r\n");   // combo device, out-report, 4-reconnect
-    wait_ms(500); print_rn42();
-    rn42_puts("SY,FFF4\r\n");   // transmit power -12
-    wait_ms(500); print_rn42();
-    rn42_puts("R,1\r\n");
-    wait_ms(500); print_rn42();
+    SEND_COMMAND("SF,1\r\n");  // factory defaults
+    SEND_COMMAND("S-,TmkBT\r\n");
+    SEND_COMMAND("SS,Keyboard/Mouse\r\n");
+    SEND_COMMAND("SM,4\r\n");  // auto connect(DTR)
+    SEND_COMMAND("SW,8000\r\n");   // Sniff disable
+    SEND_COMMAND("S~,6\r\n");   // HID profile
+    SEND_COMMAND("SH,003C\r\n");   // combo device, out-report, 4-reconnect
+    SEND_COMMAND("SY,FFF4\r\n");   // transmit power -12
+    SEND_COMMAND("R,1\r\n");
     if (!config_mode) exit_command_mode();
 }
 
-static void connect(uint8_t *addr)
+#if 0
+// Switching connections
+// NOTE: Remote Address doesn't work in the way manual says.
+// EEPROM address for link store
+#define RN42_LINK0  (uint8_t *)128
+#define RN42_LINK1  (uint8_t *)140
+#define RN42_LINK2  (uint8_t *)152
+#define RN42_LINK3  (uint8_t *)164
+static void store_link(uint8_t *eeaddr)
 {
     enter_command_mode();
+    SEND_STR("GR\r\n"); // remote address
+    const char *s = rn42_gets(500);
+    if (strcmp("GR", s) == 0) s = rn42_gets(500);   // ignore local echo
+    xprintf("%s(%d)\r\n", s, strlen(s));
+    if (strlen(s) == 12) {
+        for (int i = 0; i < 12; i++) {
+            eeprom_write_byte(eeaddr+i, *(s+i));
+            dprintf("%c ", *(s+i));
+        }
+        dprint("\r\n");
+    }
+    exit_command_mode();
 }
 
-static void pairng(void)
+static void restore_link(const uint8_t *eeaddr)
 {
+    enter_command_mode();
+    SEND_COMMAND("SR,Z\r\n");   // remove remote address
+    SEND_STR("SR,");            // set remote address from EEPROM
+    for (int i = 0; i < 12; i++) {
+        uint8_t c = eeprom_read_byte(eeaddr+i);
+        rn42_putc(c);
+        dprintf("%c ", c);
+    }
+    dprintf("\r\n");
+    SEND_COMMAND("\r\n");
+    SEND_COMMAND("R,1\r\n");    // reboot
+    exit_command_mode();
+}
+
+static const char *get_link(uint8_t * eeaddr)
+{
+    static char s[13];
+    for (int i = 0; i < 12; i++) {
+        uint8_t c = eeprom_read_byte(eeaddr+i);
+        s[i] = c;
+    }
+    s[12] = '\0';
+    return s;
+}
+#endif
+
+static void pairing(void)
+{
+    enter_command_mode();
+    SEND_COMMAND("SR,Z\r\n");   // remove remote address
+    SEND_COMMAND("R,1\r\n");    // reboot
+    exit_command_mode();
 }
 
 bool command_extra(uint8_t code)
@@ -213,6 +275,11 @@ bool command_extra(uint8_t code)
             print("b:       battery voltage\n");
             print("Del:     enter/exit RN-42 config mode\n");
             print("Slck:    RN-42 initialize\n");
+#if 0
+            print("1-4:     restore link\n");
+            print("F1-F4:   store link\n");
+#endif
+            print("p:       pairing\n");
 
             if (config_mode) {
                 return true;
@@ -220,6 +287,37 @@ bool command_extra(uint8_t code)
                 print("u:       toggle Force USB mode\n");
                 return false;   // to display default command help
             }
+        case KC_P:
+            pairing();
+            return true;
+#if 0
+        /* Store link address to EEPROM */
+        case KC_F1:
+            store_link(RN42_LINK0);
+            return true;
+        case KC_F2:
+            store_link(RN42_LINK1);
+            return true;
+        case KC_F3:
+            store_link(RN42_LINK2);
+            return true;
+        case KC_F4:
+            store_link(RN42_LINK3);
+            return true;
+        /* Restore link address to EEPROM */
+        case KC_1:
+            restore_link(RN42_LINK0);
+            return true;
+        case KC_2:
+            restore_link(RN42_LINK1);
+            return true;
+        case KC_3:
+            restore_link(RN42_LINK2);
+            return true;
+        case KC_4:
+            restore_link(RN42_LINK3);
+            return true;
+#endif
         case KC_I:
             print("\n----- RN-42 info -----\n");
             xprintf("protocol: %s\n", (host_get_driver() == &rn42_driver) ? "RN-42" : "LUFA");
@@ -251,6 +349,12 @@ bool command_extra(uint8_t code)
             uint8_t m = t%3600/60;
             uint8_t s = t%60;
             xprintf("uptime: %02u %02u:%02u:%02u\n", d, h, m, s);
+#if 0
+            xprintf("LINK0: %s\r\n", get_link(RN42_LINK0));
+            xprintf("LINK1: %s\r\n", get_link(RN42_LINK1));
+            xprintf("LINK2: %s\r\n", get_link(RN42_LINK2));
+            xprintf("LINK3: %s\r\n", get_link(RN42_LINK3));
+#endif
             return true;
         case KC_B:
             // battery monitor

From 517817b9c7f00b180385c6bdf5310234185e5b98 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Thu, 15 Jan 2015 17:02:38 +0900
Subject: [PATCH 56/95] rn42: Update doc

---
 keyboard/hhkb_rn42/{ => rn42}/MEMO.txt |  77 +++---
 keyboard/hhkb_rn42/rn42/RN42.txt       | 362 +++++++++++++++++++++++++
 2 files changed, 404 insertions(+), 35 deletions(-)
 rename keyboard/hhkb_rn42/{ => rn42}/MEMO.txt (95%)
 create mode 100644 keyboard/hhkb_rn42/rn42/RN42.txt

diff --git a/keyboard/hhkb_rn42/MEMO.txt b/keyboard/hhkb_rn42/rn42/MEMO.txt
similarity index 95%
rename from keyboard/hhkb_rn42/MEMO.txt
rename to keyboard/hhkb_rn42/rn42/MEMO.txt
index f2aaa7c046..f772c4cb53 100644
--- a/keyboard/hhkb_rn42/MEMO.txt
+++ b/keyboard/hhkb_rn42/rn42/MEMO.txt
@@ -1,38 +1,8 @@
-Roving RN-42
-============
+Memo of deveopment
+==================
+just memo, NOT WORTH READING
 
 Bug:
-- with Nexus5 keyboard and mouse are very laggy.
-
-- lose USB connection during power-down mode - DONE
-    - USB initialize code in main() causes this - WRONG
-    - Do not power-down during USB connection is active - DONE 11/11
-        (USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection
-        matrix_power_down() matrix.c - 11/23
-
-- When given power only from wall wart adapter
-    - it sleeps. it should not sleep
-    - Configured state without USB connection?
-
-- timer is slow while power down - DONE 11/26
-    - time out interrupt is lost while power down?
-    - interrupt of watchdog timer compensates timer counter(avr/suspend.c)
-
-- USB plug-in fails while BT
-    - it ends in suspend state
-    - maybe, not responsive to host enumeration process due to power-down.
-    - matrix_power_down() only when state is unattached - 11/26
-        - need to observe a while
-- repeated CHARGING/FULL_CHARGED
-    - In LTC sharp pulses are observed.
-    - MCP has no pulse but still has a problem.
-    - needs more wait before read pin state? - NO
-- wrongly suspended when powered from adapter without USB connection - DONE
-    - suspend event may occur when plug into adapter
-    - and never wake until conected to real USB line
-    - without debug print via USB no problem; CSW(wake just after suspend as real USB line)
-    - seems like USB print causes this problem after suspended
-
 - Factory Reset PIO4 doesn't work
     - the reason is unclear - 12/08 NOT LOOK INTO ANY MORE
     - WORKAROUND: use serial pins(3.3V, GND, RX and TX)
@@ -51,11 +21,9 @@ Todo:
     - no buffering. character lost can be caused.
 - LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
 
-- switch BT host connections
 - BT operations
     - disconnect
     - new connection
-    - switch next connection
     - remove connection
 
 - sendchar() in lufa.c block loop   - DONE 11/29
@@ -246,3 +214,42 @@ Done:
 - Under voltage lock out UVLO for protection of Lipo - Lipo has discharge protection at 3.100V    07.01
 - Power saving: HHKB scan, BT radio control - 9h with 850mAh, this is enough   07.01
 - Power selector doesn't work; Q4 MOSFET leaks from Lipo to USB power line. -- use Schottky instead 07/04
+
+- wrongly suspended when powered from adapter without USB connection - DONE
+    - suspend event may occur when plug into adapter
+    - and never wake until conected to real USB line
+    - without debug print via USB no problem; CSW(wake just after suspend as real USB line)
+    - seems like USB print causes this problem after suspended
+
+- lose USB connection during power-down mode - DONE
+    - USB initialize code in main() causes this - WRONG
+    - Do not power-down during USB connection is active - DONE 11/11
+        (USB_DeviceState == USB_DEVICE_Configured) is used to check USB connection
+        matrix_power_down() matrix.c - 11/23
+
+- with Nexus5 keyboard and mouse are very laggy.
+    Not confirmed. 01/15
+
+- switch BT host connections    - CANCEL 01/15
+    - switch next connection
+        cannot switch connection with version 6.15 at least
+
+- When given power only from wall wart adapter  - DONE? not confirmed 01/15
+    - it sleeps. it should not sleep
+    - Configured state without USB connection?
+
+- timer is slow while power down - DONE 11/26
+    - time out interrupt is lost while power down?
+    - interrupt of watchdog timer compensates timer counter(avr/suspend.c)
+
+- repeated CHARGING/FULL_CHARGED    - No longer problem 01/15
+    - In LTC sharp pulses are observed.
+    - MCP has no pulse but still has a problem.
+    - needs more wait before read pin state? - NO
+
+- USB plug-in fails while BT        - No longer problem 01/15
+    - it ends in suspend state
+    - maybe, not responsive to host enumeration process due to power-down.
+    - matrix_power_down() only when state is unattached - 11/26
+        - need to observe a while
+
diff --git a/keyboard/hhkb_rn42/rn42/RN42.txt b/keyboard/hhkb_rn42/rn42/RN42.txt
new file mode 100644
index 0000000000..ace30da4ed
--- /dev/null
+++ b/keyboard/hhkb_rn42/rn42/RN42.txt
@@ -0,0 +1,362 @@
+RN-42 Bluetooth Module Support
+==============================
+Bluetooth controller board works with HHKB Pro2, JP, Type-S and Type-S JP and it supports both USB and Bluetooth as keyboard output protocol. Bluetooth module Roving Networks/Microchip RN-42 is installed on the board.
+
+
+Limitations:
+- short battery life
+- connection switching
+    the module always connects to the last linked device. Remote address setting does not work as expected.
+- HHKB JP requires case modification for power switch and LEDs.
+    without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled.
+- Wiress certification of RN-42
+    Japan, Korea, Taiwan, Europe, FCC, Canada
+    http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
+
+NOTE:
+- Lipo battery is not included. Cannot ship it from Japan due to regulations.
+
+Bugs:
+
+Todos:
+
+
+
+
+
+LED Status
+----------
+Configuring                     10 times per sec
+Startup/configuration timer     2 times per sec
+Discoverable/Inquiring/Idle     once per sec
+Connected                       solid on
+
+
+RN-42 Magic Command
+--------------------
+Magic key combination is 'LShift+RShift' by default in case of HHKB.
+
+Here is help.
+
+    ----- Bluetooth RN-42 Help -----
+    i:       RN-42 info
+    b:       battery voltage
+    Del:     enter/exit RN-42 config mode
+    Slck:    RN-42 initialize
+    p:       pairing
+    u:       toggle Force USB mode
+
+    RN-42 info:             displays information of the module on console.
+    battery voltage:        displays current voltage of battery and uptime.
+    RN-42 initialize:       does factory reset and configures RN-42
+    pairing:                enters Pairing mode.
+    toggle Force USB mode:  switch between USB and Bluetooth
+
+
+RN-42 Config mode
+-----------------
+You can tune/operate RN-42 yourself with config(command) mode.
+
+1. hook up USB cable
+2. run `hid_listen` command  in console
+3. turn on Bluetooth switch
+4. press LShift+RShift+Delete(Fn+~) you will see output like followings:
+
+    Entering config mode ...
+    CMD
+    v
+    Ver 6.15 04/26/2013
+    (c) Roving Networks
+
+5. do config with RN-42 commands. See documentations of RN-42.
+6. to exit also press LShift+RShift+Delete(Fn+~)
+
+    Exiting config mode ...
+    ---
+    END
+
+
+RN-42 Initial Configuration
+---------------------------
+RN-42 is configured as SPP device at factory reset, you need to configure it as HID device. This is needed just once first time.
+
+1. hook up USB cable
+2. run `hid_listen` command  in console
+3. turn on Bluetooth switch
+4. press LShift+RShift+ScrLk(Fn+O) you will see output like followings:
+
+    Entering config mode ...
+    CMD
+    Ver 6.15 04/26/2013
+    (c) Roving Networks
+    ECHO ON
+    SF,1
+    AOK
+    S-,TmkBT
+    AOK
+    SS,Keyboard/Mouse
+    AOK
+    SM,4
+    AOK
+    SW,8000
+    AOK
+    S~,6
+    AOK
+    SH,003C
+    AOK
+    SY,FFF4
+    AOK
+    R,1
+    Reboot!
+    Exiting config mode ...
+
+5. output of command 'X' after cofiguration
+
+    Ver 6.15 04/26/2013
+    (c) Roving Networks
+    ***Settings***
+    BTA=00066667BBE9
+    BTName=TmkBT-BBE9
+    Baudrt(SW4)=115K
+    Mode  =DTR 
+    Authen=1
+    PinCod=1234
+    Bonded=0
+    Rem=NONE SET
+    ***ADVANCED Settings***
+    SrvName= Keyboard/Mouse
+    SrvClass=0000
+    DevClass=1F00
+    InqWindw=0100
+    PagWindw=0100
+    CfgTimer=255
+    StatuStr=NULL
+    HidFlags=3c
+    DTRtimer=8
+    KeySwapr=0
+    ***OTHER Settings***
+    Profile= HID
+    CfgChar= $
+    SniffEna=8000
+    LowPower=0
+    TX Power=fff4
+    IOPorts= 0
+    IOValues=0
+    Sleeptmr=0
+    DebugMod=0
+    RoleSwch=0
+
+
+Switch to USB mode
+------------------
+You can switch between USB and Bluetooth with pressing 'LShift+RShift+u'.
+
+
+Pairing mode
+------------
+This disconnects current connect and enter pairing mode.
+
+
+
+
+For deveropment
+===============
+
+RN-42 Serial Connection
+-----------------------
+UART:           115200bps, 8bit, 1-stopbit, non-parity, no flow control
+SSP:            115200bps, 8bit, 1-stopbit, non-parity, no flow control(via Bluetooth)
+
+To enter command mode disconnect the module from host and type '$$$'.(you will see 'CMD') and type '+' to get local echo. To exit type '---'(you will see 'END').
+
+
+RN-42 Commands
+--------------
+S-,tmkBT            // Device name
+SS,keyboard/mouse   // service name
+SM,4                // Auto Connect DTR mode
+SW,8010             // Sniff enable 0x10*0.625ms=10ms; 50ms is laggish and not much power save
+S~,6                // HID profile
+S~,0                // SPP profile
+SH,003C             // HID register
+SY,0004             // Transmit power
+SC,0000             // COD: 000005C0    (see HID spec/Bluegiga doc)
+SD,05C0             //     bit 12-8         7           6           5-0
+                    //         00101        1           1           0
+                    //         peripheral   pointing    keybaord    joystick, gamepad, ...
+SM,6                // Pairing mode: auto connect
+SM,4                // Master mode: Connection can be controled with GPIO6
+SF,1                // Factroy reset
+R,1                 // reboot
+SR,Z                // removes all remote addresses for reconnecting.
+                    // can be used to connect another host
+SR,I                // registers last inquiry address
+
+
+Operation Modes
+---------------
+SM,3        Auto Connect Master mode
+SM,4        Auto Connect DTR Mode uses GPIO6 to make and break connection(Mode =DTR)
+                confirm: auto connect works and control connection with GPIO6
+SM,5        Auto Connect ANY Mode (Mode =ANY)
+                each time GPIO is set, make inquiry and connect to the first found device
+SM,6        automatically reconnect(Mode =Pair)
+                confirm: auto connect works well but difficult to enter command mode.
+
+
+HID flag register
+-----------------
+SH,0200
+GH
+
+10 0000 0000(0200)  default
+00 0011 1000(0038)  Combo
+|| |  | |\_\____ number of paired devices to which the module can reconnect
+|| |  | \_______ send out reports over UART (0xFF <len> <data>)
+|| \__\_________ descriptor type
+|\______________ toggle virtual keyboard on iOS when first connected
+\_______________ Force HID mode if GPIO11 is high on power-up
+
+    Descriptor type:
+    0000:   keybaord
+    0001:   Game Pad
+    0010:   Mouse
+    0011:   Combo
+    0100:   Joystick
+    1xxx:   reserved
+
+
+Out report - Indicator
+----------------------
+0xFE 0x02 0x01 <LED_state>
+
+
+Apple iOS
+---------
+Keyboard can be used with iPhone, but mouse cannot.
+
+
+Android
+-------
+3.7.1.5 Note: To connect with Android phone the modules must wake up 11ms every 2.5seconds.
+
+
+Power Management
+----------------
+Inquiry and Page window     Idle or Active  (3.1.1)
+    Downside: delay in discovery or connection time
+    SI,         // set inquiry scan window(discovery) on/off duty?
+    SJ,         // set page scan window(connection)
+    This reduces averaege power >20mA to 5mA(3mA in Sniff mode)
+
+Sniff mode                  Transmit
+    Sniff mode is disabled by default and radio is active continuously when connected.(25-30mA)
+    In Sniff mode the radio wakes up intermittently and sleeps in very low power mode.(2mA)
+    SW,<val>    // set interval timer(*0.625ms) 0000-7FFF
+
+Deep sleep                  Idle            (3.1.2)
+    In this mode the module shuts down completly and only draws about 300uA. To enable this set the most signifant bit(0x8000) of Sniff interaval timer.
+    SW,8320     // deep sleep enable(interval=0x320*0.625=500ms)
+    In normal sleep the firmware is still running in idle mode, and wakes up about 20 times per second to check ports, update LEDs, etc. During deep sleep, the firmware actually stops runnig some tasks and the LEDs only update about once per second.
+    To wake from deep sleep there are three ways: (in worst case wake up takes 5ms)
+        *send a charactor to the UART(first charactor will be lost)
+        *toggle CTS low to high and wait 5ms
+        *wake automatically every slot time(<val>*0.625ms)
+    Once the radio is awake it stay active for exactly 1 second of inactivity and then sleeps again.
+    Downside: latency and data loss
+
+Disable Output driver       Idle or Active  (3.1.3)
+    S%,1000     // set all GPIO pins(0-11) to inputs.
+
+Lower Transmit Power        Idle or Active  (3.1.4)
+    SY,<hex>    // transmit power setting(takes effect after a power cycle and reboot)
+    Downside: reducing effective range
+
+
+Optimizig for Latency
+---------------------
+By default the firmware is optimized for throughput.
+SQ,16           // set latency bit
+SQ,0            // unset latency bit
+
+
+Configuration timer settings
+----------------------------
+Remote configuration is used for the module to be configured with various commands over Bluetooth(SPP profile only?).
+
+The module has remote configuration timer to allow remote configuration over Bluetooth after power up in Slave mode. In Master modes the remote configuration timer is set to 0(no remote configuration). (In Trigger Master mode the timer is used as an idle timer to break the connection after time expires with no charactors receive.)
+    ST,0        // no remote, no local when connected
+    ST,<1-252>  // local and remote with timeout in seconds from power up
+    ST,253      // local only       without timeout
+    ST,254      // remote only      without timeout
+    ST,255      // local and remote without timeout
+
+
+Commands
+--------
+S7,                     7bit mode
+SA,                     Authenticaiton
+SB,                     Send break
+SC,                     Service class
+SD,                     Device class
+SM,<val>                Operation mode
+SP,<string>             Pin code(alpahnumeric)
+SQ,<mask>               Special configuration(GPIO, discovery mode, low latency, reboot, UART)
+SR,<hex>                Store remote address
+SR,Z                    Erase all address
+SS,<string>             Set service name(1-20)**
+ST,<val>                Remote configuration timer(Master:0, Slave:0-255, Triger:as idle timer)
+SU,<val>                UART baud rate
+SW,<val>                low-power sniff mode** deep sleep and wake up every 625us * <val>
+SX,<0|1>                bonding enable  only acceps device that matches the stored address
+SY,<hex>                power setting**
+SZ,<val>                non-standard raw baud rate  <val>=baud*0.004096
+S~,<val>                Profile     0:SPP, 5:APL, 6:HID
+S-,<string>             Device name     -15 alphanumeric charactors
+S?,<0|1>                role switch enable
+S$,<char>               command mode char
+$|,<hex>                low-power connect mode  deep sleep/active(discoverable and connectable) cycle
+D                       display basic setting
+E                       display extended setting
+GB                      display the device's Bluetooth address
+GF                      display Bluetooth address of connected device
+GK                      show connection status
+GR                      show remote address for reconnecting
+G&                      show GPIO pin
+G<char>                 show stored setting
++                       toggle local echo on/off
+&                       show GPIO 3,4,6,7(DIP switch)
+C                       connect to stored remote address
+C,<address>             connect last address
+CFI                     connect and go into fast data mode
+CFR                     connect and go into fast data mode
+CT,<address>,<val>      connect to the address and disconnect after val?
+F,1                     fast data mod:
+H                       display help
+I,<time>,<cod>          inquiry scan with <cod>
+IN,<time>,<cod>         inquiry scan with <cod>, return without BT name
+IR                      inquiry scan with 0055AA
+IS                      inquiry scan with 001F00
+J                       hide pin code
+K,                      kill    disconnects current connection
+L                       link quality
+M                       show modem signlal status
+O                       display other settings
+P,<char>                pass through?
+Q                       quiet mode  make the module not discoverable
+Q,0                     discoverable and connectable
+Q,1                     not discoverable and not connectable
+Q,2                     not discoverable and connectable
+Q,?                     display current quiet mode
+R,1                     reboot
+T,<0|1>                 pass received data while in command mode
+U,<baud>,<parity>       change UART setting tentatively
+V                       display firmware version
+W                       wake from quiet mode    enable discovery and connection
+Z                       deep sleep mode(<2mA)
+
+
+Reset to Factory Default
+------------------------
+SF,1
+R,1

From a7a808795e6a41114f8f026d589432ca3e0d25cb Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 15 Jan 2015 13:06:43 -0500
Subject: [PATCH 57/95] Update README.md

---
 keyboard/planck/README.md | 130 ++------------------------------------
 1 file changed, 5 insertions(+), 125 deletions(-)

diff --git a/keyboard/planck/README.md b/keyboard/planck/README.md
index 510cb5c8b6..593620f029 100644
--- a/keyboard/planck/README.md
+++ b/keyboard/planck/README.md
@@ -1,16 +1,9 @@
-GH60 keyboard firmware
+Planck keyboard firmware
 ======================
-DIY compact keyboard designed and run by komar007 and Geekhack community.
-
-- Both Rev.A and Rev.B PCB are supported by one firmware binary(issue #64)
-
-## GH60 Resources
-- [KOMAR's project page](http://blog.komar.be/projects/gh60-programmable-keyboard/)
-- [Prototyping](http://geekhack.org/index.php?topic=34959.0)
-- [Rev.A PCB test](http://geekhack.org/index.php?topic=37570.0)
-- [Rev.B PCB test](http://geekhack.org/index.php?topic=50685.0)
-- [Group buy](http://geekhack.org/index.php?topic=41464.0)
+DIY/Assembled compact ortholinear keyboard by [Ortholinear Keyboards](http://ortholinearkeyboards.com).
 
+## Notable TMK forks (which some of the keymap files are from)
+- [Shane's Fork](https://github.com/shanecelis/tmk_keyboard/tree/master/keyboard/planck)
 
 ## Build
 Move to this directory then just run `make` like:
@@ -25,117 +18,4 @@ Several version of keymap are available in advance but you are recommended to de
 
 To build firmware binary hex file with a certain keymap just do `make` with `KEYMAP` option like:
 
-    $ make KEYMAP=[poker|poker_set|poker_bit|plain|hasu|spacefn|hhkb|<name>]
-
-
-### 1  Poker
-[keymap_poker.c](keymap_poker.c) emulates original Poker layers
-while both [keymap_poker_bit.c](keymap_poker_bit.c) and [keymap_poker_set.c](keymap_poker_set.c) implements same layout in different way and they fix a minor issue of original Poker and enhance arrow keys.
-
-    Fn + Esc = `
-    Fn + {left, down, up, right}  = {home, pgdown, pgup, end}
-
-#### 1.0 Default layer
-    ,-----------------------------------------------------------.
-    |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
-    |-----------------------------------------------------------|
-    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
-    |-----------------------------------------------------------|
-    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
-    |-----------------------------------------------------------|
-    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
-    |-----------------------------------------------------------|
-    |Ctrl|Gui |Alt |      Space             |Fn  |Gui |App |Ctrl|
-    `-----------------------------------------------------------'
-#### 1.1 Poker Fn layer
-    ,-----------------------------------------------------------.
-    |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|       |
-    |-----------------------------------------------------------|
-    |     |FnQ| Up|   |   |   |   |   |   |Cal|   |Hom|Ins|     |
-    |-----------------------------------------------------------|
-    |      |Lef|Dow|Rig|   |   |Psc|Slk|Pau|   |Tsk|End|        |
-    |-----------------------------------------------------------|
-    |        |Del|   |Web|Mut|VoU|VoD|   |PgU|PgD|Del|   Up     |
-    |-----------------------------------------------------------|
-    |    |    |    |         FnS            |Fn  |Left|Down|Righ|
-    `-----------------------------------------------------------'
-
-
-### 2. Plain
-Without any Fn layer this will be useful if you want to use key remapping tool like AHK on host.
-See [keymap_plain.c](keymap_plain.c) for detail.
-
-#### 1.0 Plain Default layer
-    ,-----------------------------------------------------------.
-    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
-    |-----------------------------------------------------------|
-    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
-    |-----------------------------------------------------------|
-    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
-    |-----------------------------------------------------------|
-    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
-    |-----------------------------------------------------------|
-    |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |Ctrl|
-    `-----------------------------------------------------------'
-
-
-### 3. Hasu
-This is my favorite keymap with HHKB Fn, Vi cursor and Mousekey layer. See [keymap_hasu.c](keymap_hasu.c) for detail.
-
-
-### 4. SpaceFN
-This layout proposed by spiceBar uses space bar to change layer with using Dual role key technique. See [keymap_spacefn.c](keymap_spacefn.c) and [SpaceFN discussion](http://geekhack.org/index.php?topic=51069.0).
-
-#### 4.0 Default layer
-    ,-----------------------------------------------------------.
-    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
-    |-----------------------------------------------------------|
-    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
-    |-----------------------------------------------------------|
-    |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
-    |-----------------------------------------------------------|
-    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
-    |-----------------------------------------------------------|
-    |Ctrl|Gui |Alt |      Space/Fn          |Alt |Gui |App |Ctrl|
-    `-----------------------------------------------------------'
-#### 4.1 SpaceFN layer
-    ,-----------------------------------------------------------.
-    |`  | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
-    |-----------------------------------------------------------|
-    |     |   |   |   |   |   |   |Hom|Up |End|Psc|Slk|Pau|Ins  |
-    |-----------------------------------------------------------|
-    |      |   |   |   |   |   |PgU|Lef|Dow|Rig|   |   |        |
-    |-----------------------------------------------------------|
-    |        |   |   |   |   |Spc|PgD|`  |~  |   |   |          |
-    |-----------------------------------------------------------|
-    |    |    |    |            Fn          |    |    |    |    |
-    `-----------------------------------------------------------'
-
-
-### 5. HHKB
-[keymap_hhkb.c](keymap_hhkb.c) emulates original HHKB layers.
-#### 5.0: Default layer
-    ,-----------------------------------------------------------.
-    |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|  `|
-    |-----------------------------------------------------------|
-    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Bspc |
-    |-----------------------------------------------------------|
-    |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Return  |
-    |-----------------------------------------------------------|
-    |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Fn |
-    |-----------------------------------------------------------|
-    |    |Gui |Alt |      Space             |    |Alt |Gui |    |
-    `-----------------------------------------------------------'
-#### 5.1: HHKB Fn layer
-    ,-----------------------------------------------------------.
-    |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-    |-----------------------------------------------------------|
-    |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |     |
-    |-----------------------------------------------------------|
-    |      |VoD|VoU|Mut|Ejc|   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
-    |-----------------------------------------------------------|
-    |        |   |   |   |   |   |  +|  -|End|PgD|Dow|      |   |
-    |-----------------------------------------------------------|
-    |    |    |    |                        |    |    |    |    |
-    `-----------------------------------------------------------'
-
+    $ make KEYMAP=[<name>]

From 3e88e8b761f8f8d8c5155fed3f064cc1bf207dab Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Fri, 16 Jan 2015 05:22:29 +0900
Subject: [PATCH 58/95] hhkb: Fix layer stuck of keymap_hasu

- In mouse key layer with holding semicolon, press Fn0, release
  semicolon and release Fn0 now layer 1 is stuck.
---
 keyboard/hhkb/keymap_hasu.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/keyboard/hhkb/keymap_hasu.c b/keyboard/hhkb/keymap_hasu.c
index 8379c84f52..433f9cb270 100644
--- a/keyboard/hhkb/keymap_hasu.c
+++ b/keyboard/hhkb/keymap_hasu.c
@@ -27,7 +27,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
            TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSPC, \
            LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   FN3, QUOT,FN6, \
            FN7, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, FN2, RSFT,FN1, \
-                LGUI,LALT,          FN4,                FN5, FN5),
+                LGUI,LALT,          FN4,                FN5, RGUI),
 
     /* Layer 1: HHKB mode[HHKB Fn]
      * ,-----------------------------------------------------------.
@@ -47,7 +47,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
            CAPS,NO,  NO,  NO,  NO,  NO,  NO,  NO,  PSCR,SLCK,PAUS, UP,  NO,  BSPC, \
            LCTL,VOLD,VOLU,MUTE,NO,  NO,  PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
            LSFT,NO,  NO,  NO,  NO,  NO,  PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
-                LGUI,LALT,          SPC,                RALT,RGUI),
+                LGUI,LALT,          TRNS,               RALT,RGUI),
 
     /* Layer 2: Vi mode[Slash]
      * ,-----------------------------------------------------------.
@@ -66,7 +66,7 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
            TAB, HOME,PGDN,UP,  PGUP,END, HOME,PGDN,PGUP,END, NO,  NO,  NO,  BSPC, \
            LCTL,NO,  LEFT,DOWN,RGHT,NO,  LEFT,DOWN,UP,  RGHT,NO,  NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, TRNS,RSFT,NO, \
+           LSFT,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \
                 LGUI,LALT,          SPC,                RALT,RGUI),
 
     /* Layer 3: Mouse mode(IJKL)[Semicolon]
@@ -81,16 +81,16 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * `-----------------------------------------------------------'
      *      |Gui |Alt  |          Mb1          |Fn   |Fn |
      *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
+     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
      */
     [3] = \
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, \
-           LCTL,ACL0,ACL1,ACL2,ACL2,NO,  NO,  MS_L,MS_D,MS_R,TRNS,NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,BTN4,BTN5,NO,  RSFT,NO, \
+           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
+           LCTL,ACL0,ACL1,ACL2,ACL2,NO,  NO,  MS_L,MS_D,MS_R,FN3, NO,  ENT, \
+           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,TRNS, \
                 LGUI,LALT,          BTN1,               TRNS,TRNS),
 
-    /* Layer 5: Mouse mode(IJKL)[Space]
+    /* Layer 4: Mouse mode(IJKL)[Space]
      * ,-----------------------------------------------------------.
      * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
      * |-----------------------------------------------------------|
@@ -102,13 +102,13 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * `-----------------------------------------------------------'
      *      |Gui |Alt  |          Mb1          |Fn   |Fn |
      *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel8
+     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
      */
     [4] = \
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  WH_L,WH_D,MS_U,WH_U,WH_R,WBAK,WFWD,FN8, \
+           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
            LCTL,VOLD,VOLU,MUTE,NO,  NO,  NO,  MS_L,MS_D,MS_R,BTN1,NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,BTN4,BTN5,NO,  RSFT,NO, \
+           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,TRNS, \
                 LGUI,LALT,          TRNS,               TRNS,TRNS),
 
 #if 0
@@ -127,9 +127,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel 
      */
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           TAB, NO,  NO,  NO,  NO,  NO,  WH_L,WH_D,WH_U,WH_R,NO,  NO,  NO,  BSPC, \
+           TAB, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,WH_U,RGHT,NO,  NO,  NO,  BSPC, \
            LCTL,NO,  ACL0,ACL1,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,BTN4,BTN5,SLSH,RSFT,NO, \
+           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \
                 LGUI,LALT,          BTN1,               RALT,TRNS),
 
     /* Layer4: Mouse mode(HJKL)[Space]
@@ -147,9 +147,9 @@ const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
      * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel 
      */
     KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  WH_L,WH_D,WH_U,WH_R,NO,  WBAK,WFWD,FN8, \
+           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,WH_U,RGHT,NO,  FN9, FN10,FN8, \
            LCTL,NO,  ACL0,ACL1,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,BTN1,NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,BTN4,BTN5,NO,  RSFT,NO, \
+           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,NO, \
                 LGUI,LALT,          TRNS,               RALT,RGUI),
 #endif
 #if 0
@@ -201,10 +201,12 @@ const uint16_t fn_actions[] PROGMEM = {
     [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH),          // Cursor layer with Slash*
     [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN),           // Mousekey layer with Semicolon*
     [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC),            // Mousekey layer with Space
-    [5] = ACTION_LAYER_MOMENTARY(3),                  // Mousekey layer
+    [5] = ACTION_LAYER_MOMENTARY(4),                  // Mousekey layer(IJKL)
     [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT),      // RControl with tap Enter
     [7] = ACTION_MODS_ONESHOT(MOD_LSFT),              // Oneshot Shift
     [8] = ACTION_MACRO(ALT_TAB),                      // Application switching
+    [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT),
+   [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT),
 
 //  [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC),        // LControl with tap Backspace
 //  [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC),         // LControl with tap Esc

From ce6698865046c2d5e5fae73a74323048036e7d44 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Fri, 16 Jan 2015 08:26:59 +0900
Subject: [PATCH 59/95] hhkb_rn42: Move doc

---
 keyboard/hhkb_rn42/{ => rn42}/PowerSave.txt | 47 ++-------------------
 1 file changed, 4 insertions(+), 43 deletions(-)
 rename keyboard/hhkb_rn42/{ => rn42}/PowerSave.txt (71%)

diff --git a/keyboard/hhkb_rn42/PowerSave.txt b/keyboard/hhkb_rn42/rn42/PowerSave.txt
similarity index 71%
rename from keyboard/hhkb_rn42/PowerSave.txt
rename to keyboard/hhkb_rn42/rn42/PowerSave.txt
index 9aa89f4416..8aea1c6dd2 100644
--- a/keyboard/hhkb_rn42/PowerSave.txt
+++ b/keyboard/hhkb_rn42/rn42/PowerSave.txt
@@ -1,11 +1,9 @@
-RN-42
-=====
+Power Saving
+============
 
 
-12/11
-Power Comsumption
-MCU+HHKB
---------
+MCU+HHKB Power Comsumption
+--------------------------
 Battery drive:
     idle    18.9mA
     active  35.8mA
@@ -76,40 +74,3 @@ S%,1000         status led and connection control don't work
                 GPIO5: status LED
                 GPIO6: Connection control
                 GPIO2: linked status
-
-
-
-
-
-Ver 6.15 04/26/2013
-(c) Roving Networks
-***Settings***
-BTA=00066667BBE9
-BTName=tmkBT-BBE9
-Baudrt(SW4)=115K
-Mode  =DTR
-Authen=1
-Bonded=0
-Rem=001BDC06415B
-***ADVANCED Settings***
-SrvName= keyboard/mouse
-SrvClass=0000
-DevClass=1F00
-InqWindw=0012
-PagWindw=0012
-CfgTimer=255
-StatuStr=NULL
-HidFlags=3c
-DTRtimer=8
-KeySwapr=0
-***OTHER Settings***
-Profile= HID
-CfgChar= $
-SniffEna=8010
-LowPower=0          S|,
-TX Power=fff4       SY,
-IOPorts= 0
-IOValues=0
-Sleeptmr=0
-DebugMod=0
-RoleSwch=0

From 83a3d7a3da505b4932b183a719700f88aeaf9dde Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 15 Jan 2015 19:58:38 -0500
Subject: [PATCH 60/95] Update README.md

---
 keyboard/planck/README.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/keyboard/planck/README.md b/keyboard/planck/README.md
index 593620f029..ddd080ff2f 100644
--- a/keyboard/planck/README.md
+++ b/keyboard/planck/README.md
@@ -4,6 +4,7 @@ DIY/Assembled compact ortholinear keyboard by [Ortholinear Keyboards](http://ort
 
 ## Notable TMK forks (which some of the keymap files are from)
 - [Shane's Fork](https://github.com/shanecelis/tmk_keyboard/tree/master/keyboard/planck)
+- [Pierre's Fork](https://github.com/pcarrier/tmk_keyboard/blob/pcarrier/planck/keyboard/gh60/keymap_planck.c)
 
 ## Build
 Move to this directory then just run `make` like:

From 099701dd3130d433244b3a4102f36f547aec25ae Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Fri, 16 Jan 2015 10:21:18 +0900
Subject: [PATCH 61/95] hhkb: Integrate RN-42 support, remove hhkb_rn42

---
 keyboard/hhkb/Makefile.nodebug                | 141 ---------
 .../Makefile => hhkb/Makefile.rn42}           |  22 +-
 keyboard/hhkb/README.md                       |  17 +-
 .../config.h => hhkb/config_rn42.h}           |   0
 keyboard/hhkb/hhkb_avr.h                      |  28 +-
 keyboard/hhkb/matrix.c                        |  27 +-
 .../hhkb/{ => not_supported}/Makefile.iwrap   |   0
 .../hhkb/{ => not_supported}/Makefile.vusb    |   0
 .../hhkb/{ => not_supported}/config_iwrap.h   |   0
 .../hhkb/{ => not_supported}/config_vusb.h    |   0
 keyboard/hhkb/{ => not_supported}/iwrap.txt   |   0
 keyboard/hhkb/{ => not_supported}/usbconfig.h |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42.mk          |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/MEMO.txt    |   0
 .../{hhkb_rn42 => hhkb}/rn42/PowerSave.txt    |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/RN42.txt    |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/battery.c   |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/battery.h   |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/main.c      |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/rn42.c      |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/rn42.h      |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/rn42_task.c |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/rn42_task.h |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/suart.S     |   0
 keyboard/{hhkb_rn42 => hhkb}/rn42/suart.h     |   0
 keyboard/hhkb_rn42/hhkb_avr.h                 | 166 -----------
 keyboard/hhkb_rn42/keymap_common.c            |  33 --
 keyboard/hhkb_rn42/keymap_common.h            |  84 ------
 keyboard/hhkb_rn42/keymap_hasu.c              | 282 ------------------
 keyboard/hhkb_rn42/keymap_jp.c                |  50 ----
 keyboard/hhkb_rn42/led.c                      |  33 --
 keyboard/hhkb_rn42/matrix.c                   | 190 ------------
 32 files changed, 69 insertions(+), 1004 deletions(-)
 delete mode 100644 keyboard/hhkb/Makefile.nodebug
 rename keyboard/{hhkb_rn42/Makefile => hhkb/Makefile.rn42} (95%)
 rename keyboard/{hhkb_rn42/config.h => hhkb/config_rn42.h} (100%)
 rename keyboard/hhkb/{ => not_supported}/Makefile.iwrap (100%)
 rename keyboard/hhkb/{ => not_supported}/Makefile.vusb (100%)
 rename keyboard/hhkb/{ => not_supported}/config_iwrap.h (100%)
 rename keyboard/hhkb/{ => not_supported}/config_vusb.h (100%)
 rename keyboard/hhkb/{ => not_supported}/iwrap.txt (100%)
 rename keyboard/hhkb/{ => not_supported}/usbconfig.h (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42.mk (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/MEMO.txt (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/PowerSave.txt (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/RN42.txt (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/battery.c (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/battery.h (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/main.c (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/rn42.c (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/rn42.h (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/rn42_task.c (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/rn42_task.h (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/suart.S (100%)
 rename keyboard/{hhkb_rn42 => hhkb}/rn42/suart.h (100%)
 delete mode 100644 keyboard/hhkb_rn42/hhkb_avr.h
 delete mode 100644 keyboard/hhkb_rn42/keymap_common.c
 delete mode 100644 keyboard/hhkb_rn42/keymap_common.h
 delete mode 100644 keyboard/hhkb_rn42/keymap_hasu.c
 delete mode 100644 keyboard/hhkb_rn42/keymap_jp.c
 delete mode 100644 keyboard/hhkb_rn42/led.c
 delete mode 100644 keyboard/hhkb_rn42/matrix.c

diff --git a/keyboard/hhkb/Makefile.nodebug b/keyboard/hhkb/Makefile.nodebug
deleted file mode 100644
index 578ba70c45..0000000000
--- a/keyboard/hhkb/Makefile.nodebug
+++ /dev/null
@@ -1,141 +0,0 @@
-#----------------------------------------------------------------------------
-# On command line:
-#
-# make all = Make software.
-#
-# make clean = Clean out built project files.
-#
-# make coff = Convert ELF to AVR COFF.
-#
-# make extcoff = Convert ELF to AVR Extended COFF.
-#
-# make program = Download the hex file to the device.
-#                Please customize your programmer settings(PROGRAM_CMD)
-#
-# make teensy = Download the hex file to the device, using teensy_loader_cli.
-#               (must have teensy_loader_cli installed).
-#
-# make dfu = Download the hex file to the device, using dfu-programmer (must
-#            have dfu-programmer installed).
-#
-# make flip = Download the hex file to the device, using Atmel FLIP (must
-#             have Atmel FLIP installed).
-#
-# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
-#               (must have dfu-programmer installed).
-#
-# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
-#                (must have Atmel FLIP installed).
-#
-# make debug = Start either simulavr or avarice as specified for debugging, 
-#              with avr-gdb or avr-insight as the front end for debugging.
-#
-# make filename.s = Just compile filename.c into the assembler code only.
-#
-# make filename.i = Create a preprocessed source file for use in submitting
-#                   bug reports to the GCC project.
-#
-# To rebuild project do "make clean" then "make all".
-#----------------------------------------------------------------------------
-
-# Target file name (without extension).
-TARGET = hhkb_lufa
-
-# Directory common source filess exist
-TOP_DIR = ../..
-
-# Directory keyboard dependent files exist
-TARGET_DIR = .
-
-
-# List C source files here. (C dependencies are automatically generated.)
-SRC +=	keymap_common.c \
-	matrix.c \
-	led.c
-
-ifdef KEYMAP
-    SRC := keymap_$(KEYMAP).c $(SRC)
-else
-    SRC := keymap_hasu.c $(SRC)
-endif
-
-CONFIG_H = config.h
-
-
-# MCU name
-# PJRC Teensy++ 2.0
-#MCU = at90usb1286
-# TMK Alt Controller or PJRC Teensy 2.0
-MCU = atmega32u4
-
-# Processor frequency.
-#     This will define a symbol, F_CPU, in all source code files equal to the
-#     processor frequency in Hz. You can then use this symbol in your source code to
-#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
-#     automatically to create a 32-bit value in your source code.
-#
-#     This will be an integer division of F_USB below, as it is sourced by
-#     F_USB after it has run through any CPU prescalers. Note that this value
-#     does not *change* the processor frequency - it should merely be updated to
-#     reflect the processor speed set externally so that the code can use accurate
-#     software delays.
-F_CPU = 16000000
-
-
-#
-# LUFA specific
-#
-# Target architecture (see library "Board Types" documentation).
-ARCH = AVR8
-
-# Input clock frequency.
-#     This will define a symbol, F_USB, in all source code files equal to the
-#     input clock frequency (before any prescaling is performed) in Hz. This value may
-#     differ from F_CPU if prescaling is used on the latter, and is required as the
-#     raw input clock is fed directly to the PLL sections of the AVR for high speed
-#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
-#     at the end, this will be done automatically to create a 32-bit value in your
-#     source code.
-#
-#     If no clock division is performed on the input clock inside the AVR (via the
-#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
-F_USB = $(F_CPU)
-
-# Interrupt driven control endpoint task
-#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
-
-
-# Boot Section Size in *bytes*
-#   Teensy halfKay   512
-#   Teensy++ halfKay 1024
-#   Atmel DFU loader 4096	(TMK Alt Controller)
-#   LUFA bootloader  4096
-#   USBaspLoader     2048
-OPT_DEFS += -DBOOTLOADER_SIZE=4096
-
-
-# Build Options
-#   comment out to disable the options.
-#
-BOOTMAGIC_ENABLE = yes		# Virtual DIP switch configuration
-MOUSEKEY_ENABLE = yes		# Mouse keys
-EXTRAKEY_ENABLE = yes		# Audio control and System control
-#CONSOLE_ENABLE = yes		# Console for debug
-COMMAND_ENABLE = yes    	# Commands for debug and configuration
-NKRO_ENABLE = yes		# USB Nkey Rollover
-KEYMAP_SECTION_ENABLE = yes	# fixed address keymap for keymap editor
-
-
-# Search Path
-VPATH += $(TARGET_DIR)
-VPATH += $(TOP_DIR)
-
-include $(TOP_DIR)/protocol/lufa.mk
-include $(TOP_DIR)/common.mk
-include $(TOP_DIR)/rules.mk
-
-debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
-debug-on: all
-
-debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
-debug-off: all
diff --git a/keyboard/hhkb_rn42/Makefile b/keyboard/hhkb/Makefile.rn42
similarity index 95%
rename from keyboard/hhkb_rn42/Makefile
rename to keyboard/hhkb/Makefile.rn42
index 3d9a602a58..b1eacd070f 100644
--- a/keyboard/hhkb_rn42/Makefile
+++ b/keyboard/hhkb/Makefile.rn42
@@ -39,7 +39,7 @@
 #----------------------------------------------------------------------------
 
 # Target file name (without extension).
-TARGET = hhkb_lufa
+TARGET = hhkb_rn42
 
 # Directory common source filess exist
 TOP_DIR = ../..
@@ -53,13 +53,10 @@ SRC +=	keymap_common.c \
 	matrix.c \
 	led.c
 
-CONFIG_H = config.h
+CONFIG_H = config_rn42.h
 
 
 # MCU name
-# PJRC Teensy++ 2.0
-#MCU = at90usb1286
-# TMK Alt Controller or PJRC Teensy 2.0
 MCU = atmega32u4
 
 # Processor frequency.
@@ -121,11 +118,6 @@ COMMAND_ENABLE = yes    	# Commands for debug and configuration
 #HHKB_JP = yes			# HHKB JP support
 
 
-ifdef HHKB_JP
-    OPT_DEFS += -DHHKB_JP
-endif
-
-
 #
 # Keymap file
 #
@@ -134,12 +126,17 @@ ifdef KEYMAP
 else
     ifdef HHKB_JP
     	SRC := keymap_jp.c $(SRC)
-    else
-	SRC := keymap_hasu.c $(SRC)
+    else 
+    	SRC := keymap_hhkb.c $(SRC)
     endif
 endif
 
 
+ifneq (, $(or $(findstring keymap_jp.c, $(SRC)), $(findstring yes, $(HHKB_JP))))
+    OPT_DEFS += -DHHKB_JP
+endif
+
+
 # Search Path
 VPATH += $(TARGET_DIR)
 VPATH += $(TOP_DIR)
@@ -154,4 +151,5 @@ debug-on: EXTRAFLAGS += -DDEBUG -DDEBUG_ACTION
 debug-on: all
 
 debug-off: EXTRAFLAGS += -DNO_DEBUG -DNO_PRINT
+debug-off: OPT_DEFS := $(filter-out -DCONSOLE_ENABLE,$(OPT_DEFS))
 debug-off: all
diff --git a/keyboard/hhkb/README.md b/keyboard/hhkb/README.md
index f9fd165076..fcd72e1941 100644
--- a/keyboard/hhkb/README.md
+++ b/keyboard/hhkb/README.md
@@ -10,11 +10,17 @@ See [this thread][AltController] in geekhack.org.
 [AltController]: http://geekhack.org/index.php?topic=12047.0
 
 
+## Update
+* Bluetooth module RN-42 is supported.(2015/01)
+* V-USB and iWRAP are no longer supported now, but still it'll works with a little fix. See not_supported directory.(2015/01)
+
+
 ##Features
 * Customizable keymap
 * More keymap layers(more Fn keys)
 * Mouse keys
 * USB NKRO
+* Bluetooth(RN-42)
 
 See README of [tmk_keyboard] for more.
 
@@ -50,8 +56,9 @@ If you use other than **TMK Alt Controller Board** set proper `MCU`, `BOOTLOADER
 ### Build 
 Several version of keymap are available in advance but you are recommended to define your favorite layout yourself. Just `make` with `KEYMAP` option like:
 
-    $ make KEYMAP=[hasu|hhkb|spacefn|<name>]
-    $ make -f Makefile.jp KEYMAP=[jp|<name>]        # for HHKB JP
+    $ make -f Makefile.<jp|pjrc|rn42> KEYMAP=(hasu|hhkb|spacefn|<name>)
+
+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**.
 
 
 ### Program
@@ -59,13 +66,11 @@ First, push reset button on board to start bootloader.
 
 This command programs the controller with [dfu-programmer] if the tool is installed and configured properly.
 
-    $ make dfu
-    $ make -f Makefile.jp dfu       # for HHKB JP
+    $ make -f Makefile.<variant> KEYMAP=<name> dfu
 
 Or you can also use [FLIP] command to program. Also the tool should be installed and configured properly. FLIP GUI application is also available.
 
-    $ make flip
-    $ make -f Makefile.jp flip      # for HHKB JP
+    $ make -f Makefile.<variant> KEYMAP=<name> flip
 
 Use [Teensy Loader] if your controller is Teensy/Teensy++.
 
diff --git a/keyboard/hhkb_rn42/config.h b/keyboard/hhkb/config_rn42.h
similarity index 100%
rename from keyboard/hhkb_rn42/config.h
rename to keyboard/hhkb/config_rn42.h
diff --git a/keyboard/hhkb/hhkb_avr.h b/keyboard/hhkb/hhkb_avr.h
index b7bd507b5d..7ea6322c73 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)); }
 static inline bool KEY_STATE(void) { return (PIND & (1<<7)); }
 static inline void KEY_PREV_ON(void) { (PORTB |=  (1<<7)); }
 static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); }
+#ifdef HHKB_POWER_SAVING
+static inline void KEY_POWER_ON(void) {
+    DDRB = 0xFF; PORTB = 0x40;          // change pins output
+    DDRD |= (1<<4); PORTD |= (1<<4);    // MOS FET switch on
+    /* Without this wait you will miss or get false key events. */
+    _delay_ms(5);                       // wait for powering up
+}
+static inline void KEY_POWER_OFF(void) {
+    /* input with pull-up consumes less than without it when pin is open. */
+    DDRB = 0x00; PORTB = 0xFF;          // change pins input with pull-up
+    DDRD |= (1<<4); PORTD &= ~(1<<4);   // MOS FET switch off
+}
+static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
+#else
 static inline void KEY_POWER_ON(void) {}
 static inline void KEY_POWER_OFF(void) {}
+static inline bool KEY_POWER_STATE(void) { return true; }
+#endif
 static inline void KEY_INIT(void)
 {
+    /* row,col,prev: output */
     DDRB  = 0xFF;
-    PORTB = 0x00;
+    PORTB = 0x40;   // unable
+    /* key: input with pull-up */
     DDRD  &= ~0x80;
-    PORTD |= 0x80;
-    /* keyswitch board power on */
-    DDRD  |=  (1<<4);
-    PORTD |=  (1<<4);
+    PORTD |=  0x80;
 #ifdef HHKB_JP
     /* row extention for HHKB JP */
     DDRC  |= (1<<6|1<<7);
@@ -59,6 +74,8 @@ static inline void KEY_INIT(void)
 #endif
     KEY_UNABLE();
     KEY_PREV_OFF();
+
+    KEY_POWER_OFF();
 }
 static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
 {
@@ -98,6 +115,7 @@ static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
 #define KEY_PREV_OFF()          (PORTE &= ~(1<<7))
 #define KEY_POWER_ON()
 #define KEY_POWER_OFF()
+#define KEY_POWER_STATE()       true
 
 
 #else
diff --git a/keyboard/hhkb/matrix.c b/keyboard/hhkb/matrix.c
index b0af4baa52..fb96997944 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/>.
 #include "timer.h"
 #include "matrix.h"
 #include "hhkb_avr.h"
+#include <avr/wdt.h>
+#include "suspend.h"
+#include "lufa.h"
 
 
+// matrix power saving
+#define MATRIX_POWER_SAVE       10000
+static uint32_t matrix_last_modified = 0;
+
 // matrix state buffer(1:on, 0:off)
 static matrix_row_t *matrix;
 static matrix_row_t *matrix_prev;
@@ -72,7 +79,8 @@ uint8_t matrix_scan(void)
     matrix_prev = matrix;
     matrix = tmp;
 
-    KEY_POWER_ON();
+    // power on
+    if (!KEY_POWER_STATE()) KEY_POWER_ON();
     for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
         for (uint8_t col = 0; col < MATRIX_COLS; col++) {
             KEY_SELECT(row, col);
@@ -126,8 +134,16 @@ uint8_t matrix_scan(void)
             // This takes 25us or more to make sure KEY_STATE returns to idle state.
             _delay_us(75);
         }
+        if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32();
+    }
+    // power off
+    if (KEY_POWER_STATE() &&
+            (USB_DeviceState == DEVICE_STATE_Suspended ||
+             USB_DeviceState == DEVICE_STATE_Unattached ) &&
+            timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) {
+        KEY_POWER_OFF();
+        suspend_power_down();
     }
-    KEY_POWER_OFF();
     return 1;
 }
 
@@ -165,3 +181,10 @@ void matrix_print(void)
         xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row)));
     }
 }
+
+void matrix_power_up(void) {
+    KEY_POWER_ON();
+}
+void matrix_power_down(void) {
+    KEY_POWER_OFF();
+}
diff --git a/keyboard/hhkb/Makefile.iwrap b/keyboard/hhkb/not_supported/Makefile.iwrap
similarity index 100%
rename from keyboard/hhkb/Makefile.iwrap
rename to keyboard/hhkb/not_supported/Makefile.iwrap
diff --git a/keyboard/hhkb/Makefile.vusb b/keyboard/hhkb/not_supported/Makefile.vusb
similarity index 100%
rename from keyboard/hhkb/Makefile.vusb
rename to keyboard/hhkb/not_supported/Makefile.vusb
diff --git a/keyboard/hhkb/config_iwrap.h b/keyboard/hhkb/not_supported/config_iwrap.h
similarity index 100%
rename from keyboard/hhkb/config_iwrap.h
rename to keyboard/hhkb/not_supported/config_iwrap.h
diff --git a/keyboard/hhkb/config_vusb.h b/keyboard/hhkb/not_supported/config_vusb.h
similarity index 100%
rename from keyboard/hhkb/config_vusb.h
rename to keyboard/hhkb/not_supported/config_vusb.h
diff --git a/keyboard/hhkb/iwrap.txt b/keyboard/hhkb/not_supported/iwrap.txt
similarity index 100%
rename from keyboard/hhkb/iwrap.txt
rename to keyboard/hhkb/not_supported/iwrap.txt
diff --git a/keyboard/hhkb/usbconfig.h b/keyboard/hhkb/not_supported/usbconfig.h
similarity index 100%
rename from keyboard/hhkb/usbconfig.h
rename to keyboard/hhkb/not_supported/usbconfig.h
diff --git a/keyboard/hhkb_rn42/rn42.mk b/keyboard/hhkb/rn42.mk
similarity index 100%
rename from keyboard/hhkb_rn42/rn42.mk
rename to keyboard/hhkb/rn42.mk
diff --git a/keyboard/hhkb_rn42/rn42/MEMO.txt b/keyboard/hhkb/rn42/MEMO.txt
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/MEMO.txt
rename to keyboard/hhkb/rn42/MEMO.txt
diff --git a/keyboard/hhkb_rn42/rn42/PowerSave.txt b/keyboard/hhkb/rn42/PowerSave.txt
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/PowerSave.txt
rename to keyboard/hhkb/rn42/PowerSave.txt
diff --git a/keyboard/hhkb_rn42/rn42/RN42.txt b/keyboard/hhkb/rn42/RN42.txt
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/RN42.txt
rename to keyboard/hhkb/rn42/RN42.txt
diff --git a/keyboard/hhkb_rn42/rn42/battery.c b/keyboard/hhkb/rn42/battery.c
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/battery.c
rename to keyboard/hhkb/rn42/battery.c
diff --git a/keyboard/hhkb_rn42/rn42/battery.h b/keyboard/hhkb/rn42/battery.h
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/battery.h
rename to keyboard/hhkb/rn42/battery.h
diff --git a/keyboard/hhkb_rn42/rn42/main.c b/keyboard/hhkb/rn42/main.c
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/main.c
rename to keyboard/hhkb/rn42/main.c
diff --git a/keyboard/hhkb_rn42/rn42/rn42.c b/keyboard/hhkb/rn42/rn42.c
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/rn42.c
rename to keyboard/hhkb/rn42/rn42.c
diff --git a/keyboard/hhkb_rn42/rn42/rn42.h b/keyboard/hhkb/rn42/rn42.h
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/rn42.h
rename to keyboard/hhkb/rn42/rn42.h
diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.c b/keyboard/hhkb/rn42/rn42_task.c
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/rn42_task.c
rename to keyboard/hhkb/rn42/rn42_task.c
diff --git a/keyboard/hhkb_rn42/rn42/rn42_task.h b/keyboard/hhkb/rn42/rn42_task.h
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/rn42_task.h
rename to keyboard/hhkb/rn42/rn42_task.h
diff --git a/keyboard/hhkb_rn42/rn42/suart.S b/keyboard/hhkb/rn42/suart.S
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/suart.S
rename to keyboard/hhkb/rn42/suart.S
diff --git a/keyboard/hhkb_rn42/rn42/suart.h b/keyboard/hhkb/rn42/suart.h
similarity index 100%
rename from keyboard/hhkb_rn42/rn42/suart.h
rename to 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 0321977d11..0000000000
--- a/keyboard/hhkb_rn42/hhkb_avr.h
+++ /dev/null
@@ -1,166 +0,0 @@
-#ifndef HHKB_AVR_H
-#define HHKB_AVR_H
-
-#include <stdint.h>
-#include <stdbool.h>
-#include <avr/io.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
-
-
-// Timer resolution check
-#if (1000000/TIMER_RAW_FREQ > 20)
-#   error "Timer resolution(>20us) is not enough for HHKB matrix scan tweak on V-USB."
-#endif
-
-
-/*
- * HHKB Matrix I/O
- *
- * row:     HC4051[A,B,C]  selects scan row0-7
- * row-ext: [En0,En1] row extention for JP
- * col:     LS145[A,B,C,D] selects scan col0-7 and enable(D)
- * key:     on: 0/off: 1
- * prev:    hysteresis control: assert(1) when previous key state is on
- */
-
-
-#if defined(__AVR_ATmega32U4__)
-/*
- * For TMK HHKB alt controller(ATMega32U4)
- *
- * row:     PB0-2
- * col:     PB3-5,6
- * key:     PD7(pull-uped)
- * prev:    PB7
- * power:   PD4(L:off/H:on)
- * row-ext: PC6,7 for HHKB JP(active low)
- */
-static inline void KEY_ENABLE(void) { (PORTB &= ~(1<<6)); }
-static inline void KEY_UNABLE(void) { (PORTB |=  (1<<6)); }
-static inline bool KEY_STATE(void) { return (PIND & (1<<7)); }
-static inline void KEY_PREV_ON(void) { (PORTB |=  (1<<7)); }
-static inline void KEY_PREV_OFF(void) { (PORTB &= ~(1<<7)); }
-#ifdef HHKB_POWER_SAVING
-static inline void KEY_POWER_ON(void) {
-    DDRB = 0xFF; PORTB = 0x40;          // change pins output
-    DDRD |= (1<<4); PORTD |= (1<<4);    // MOS FET switch on
-    /* Without this wait you will miss or get false key events. */
-    _delay_ms(5);                       // wait for powering up
-}
-static inline void KEY_POWER_OFF(void) {
-    /* input with pull-up consumes less than without it when pin is open. */
-    DDRB = 0x00; PORTB = 0xFF;          // change pins input with pull-up
-    DDRD |= (1<<4); PORTD &= ~(1<<4);   // MOS FET switch off
-}
-static inline bool KEY_POWER_STATE(void) { return PORTD & (1<<4); }
-#else
-static inline void KEY_POWER_ON(void) {}
-static inline void KEY_POWER_OFF(void) {}
-static inline bool KEY_POWER_STATE(void) { return true; }
-#endif
-static inline void KEY_INIT(void)
-{
-    /* row,col,prev: output */
-    DDRB  = 0xFF;
-    PORTB = 0x40;   // unable
-    /* key: input with pull-up */
-    DDRD  &= ~0x80;
-    PORTD |=  0x80;
-#ifdef HHKB_JP
-    /* row extention for HHKB JP */
-    DDRC  |= (1<<6|1<<7);
-    PORTC |= (1<<6|1<<7);
-#endif
-    KEY_UNABLE();
-    KEY_PREV_OFF();
-
-    KEY_POWER_OFF();
-}
-static inline void KEY_SELECT(uint8_t ROW, uint8_t COL)
-{
-    PORTB = (PORTB & 0xC0) | (((COL) & 0x07)<<3) | ((ROW) & 0x07);
-#ifdef HHKB_JP
-    if ((ROW) & 0x08) PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<6);
-    else              PORTC = (PORTC & ~(1<<6|1<<7)) | (1<<7);
-#endif
-}
-
-
-#elif defined(__AVR_AT90USB1286__)
-/*
- * For Teensy++(AT90USB1286)
- *
- *                          HHKB pro    HHKB pro2
- * row:     PB0-2           (6-8)       (5-7)
- * col:     PB3-5,6         (9-12)      (8-11)
- * key:     PE6(pull-uped)  (4)         (3)
- * prev:    PE7             (5)         (4)
- *
- * TODO: convert into 'staitc inline' function
- */
-#define KEY_INIT()              do {    \
-    DDRB |= 0x7F;                       \
-    DDRE |=  (1<<7);                    \
-    DDRE &= ~(1<<6);                    \
-    PORTE |= (1<<6);                    \
-} while (0)
-#define KEY_SELECT(ROW, COL)    (PORTB = (PORTB & 0xC0) |       \
-                                         (((COL) & 0x07)<<3) |  \
-                                         ((ROW) & 0x07))
-#define KEY_ENABLE()            (PORTB &= ~(1<<6))
-#define KEY_UNABLE()            (PORTB |=  (1<<6))
-#define KEY_STATE()             (PINE & (1<<6))
-#define KEY_PREV_ON()           (PORTE |=  (1<<7))
-#define KEY_PREV_OFF()          (PORTE &= ~(1<<7))
-#define KEY_POWER_ON()
-#define KEY_POWER_OFF()
-
-
-#else
-#   error "define code for matrix scan"
-#endif
-
-
-#if 0
-// For ATMega328P with V-USB
-//
-// #elif defined(__AVR_ATmega328P__)
-// Ports for V-USB
-// key:     PB0(pull-uped)
-// prev:    PB1
-// row:     PB2-4
-// col:     PC0-2,3
-// power:   PB5(Low:on/Hi-z:off)
-#define KEY_INIT()              do {    \
-    DDRB  |= 0x3E;                      \
-    DDRB  &= ~(1<<0);                   \
-    PORTB |= 1<<0;                      \
-    DDRC  |= 0x0F;                      \
-    KEY_UNABLE();                       \
-    KEY_PREV_OFF();                     \
-} while (0)
-#define KEY_SELECT(ROW, COL)    do {    \
-    PORTB = (PORTB & 0xE3) | ((ROW) & 0x07)<<2; \
-    PORTC = (PORTC & 0xF8) | ((COL) & 0x07);    \
-} while (0)
-#define KEY_ENABLE()            (PORTC &= ~(1<<3))
-#define KEY_UNABLE()            (PORTC |=  (1<<3))
-#define KEY_STATE()             (PINB & (1<<0))
-#define KEY_PREV_ON()           (PORTB |=  (1<<1))
-#define KEY_PREV_OFF()          (PORTB &= ~(1<<1))
-// Power supply switching
-#define KEY_POWER_ON()          do {    \
-    KEY_INIT();                         \
-    PORTB &= ~(1<<5);                   \
-    _delay_ms(1);                       \
-} while (0)
-#define KEY_POWER_OFF()         do {    \
-    DDRB  &= ~0x3F;                     \
-    PORTB &= ~0x3F;                     \
-    DDRC  &= ~0x0F;                     \
-    PORTC &= ~0x0F;                     \
-} while (0)
-#endif
-
-#endif
diff --git a/keyboard/hhkb_rn42/keymap_common.c b/keyboard/hhkb_rn42/keymap_common.c
deleted file mode 100644
index e938fb6270..0000000000
--- a/keyboard/hhkb_rn42/keymap_common.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#include <stdint.h>
-#include "action.h"
-#include <avr/pgmspace.h>
-#include "keymap_common.h"
-
-
-/* translates key to keycode */
-uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
-{
-    return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
-}
-
-/* translates Fn keycode to action */
-action_t keymap_fn_to_action(uint8_t keycode)
-{
-    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
-}
diff --git a/keyboard/hhkb_rn42/keymap_common.h b/keyboard/hhkb_rn42/keymap_common.h
deleted file mode 100644
index 3622665f3a..0000000000
--- a/keyboard/hhkb_rn42/keymap_common.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-#ifndef KEYMAP_COMMON_H
-#define KEYMAP_COMMON_H
-
-#include <stdint.h>
-#include <stdbool.h>
-#include "keycode.h"
-#include "action.h"
-#include "action_code.h"
-#include "action_layer.h"
-#include "action_macro.h"
-#include "action_util.h"
-#include "report.h"
-#include "host.h"
-#include "print.h"
-#include "debug.h"
-#include "keymap.h"
-
-
-extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
-extern const uint16_t fn_actions[];
-
-
-#define KEYMAP( \
-    K31, K30, K00, K10, K11, K20, K21, K40, K41, K60, K61, K70, K71, K50, K51, \
-    K32, K01, K02, K13, K12, K23, K22, K42, K43, K62, K63, K73, K72, K52, \
-    K33, K04, K03, K14, K15, K24, K25, K45, K44, K65, K64, K74, K53, \
-    K34, K05, K06, K07, K16, K17, K26, K46, K66, K76, K75, K55, K54, \
-         K35, K36,           K37,                K57, K56 \
-) \
-{ \
-    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
-    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
-    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO    }, \
-    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
-    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_NO    }, \
-    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
-    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO    }, \
-    { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO    } \
-}
-
-
-#define KEYMAP_JP( \
-    K02, K32, K62, K22, K12, K52, K72, KA2, K92, K82, KB2, KE2, KF2, KD2, KC2, \
-    K03, K63, K23, K13, K53, K73, KA3, K93, K83, KB3, KE3, KF3, KD3, \
-    K06, K66, K26, K16, K56, K76, KA6, K96, K86, KB6, KE6, KF6, KD6, KC6, \
-    K05, K65, K25, K15, K55, K75, KA5, K95, K85, KB5, KE5, KF5, KD5, KC5, \
-    K04, K34, K64, K24, K14,      K74,      K94, K84, KB4, KE4, KF4, KD4, KC4 \
-) \
-{ \
-    { KC_NO,    KC_NO,    KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K32, KC_NO,    KC_##K34, KC_NO,    KC_NO,    KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K52, KC_##K53, KC_NO,    KC_##K55, KC_##K56, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##K92, KC_##K93, KC_##K94, KC_##K95, KC_##K96, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##KA2, KC_##KA3, KC_NO,    KC_##KA5, KC_##KA6, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##KB2, KC_##KB3, KC_##KB4, KC_##KB5, KC_##KB6, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##KC2, KC_NO,    KC_##KC4, KC_##KC5, KC_##KC6, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##KD2, KC_##KD3, KC_##KD4, KC_##KD5, KC_##KD6, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##KE2, KC_##KE3, KC_##KE4, KC_##KE5, KC_##KE6, KC_NO    }, \
-    { KC_NO,    KC_NO,    KC_##KF2, KC_##KF3, KC_##KF4, KC_##KF5, KC_##KF6, KC_NO    }  \
-}
-
-#endif
diff --git a/keyboard/hhkb_rn42/keymap_hasu.c b/keyboard/hhkb_rn42/keymap_hasu.c
deleted file mode 100644
index 433f9cb270..0000000000
--- a/keyboard/hhkb_rn42/keymap_hasu.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/* 
- * Hasu: my personal keymap
- */
-#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
-     * ,-----------------------------------------------------------.
-     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|  `|
-     * |-----------------------------------------------------------|
-     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Backs|
-     * |-----------------------------------------------------------|
-     * |Contro|  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Fn6     |
-     * |-----------------------------------------------------------|
-     * |Fn7     |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|Fn2|Shift |Fn1|
-     * `-----------------------------------------------------------'
-     *       |Gui|Alt  |         Fn4           |Fn5  |Gui|
-     *       `-------------------------------------------'
-     */
-    [0] = \
-    KEYMAP(ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSLS,GRV, \
-           TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSPC, \
-           LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   FN3, QUOT,FN6, \
-           FN7, Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, FN2, RSFT,FN1, \
-                LGUI,LALT,          FN4,                FN5, RGUI),
-
-    /* Layer 1: HHKB mode[HHKB Fn]
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |Backs|
-     * |-----------------------------------------------------------|
-     * |Contro|VoD|VoU|Mut|   |   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |   |  +|  -|End|PgD|Dow|Shift |   |
-     * `-----------------------------------------------------------'
-     *       |Gui|Alt  |         Space         |Alt  |Gui|
-     *       `-------------------------------------------'
-     */ 
-    [1] = \
-    KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           CAPS,NO,  NO,  NO,  NO,  NO,  NO,  NO,  PSCR,SLCK,PAUS, UP,  NO,  BSPC, \
-           LCTL,VOLD,VOLU,MUTE,NO,  NO,  PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \
-           LSFT,NO,  NO,  NO,  NO,  NO,  PPLS,PMNS,END, PGDN,DOWN,RSFT,TRNS, \
-                LGUI,LALT,          TRNS,               RALT,RGUI),
-
-    /* Layer 2: Vi mode[Slash]
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Tab  |Hom|PgD|Up |PgU|End|Hom|PgD|PgUlEnd|   |   |   |Backs|
-     * |-----------------------------------------------------------|
-     * |Contro|   |Lef|Dow|Rig|   |Lef|Dow|Up |Rig|   |   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |   |Hom|PgD|PgUlEnd|Fn0|Shift |   |
-     * `-----------------------------------------------------------'
-     *       |Gui|Alt  |          Space        |Alt  |Gui|
-     *       `-------------------------------------------'
-     */
-    [2] = \
-    KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           TAB, HOME,PGDN,UP,  PGUP,END, HOME,PGDN,PGUP,END, NO,  NO,  NO,  BSPC, \
-           LCTL,NO,  LEFT,DOWN,RGHT,NO,  LEFT,DOWN,UP,  RGHT,NO,  NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  NO,  HOME,PGDN,PGUP,END, FN2, RSFT,TRNS, \
-                LGUI,LALT,          SPC,                RALT,RGUI),
-
-    /* Layer 3: Mouse mode(IJKL)[Semicolon]
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Tab  |   |   |   |   |   |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
-     * |-----------------------------------------------------------|
-     * |Contro|   |   |   |   |   |Mb2|McL|McD|McR|Fn |   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift |   |
-     * `-----------------------------------------------------------'
-     *      |Gui |Alt  |          Mb1          |Fn   |Fn |
-     *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
-     */
-    [3] = \
-    KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
-           LCTL,ACL0,ACL1,ACL2,ACL2,NO,  NO,  MS_L,MS_D,MS_R,FN3, NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,TRNS, \
-                LGUI,LALT,          BTN1,               TRNS,TRNS),
-
-    /* Layer 4: Mouse mode(IJKL)[Space]
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Tab  |   |   |   |   |   |MwL|MwD|McU|MwU|MwR|Wbk|Wfr|Alt-T|
-     * |-----------------------------------------------------------|
-     * |Contro|   |   |   |   |   |Mb2|McL|McD|McR|Mb1|   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift |   |
-     * `-----------------------------------------------------------'
-     *      |Gui |Alt  |          Mb1          |Fn   |Fn |
-     *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
-     */
-    [4] = \
-    KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,MS_U,WH_U,RGHT,FN9, FN10,FN8, \
-           LCTL,VOLD,VOLU,MUTE,NO,  NO,  NO,  MS_L,MS_D,MS_R,BTN1,NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,TRNS, \
-                LGUI,LALT,          TRNS,               TRNS,TRNS),
-
-#if 0
-    /* Layer 3: Mouse mode(HJKL)[Semicolon]
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Tab  |   |   |   |   |   |MwL|MwD|MwU|MwR|   |   |   |Backs|
-     * |-----------------------------------------------------------|
-     * |Contro|   |   |   |   |   |McL|McD|McU|McR|Fn0|   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift |   |
-     * `-----------------------------------------------------------'
-     *      |Gui |Alt  |          Mb1          |Alt  |Fn0|
-     *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel 
-     */
-    KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           TAB, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,WH_U,RGHT,NO,  NO,  NO,  BSPC, \
-           LCTL,NO,  ACL0,ACL1,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,TRNS,QUOT,ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,SLSH,RSFT,NO, \
-                LGUI,LALT,          BTN1,               RALT,TRNS),
-
-    /* Layer4: Mouse mode(HJKL)[Space]
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Tab  |   |   |   |   |   |MwL|MwD|MwU|MwR|   |Wbk|Wfr|Alt-T|
-     * |-----------------------------------------------------------|
-     * |Contro|   |   |   |   |   |McL|McD|McU|McR|Fn0|   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift |   |
-     * `-----------------------------------------------------------'
-     *      |Gui |Alt  |          Fn0          |Alt  |Fn0|
-     *      `--------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel 
-     */
-    KEYMAP(GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-           FN8, NO,  NO,  NO,  NO,  NO,  NO,  WH_D,WH_U,RGHT,NO,  FN9, FN10,FN8, \
-           LCTL,NO,  ACL0,ACL1,ACL2,NO,  MS_L,MS_D,MS_U,MS_R,BTN1,NO,  ENT, \
-           LSFT,NO,  NO,  NO,  NO,  BTN3,BTN2,BTN1,FN9, FN10,NO,  RSFT,NO, \
-                LGUI,LALT,          TRNS,               RALT,RGUI),
-#endif
-#if 0
-    /* Layer x: Matias half-qwerty keyboard style[Space]
-     * ,-----------------------------------------------------------.
-     * |  -|  0|  9|  8|  7|  6|  5|  4|  3|  2|  1|   |   |   |Esc|
-     * |-----------------------------------------------------------|
-     * |Backs|  P|  O|  I|  U|  Y|  T|  R|  E|  W|  Q|   |   |Tab  |
-     * |-----------------------------------------------------------|
-     * |Contro|  ;|  L|  K|  J|  H|  G|  F|  D|  S|  A|Con|Control |
-     * |-----------------------------------------------------------|
-     * |Shift   |  /|  .|  ,|  M|  N|  B|  V|  C|  X|  Z|Shift |   |
-     * `-----------------------------------------------------------'
-     *      |Gui |Alt  |          Fn0          |Alt  |Gui|
-     *      `--------------------------------------------'
-     */
-    KEYMAP(MINS,0,   9,   8,   7,   6,   5,   4,   3,   2,   1,   NO,  NO,  NO,  ESC, \
-           BSPC,P,   O,   I,   U,   Y,   T,   R,   E,   W,   Q,   NO,  NO,  TAB, \
-           LCTL,SCLN,L,   K,   J,   H,   G,   F,   D,   S,   A,   RCTL,RCTL, \
-           LSFT,SLSH,DOT, COMM,M,   N,   B,   V,   C,   X,   Z,   RSFT,NO, \
-                LGUI,LALT,          TRNS,               RALT,RGUI),
-#endif
-};
-
-
-
-/* id for user defined functions */
-enum function_id {
-    LSHIFT_LPAREN,
-};
-
-enum macro_id {
-    HELLO,
-    VOLUP,
-    ALT_TAB,
-};
-
-
-/*
- * Fn action definition
- */
-#ifdef KEYMAP_SECTION_ENABLE
-const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
-#else
-const uint16_t fn_actions[] PROGMEM = {
-#endif
-    [0] = ACTION_DEFAULT_LAYER_SET(0),                // Default layer(not used)
-    [1] = ACTION_LAYER_TAP_TOGGLE(1),                 // HHKB layer(toggle with 5 taps)
-    [2] = ACTION_LAYER_TAP_KEY(2, KC_SLASH),          // Cursor layer with Slash*
-    [3] = ACTION_LAYER_TAP_KEY(3, KC_SCLN),           // Mousekey layer with Semicolon*
-    [4] = ACTION_LAYER_TAP_KEY(4, KC_SPC),            // Mousekey layer with Space
-    [5] = ACTION_LAYER_MOMENTARY(4),                  // Mousekey layer(IJKL)
-    [6] = ACTION_MODS_TAP_KEY(MOD_RCTL, KC_ENT),      // RControl with tap Enter
-    [7] = ACTION_MODS_ONESHOT(MOD_LSFT),              // Oneshot Shift
-    [8] = ACTION_MACRO(ALT_TAB),                      // Application switching
-    [9] = ACTION_MODS_KEY(MOD_LALT, KC_LEFT),
-   [10] = ACTION_MODS_KEY(MOD_LALT, KC_RIGHT),
-
-//  [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_BSPC),        // LControl with tap Backspace
-//  [x] = ACTION_LMOD_TAP_KEY(KC_LCTL, KC_ESC),         // LControl with tap Esc
-//  [x] = ACTION_FUNCTION_TAP(LSHIFT_LPAREN),           // Function: LShift with tap '('
-//  [x] = ACTION_MACRO(HELLO),                          // Macro: say hello
-//  [x] = ACTION_MACRO(VOLUP),                          // Macro: media key
-};
-
-
-/*
- * Macro definition
- */
-const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
-{
-    switch (id) {
-        case HELLO:
-            return (record->event.pressed ?
-                    MACRO( I(0), T(H), T(E), T(L), T(L), W(255), T(O), END ) :
-                    MACRO_NONE );
-        case VOLUP:
-            return (record->event.pressed ?
-                    MACRO( D(VOLU), U(VOLU), END ) :
-                    MACRO_NONE );
-        case ALT_TAB:
-            return (record->event.pressed ?
-                    MACRO( D(LALT), D(TAB), END ) :
-                    MACRO( U(TAB), END ));
-    }
-    return MACRO_NONE;
-}
-
-
-
-/*
- * user defined action function
- */
-void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
-{
-    if (record->event.pressed) dprint("P"); else dprint("R");
-    dprintf("%d", record->tap.count);
-    if (record->tap.interrupted) dprint("i");
-    dprint("\n");
-
-    switch (id) {
-        case LSHIFT_LPAREN:
-            // Shift parentheses example: LShft + tap '('
-            // http://stevelosh.com/blog/2012/10/a-modern-space-cadet/#shift-parentheses
-            // http://geekhack.org/index.php?topic=41989.msg1304899#msg1304899
-            if (record->event.pressed) {
-                if (record->tap.count > 0 && !record->tap.interrupted) {
-                    if (record->tap.interrupted) {
-                        dprint("tap interrupted\n");
-                        register_mods(MOD_BIT(KC_LSHIFT));
-                    }
-                } else {
-                    register_mods(MOD_BIT(KC_LSHIFT));
-                }
-            } else {
-                if (record->tap.count > 0 && !(record->tap.interrupted)) {
-                    add_weak_mods(MOD_BIT(KC_LSHIFT));
-                    send_keyboard_report();
-                    register_code(KC_9);
-                    unregister_code(KC_9);
-                    del_weak_mods(MOD_BIT(KC_LSHIFT));
-                    send_keyboard_report();
-                    record->tap.count = 0;  // ad hoc: cancel tap
-                } else {
-                    unregister_mods(MOD_BIT(KC_LSHIFT));
-                }
-            }
-            break;
-    }
-}
diff --git a/keyboard/hhkb_rn42/keymap_jp.c b/keyboard/hhkb_rn42/keymap_jp.c
deleted file mode 100644
index 48d0ee70ba..0000000000
--- a/keyboard/hhkb_rn42/keymap_jp.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 
- * 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 */
-    KEYMAP_JP(ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, JYEN,BSPC, \
-              TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC, \
-              LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,BSLS,ENT, \
-              LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RO,  UP,  RSFT, \
-              FN0, ZKHK,LGUI,LALT,MHEN,     SPC,      HENK,KANA,RALT,FN0, LEFT,DOWN,RGHT),
-
-    /* Layer 1: HHKB mode (HHKB Fn)
-     * ,-----------------------------------------------------------.
-     * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |     |
-     * |------------------------------------------------------`    |
-     * |      |VoD|VoU|Mut|   |   |  *|  /|Hom|PgU|Lef|Rig|   |    |
-     * |-----------------------------------------------------------|
-     * |       |   |   |   |   |   |  +|  -|End|PgD|Dow|   |   |   |
-     * |-----------------------------------------------------------|
-     * |   ||   |   |   |   |         |   |   |   |   ||   |   |   |
-     * `-----------------------------------------------------------'
-     */ 
-    KEYMAP_JP(PWR, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL, \
-              CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, \
-              TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,TRNS,PENT, \
-              TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,TRNS,TRNS,TRNS, \
-              TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS),
-};
-
-
-
-/*
- * Fn action definition
- */
-#ifdef KEYMAP_SECTION_ENABLE
-const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = {
-#else
-const uint16_t fn_actions[] PROGMEM = {
-#endif
-    [0] = ACTION_LAYER_MOMENTARY(1),
-};
diff --git a/keyboard/hhkb_rn42/led.c b/keyboard/hhkb_rn42/led.c
deleted file mode 100644
index 8a08fe27fc..0000000000
--- a/keyboard/hhkb_rn42/led.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-Copyright 2011 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <avr/io.h>
-#include "stdint.h"
-#include "led.h"
-
-
-/* HHKB has no LEDs */
-void led_set(uint8_t usb_led)
-{
-    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
-        DDRD |= (1<<6);
-        PORTD |= (1<<6);
-    } else {
-        DDRD |= (1<<6);
-        PORTD &= ~(1<<6);
-    }
-}
diff --git a/keyboard/hhkb_rn42/matrix.c b/keyboard/hhkb_rn42/matrix.c
deleted file mode 100644
index fb96997944..0000000000
--- a/keyboard/hhkb_rn42/matrix.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
-Copyright 2011 Jun Wako <wakojun@gmail.com>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-/*
- * scan matrix
- */
-#include <stdint.h>
-#include <stdbool.h>
-#include <util/delay.h>
-#include "print.h"
-#include "debug.h"
-#include "util.h"
-#include "timer.h"
-#include "matrix.h"
-#include "hhkb_avr.h"
-#include <avr/wdt.h>
-#include "suspend.h"
-#include "lufa.h"
-
-
-// matrix power saving
-#define MATRIX_POWER_SAVE       10000
-static uint32_t matrix_last_modified = 0;
-
-// matrix state buffer(1:on, 0:off)
-static matrix_row_t *matrix;
-static matrix_row_t *matrix_prev;
-static matrix_row_t _matrix0[MATRIX_ROWS];
-static matrix_row_t _matrix1[MATRIX_ROWS];
-
-
-inline
-uint8_t matrix_rows(void)
-{
-    return MATRIX_ROWS;
-}
-
-inline
-uint8_t matrix_cols(void)
-{
-    return MATRIX_COLS;
-}
-
-void matrix_init(void)
-{
-#ifdef DEBUG
-    debug_enable = true;
-    debug_keyboard = true;
-#endif
-
-    KEY_INIT();
-
-    // initialize matrix state: all keys off
-    for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00;
-    for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00;
-    matrix = _matrix0;
-    matrix_prev = _matrix1;
-}
-
-uint8_t matrix_scan(void)
-{
-    uint8_t *tmp;
-
-    tmp = matrix_prev;
-    matrix_prev = matrix;
-    matrix = tmp;
-
-    // power on
-    if (!KEY_POWER_STATE()) KEY_POWER_ON();
-    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
-        for (uint8_t col = 0; col < MATRIX_COLS; col++) {
-            KEY_SELECT(row, col);
-            _delay_us(5);
-
-            // Not sure this is needed. This just emulates HHKB controller's behaviour.
-            if (matrix_prev[row] & (1<<col)) {
-                KEY_PREV_ON();
-            }
-            _delay_us(10);
-
-            // NOTE: KEY_STATE is valid only in 20us after KEY_ENABLE.
-            // If V-USB interrupts in this section we could lose 40us or so
-            // and would read invalid value from KEY_STATE.
-            uint8_t last = TIMER_RAW;
-
-            KEY_ENABLE();
-
-            // Wait for KEY_STATE outputs its value.
-            // 1us was ok on one HHKB, but not worked on another.
-            // no   wait doesn't work on Teensy++ with pro(1us works)
-            // no   wait does    work on tmk PCB(8MHz) with pro2
-            // 1us  wait does    work on both of above
-            // 1us  wait doesn't work on tmk(16MHz)
-            // 5us  wait does    work on tmk(16MHz)
-            // 5us  wait does    work on tmk(16MHz/2)
-            // 5us  wait does    work on tmk(8MHz)
-            // 10us wait does    work on Teensy++ with pro
-            // 10us wait does    work on 328p+iwrap with pro
-            // 10us wait doesn't work on tmk PCB(8MHz) with pro2(very lagged scan)
-            _delay_us(5);
-
-            if (KEY_STATE()) {
-                matrix[row] &= ~(1<<col);
-            } else {
-                matrix[row] |= (1<<col);
-            }
-
-            // Ignore if this code region execution time elapses more than 20us.
-            // MEMO: 20[us] * (TIMER_RAW_FREQ / 1000000)[count per us]
-            // MEMO: then change above using this rule: a/(b/c) = a*1/(b/c) = a*(c/b)
-            if (TIMER_DIFF_RAW(TIMER_RAW, last) > 20/(1000000/TIMER_RAW_FREQ)) {
-                matrix[row] = matrix_prev[row];
-            }
-
-            _delay_us(5);
-            KEY_PREV_OFF();
-            KEY_UNABLE();
-
-            // NOTE: KEY_STATE keep its state in 20us after KEY_ENABLE.
-            // This takes 25us or more to make sure KEY_STATE returns to idle state.
-            _delay_us(75);
-        }
-        if (matrix[row] ^ matrix_prev[row]) matrix_last_modified = timer_read32();
-    }
-    // power off
-    if (KEY_POWER_STATE() &&
-            (USB_DeviceState == DEVICE_STATE_Suspended ||
-             USB_DeviceState == DEVICE_STATE_Unattached ) &&
-            timer_elapsed32(matrix_last_modified) > MATRIX_POWER_SAVE) {
-        KEY_POWER_OFF();
-        suspend_power_down();
-    }
-    return 1;
-}
-
-bool matrix_is_modified(void)
-{
-    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
-        if (matrix[i] != matrix_prev[i])
-            return true;
-    }
-    return false;
-}
-
-inline
-bool matrix_has_ghost(void)
-{
-    return false;
-}
-
-inline
-bool matrix_is_on(uint8_t row, uint8_t col)
-{
-    return (matrix[row] & (1<<col));
-}
-
-inline
-matrix_row_t matrix_get_row(uint8_t row)
-{
-    return matrix[row];
-}
-
-void matrix_print(void)
-{
-    print("\nr/c 01234567\n");
-    for (uint8_t row = 0; row < matrix_rows(); row++) {
-        xprintf("%02X: %08b\n", row, bitrev(matrix_get_row(row)));
-    }
-}
-
-void matrix_power_up(void) {
-    KEY_POWER_ON();
-}
-void matrix_power_down(void) {
-    KEY_POWER_OFF();
-}

From f31cbc7219c9a1903331771c10056302817e68ca Mon Sep 17 00:00:00 2001
From: Ralf Schmitt <ralf@bunkertor.net>
Date: Wed, 12 Nov 2014 14:05:57 +0100
Subject: [PATCH 62/95] Changed hotkey for bootloader jump

---
 common/command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/command.c b/common/command.c
index 1a507e3a46..c50d3eb4b1 100644
--- a/common/command.c
+++ b/common/command.c
@@ -216,7 +216,7 @@ static bool command_common(uint8_t code)
             print("C> ");
             command_state = CONSOLE;
             break;
-        case KC_PAUSE:
+        case KC_B:
             clear_keyboard();
             print("\n\nJump to bootloader... ");
             _delay_ms(1000);

From d9b5f5110ebf3e7da6a11e8640fb4367114aed67 Mon Sep 17 00:00:00 2001
From: Ralf Schmitt <ralf@bunkertor.net>
Date: Tue, 11 Nov 2014 14:49:16 +0100
Subject: [PATCH 63/95] Added NerD 60% support

---
 README.md                      |   1 +
 keyboard/nerd/Makefile         | 123 ++++++++++++++++++
 keyboard/nerd/README.md        |  45 +++++++
 keyboard/nerd/backlight.c      |  75 +++++++++++
 keyboard/nerd/backlight.h      |  40 ++++++
 keyboard/nerd/config.h         |  49 ++++++++
 keyboard/nerd/keymap_ansi150.c |  39 ++++++
 keyboard/nerd/keymap_common.c  |  29 +++++
 keyboard/nerd/keymap_common.h  |  67 ++++++++++
 keyboard/nerd/led.c            |  25 ++++
 keyboard/nerd/matrix.c         | 220 +++++++++++++++++++++++++++++++++
 11 files changed, 713 insertions(+)
 create mode 100644 keyboard/nerd/Makefile
 create mode 100644 keyboard/nerd/README.md
 create mode 100644 keyboard/nerd/backlight.c
 create mode 100644 keyboard/nerd/backlight.h
 create mode 100644 keyboard/nerd/config.h
 create mode 100644 keyboard/nerd/keymap_ansi150.c
 create mode 100644 keyboard/nerd/keymap_common.c
 create mode 100644 keyboard/nerd/keymap_common.h
 create mode 100644 keyboard/nerd/led.c
 create mode 100644 keyboard/nerd/matrix.c

diff --git a/README.md b/README.md
index e077fc928d..e918faa0df 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 * [KMAC](keyboard/kmac/)                    - Korean custom keyboard
 * [Lightsaber](keyboard/lightsaber/)        - Korean custom keyboard
 * [Infinity](keyboard/infinity/)            - Massdrop [Infinity keyboard][Infinity]
+* [NerD](keyboard/nerd/)                    - Korean custom keyboard
 
 [GH_macway]:    http://geekhack.org/showwiki.php?title=Island:11930
 [GH_hhkb]:      http://geekhack.org/showwiki.php?title=Island:12047
diff --git a/keyboard/nerd/Makefile b/keyboard/nerd/Makefile
new file mode 100644
index 0000000000..10fa144fbb
--- /dev/null
+++ b/keyboard/nerd/Makefile
@@ -0,0 +1,123 @@
+#----------------------------------------------------------------------------
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF.
+#
+# make extcoff = Convert ELF to AVR Extended COFF.
+#
+# make program = Download the hex file to the device.
+#                Please customize your programmer settings(PROGRAM_CMD)
+#
+# make teensy = Download the hex file to the device, using teensy_loader_cli.
+#               (must have teensy_loader_cli installed).
+#
+# make dfu = Download the hex file to the device, using dfu-programmer (must
+#            have dfu-programmer installed).
+#
+# make flip = Download the hex file to the device, using Atmel FLIP (must
+#             have Atmel FLIP installed).
+#
+# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
+#               (must have dfu-programmer installed).
+#
+# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
+#                (must have Atmel FLIP installed).
+#
+# make debug = Start either simulavr or avarice as specified for debugging, 
+#              with avr-gdb or avr-insight as the front end for debugging.
+#
+# make filename.s = Just compile filename.c into the assembler code only.
+#
+# make filename.i = Create a preprocessed source file for use in submitting
+#                   bug reports to the GCC project.
+#
+# To rebuild project do "make clean" then "make all".
+#----------------------------------------------------------------------------
+
+# Target file name (without extension).
+TARGET = nerd_lufa
+
+# Directory common source filess exist
+TOP_DIR = ../..
+
+# Directory keyboard dependent files exist
+TARGET_DIR = .
+
+# project specific files
+SRC =	keymap_common.c \
+	matrix.c \
+	backlight.c \
+	led.c \
+	keymap_ansi150.c
+
+CONFIG_H = config.h
+
+# MCU name
+MCU = atmega32u4
+
+# Processor frequency.
+#     This will define a symbol, F_CPU, in all source code files equal to the
+#     processor frequency in Hz. You can then use this symbol in your source code to
+#     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
+#     automatically to create a 32-bit value in your source code.
+#
+#     This will be an integer division of F_USB below, as it is sourced by
+#     F_USB after it has run through any CPU prescalers. Note that this value
+#     does not *change* the processor frequency - it should merely be updated to
+#     reflect the processor speed set externally so that the code can use accurate
+#     software delays.
+F_CPU = 8000000
+
+#
+# LUFA specific
+#
+# Target architecture (see library "Board Types" documentation).
+ARCH = AVR8
+
+# Input clock frequency.
+#     This will define a symbol, F_USB, in all source code files equal to the
+#     input clock frequency (before any prescaling is performed) in Hz. This value may
+#     differ from F_CPU if prescaling is used on the latter, and is required as the
+#     raw input clock is fed directly to the PLL sections of the AVR for high speed
+#     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
+#     at the end, this will be done automatically to create a 32-bit value in your
+#     source code.
+#
+#     If no clock division is performed on the input clock inside the AVR (via the
+#     CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
+F_USB = $(F_CPU)
+
+# Boot Section Size in *bytes*
+#   Teensy halfKay   512
+#   Teensy++ halfKay 1024
+#   Atmel DFU loader 4096
+#   LUFA bootloader  4096
+#   USBaspLoader     2048
+OPT_DEFS += -DBOOTLOADER_SIZE=4096
+
+# Build Options
+#   comment out to disable the options.
+#
+BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
+#MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
+CONSOLE_ENABLE = yes	# Console for debug(+400)
+COMMAND_ENABLE = yes    # Commands for debug and configuration
+#SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
+#NKRO_ENABLE = yes	# USB Nkey Rollover - not yet supported in LUFA
+BACKLIGHT_ENABLE = yes  # Enable keyboard backlight functionality
+
+# Search Path
+VPATH += $(TARGET_DIR)
+VPATH += $(TOP_DIR)
+
+include $(TOP_DIR)/protocol/lufa.mk
+include $(TOP_DIR)/common.mk
+include $(TOP_DIR)/rules.mk
+
+winkey: OPT_DEFS += -DLAYOUT_WINKEY
+winkey: all
diff --git a/keyboard/nerd/README.md b/keyboard/nerd/README.md
new file mode 100644
index 0000000000..0130fe49fd
--- /dev/null
+++ b/keyboard/nerd/README.md
@@ -0,0 +1,45 @@
+NerD keyboard firmware
+========================
+
+Korean Keyboard designed by GON.
+
+*Note that this is not the official firmware*
+
+
+Hardware revision
+-----------------
+
+This firmware was developed and tested for NerD pcb version 1.61 and 2.0.
+
+
+Supported features
+------------------
+
+* All layout options are supported
+* All leds are supported
+
+
+Changing Bootloader
+-------------------
+
+You can't simply just upload this firmware to a new NerD board because the original
+bootloader won't accept DFU connections.
+
+You can change the bootloader of the keyboard with an ISP programmer of your choice.
+The bootloader pins are easy to access on the NerD pcb.
+
+*Be aware that after changing the bootloader the official configuration software
+won't work anymore and you'll lose your warrenty. GON won't provide any support for this firmware.*
+
+
+Build
+-----
+
+Move to this directory then just run `make`.
+
+
+Jump to Bootloader
+------------------
+
+You can jump to bootloader by software if you have a macro defined for this in your keymap. The
+default command is (LSFT+RSFT+PAUS) to access the bootloader by software jump.
diff --git a/keyboard/nerd/backlight.c b/keyboard/nerd/backlight.c
new file mode 100644
index 0000000000..804b4848a6
--- /dev/null
+++ b/keyboard/nerd/backlight.c
@@ -0,0 +1,75 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <avr/io.h>
+#include "backlight.h"
+
+void backlight_init_ports()
+{
+    DDRB |= 0b11100000; // PB7 (switch), PB6 (pcb), PB5 (caps)
+}
+
+void backlight_set(uint8_t level)
+{
+    (level & BACKLIGHT_SWITCH) ? backlight_switch_enable() : backlight_switch_disable();
+    (level & BACKLIGHT_PCB) ? backlight_pcb_enable() : backlight_pcb_disable();
+}
+
+void backlight_switch_enable()
+{
+    PORTB |= 0b10000000;
+}
+
+void backlight_switch_disable()
+{
+    PORTB &= ~0b10000000;
+}
+
+void backlight_switch_invert()
+{
+    PORTB ^= 0b10000000;
+}
+
+void backlight_pcb_enable()
+{
+    PORTB |= 0b01000000;
+}
+
+void backlight_pcb_disable()
+{
+    PORTB &= ~0b01000000;
+}
+
+void backlight_pcb_invert()
+{
+    PORTB ^= 0b01000000;
+}
+
+void backlight_caps_enable()
+{
+    PORTB |= 0b00100000;
+}
+
+void backlight_caps_disable()
+{
+    PORTB &= ~0b00100000;
+}
+
+void backlight_caps_invert()
+{
+    PORTB ^= 0b00100000;
+}
diff --git a/keyboard/nerd/backlight.h b/keyboard/nerd/backlight.h
new file mode 100644
index 0000000000..4c75d9db65
--- /dev/null
+++ b/keyboard/nerd/backlight.h
@@ -0,0 +1,40 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef BACKLIGHT_H
+#define BACKLIGHT_H
+
+enum backlight_level {
+    BACKLIGHT_SWITCH = 0b0000001,
+    BACKLIGHT_PCB    = 0b0000010,
+};
+
+void backlight_init_ports(void);
+
+void backlight_switch_invert(void);
+void backlight_switch_enable(void);
+void backlight_switch_disable(void);
+
+void backlight_pcb_invert(void);
+void backlight_pcb_enable(void);
+void backlight_pcb_disable(void);
+
+void backlight_caps_invert(void);
+void backlight_caps_enable(void);
+void backlight_caps_disable(void);
+
+#endif // BACKLIGHT_H
diff --git a/keyboard/nerd/config.h b/keyboard/nerd/config.h
new file mode 100644
index 0000000000..7eab1cb090
--- /dev/null
+++ b/keyboard/nerd/config.h
@@ -0,0 +1,49 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xFEED
+#define PRODUCT_ID      0x6060
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    GON
+#define PRODUCT         NerD
+#define DESCRIPTION     t.m.k. keyboard firmware for NerD
+
+/* key matrix size */
+#define MATRIX_ROWS 8
+#define MATRIX_COLS 10
+
+/* Set 0 if debouncing isn't needed */
+#define DEBOUNCE    5
+
+/* number of backlight levels */
+#define BACKLIGHT_LEVELS 2
+
+/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
+#define LOCKING_SUPPORT_ENABLE
+
+/* Locking resynchronize hack */
+#define LOCKING_RESYNC_ENABLE
+
+/* key combination for command */
+#define IS_COMMAND() ( \
+    keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
+)
+
+#endif
diff --git a/keyboard/nerd/keymap_ansi150.c b/keyboard/nerd/keymap_ansi150.c
new file mode 100644
index 0000000000..645ad6a83d
--- /dev/null
+++ b/keyboard/nerd/keymap_ansi150.c
@@ -0,0 +1,39 @@
+#include "keymap_common.h"
+#include "action_layer.h"
+#include "backlight.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* Layer 0: Default */
+    KEYMAP_ANSI150(GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+                   TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
+                   ESC, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
+                   LSFT,     Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,      \
+                   LCTL,LGUI,LALT,          SPC,                          RALT,FN0 ,RCTL),
+    /* Layer 1: Arrow keys */
+    KEYMAP_ANSI150(TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+                   UP,       TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
+                   LEFT,DOWN,RGHT,          TRNS,                         TRNS,TRNS,TRNS),
+    /* Layer 2: Space Fn */
+    KEYMAP_ANSI150(TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+                   TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
+                   TRNS,TRNS,TRNS,          FN1,                          TRNS,TRNS,TRNS),
+    /* Layer 3: Functions */
+    KEYMAP_ANSI150(SLEP,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, FN4,  \
+                   TRNS,TRNS,UP,  END, PSCR,SLCK,BRK, TRNS,INS, HOME,TRNS,VOLD,VOLU,FN5,  \
+                   CAPS,LEFT,DOWN,RGHT,PGDN,TRNS,LEFT,DOWN,UP  ,RGHT,TRNS,TRNS,     TRNS, \
+                   TRNS,     TRNS,DEL, TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
+                   MPRV,MPLY,MNXT,          TRNS,                          FN2,TRNS,FN3),
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(3),                // Switch to function layer
+    [1] = ACTION_LAYER_TAP_KEY(3, KC_SPACE),        // Switch to function layer (Space Fn)
+    [2] = ACTION_LAYER_TOGGLE(1),                   // Toggle "Arrow keys" layer
+    [3] = ACTION_LAYER_TOGGLE(2),                   // Toggle "Space fn" layer
+    [4] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_SWITCH), // Toggle switch leds
+    [5] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_PCB),    // Toggle pcb leds
+};
diff --git a/keyboard/nerd/keymap_common.c b/keyboard/nerd/keymap_common.c
new file mode 100644
index 0000000000..29ec4e53ef
--- /dev/null
+++ b/keyboard/nerd/keymap_common.c
@@ -0,0 +1,29 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include "keymap_common.h"
+
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+    return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+}
+
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
+}
diff --git a/keyboard/nerd/keymap_common.h b/keyboard/nerd/keymap_common.h
new file mode 100644
index 0000000000..2d801654da
--- /dev/null
+++ b/keyboard/nerd/keymap_common.h
@@ -0,0 +1,67 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef KEYMAP_COMMON_H
+#define KEYMAP_COMMON_H
+
+#include <stdint.h>
+#include <avr/pgmspace.h>
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "print.h"
+#include "debug.h"
+#include "keymap.h"
+
+extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+#define KEYMAP( \
+        K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
+        K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
+        K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, K71, K65, \
+        K07, K79, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, K67, \
+        K06, K05, K78,                K70,                K72, K73, K74, K75  \
+) { \
+/*          0         1         2         3         4         5         6         7         8         9      */\
+/* 0 */ { KC_NO,    KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_NO },   \
+/* 1 */ { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_NO,    KC_NO },   \
+/* 2 */ { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_NO,    KC_NO },   \
+/* 3 */ { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_NO,    KC_NO },   \
+/* 4 */ { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_NO,    KC_NO },   \
+/* 5 */ { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, KC_NO,    KC_NO },   \
+/* 6 */ { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, KC_NO,    KC_NO },   \
+/* 7 */ { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_NO,    KC_NO,    KC_##K78, KC_##K79 } \
+}
+
+#define KEYMAP_ANSI150( \
+        K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
+        K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
+        K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64,      K65, \
+        K07,      K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66,      \
+        K06, K05, K78,                K70,                     K73, K74, K75  \
+) KEYMAP( \
+        K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
+        K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
+        K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, NO,  K65, \
+        K07, NO,  K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, NO,  \
+        K06, K05, K78,                K70,                NO,  K73, K74, K75  \
+)
+
+#endif // KEYMAP_COMMON_H
diff --git a/keyboard/nerd/led.c b/keyboard/nerd/led.c
new file mode 100644
index 0000000000..7d9ce6d878
--- /dev/null
+++ b/keyboard/nerd/led.c
@@ -0,0 +1,25 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <avr/io.h>
+#include "stdint.h"
+#include "led.h"
+
+void led_set(uint8_t usb_led)
+{
+    (usb_led & (1<<USB_LED_CAPS_LOCK)) ? backlight_caps_enable() : backlight_caps_disable();
+}
diff --git a/keyboard/nerd/matrix.c b/keyboard/nerd/matrix.c
new file mode 100644
index 0000000000..f0ffe772da
--- /dev/null
+++ b/keyboard/nerd/matrix.c
@@ -0,0 +1,220 @@
+/*
+Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+#include "backlight.h"
+
+
+#ifndef DEBOUNCE
+#   define DEBOUNCE 5
+#endif
+static uint8_t debouncing = DEBOUNCE;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static uint16_t read_inputs(void);
+static void init_inputs(void);
+static void init_outputs(void);
+static void reset_inputs(void);
+static void reset_outputs(void);
+static void select_output(uint8_t col);
+
+inline
+uint8_t matrix_rows(void)
+{
+    return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+    return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+    backlight_init_ports();
+    init_inputs();
+    init_outputs();
+
+    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+        matrix[i] = 0;
+        matrix_debouncing[i] = 0;
+    }
+}
+
+uint8_t matrix_scan(void)
+{
+    for (uint8_t col = 0; col < MATRIX_COLS; col++) {
+        reset_inputs();
+        reset_outputs();
+        select_output(col);
+        _delay_us(3);
+        uint16_t rows = read_inputs();
+        for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+            bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
+            bool curr_bit = rows & (1<<row);
+            if (prev_bit != curr_bit) {
+                matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
+                if (debouncing) {
+                    dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
+                }
+                debouncing = DEBOUNCE;
+            }
+        }
+    }
+
+    if (debouncing) {
+        if (--debouncing) {
+            _delay_ms(1);
+        } else {
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+                matrix[i] = matrix_debouncing[i];
+            }
+        }
+    }
+
+    return 1;
+}
+
+bool matrix_is_modified(void)
+{
+    if (debouncing) return false;
+    return true;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+    return (matrix[row] & ((matrix_row_t)1<<col));
+}
+
+inline
+matrix_row_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void matrix_print(void)
+{
+    print("\nr/c 0123456789ABCDEF\n");
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+        phex(row); print(": ");
+        pbin_reverse16(matrix_get_row(row));
+        print("\n");
+    }
+}
+
+uint8_t matrix_key_count(void)
+{
+    uint8_t count = 0;
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        count += bitpop16(matrix[i]);
+    }
+    return count;
+}
+
+static void init_inputs(void)
+{
+    DDRE &= ~0b01000000; // PE6 (Col 0)
+    DDRB &= ~0b00001111; // PB0 (Col 1), PB1 (Col 2), PB2 (Col 3), PB3 (Col 4)
+    DDRF &= ~0b00000001; // PF0 (Col 5)
+    DDRD &= ~0b00100001; // PD0 (Col 6), PD5 (Col 7)
+}
+
+static uint16_t read_inputs(void)
+{
+    return (PINE&(1<<6) ? 0 : (1<<0)) |  // PE6 (Row 0)
+           (PINB&(1<<0) ? 0 : (1<<1)) |  // PB0 (Row 1)
+           (PINB&(1<<1) ? 0 : (1<<2)) |  // PB1 (Row 2)
+           (PINB&(1<<2) ? 0 : (1<<3)) |  // PB2 (Row 3)
+           (PINB&(1<<3) ? 0 : (1<<4)) |  // PB3 (Row 4)
+           (PINF&(1<<0) ? 0 : (1<<5)) |  // PF0 (Row 5)
+           (PIND&(1<<0) ? 0 : (1<<6)) |  // PD0 (Row 6)
+           (PIND&(1<<5) ? 0 : (1<<7));   // PD5 (Row 7)
+}
+
+static void reset_inputs(void)
+{
+    PORTE |= 0b01000000; // PE6 (Col 0)
+    PORTB |= 0b00001111; // PB0 (Col 1), PB1 (Col 2), PB2 (Col 3), PB3 (Col 4)
+    PORTF |= 0b00000001; // PF0 (Col 5)
+    PORTD |= 0b00100001; // PD0 (Col 6), PD5 (Col 7)
+}
+
+static void init_outputs(void)
+{
+    DDRB |= 0b00010000; // PB4 (Row 0)
+    DDRE |= 0b00000100; // PE2 (Row 1)
+    DDRF |= 0b11110010; // PF4 (Row 2), PF7 (Row 3), PF1 (Row 4), PF6 (Row 5), PF5 (Row 7)
+    DDRC |= 0b11000000; // PC6 (Row 6), PC7 (Row 9)
+    DDRD |= 0b10000000; // PD7 (Row 8)
+}
+
+static void reset_outputs(void)
+{
+    PORTB |= 0b00010000; // PB4 (Row 0)
+    PORTE |= 0b00000100; // PE2 (Row 1)
+    PORTF |= 0b11110010; // PF4 (Row 2), PF7 (Row 3), PF1 (Row 4), PF6 (Row 5), PF5 (Row 7)
+    PORTC |= 0b11000000; // PC6 (Row 6), PC7 (Row 9)
+    PORTD |= 0b10000000; // PD7 (Row 8)
+}
+
+static void select_output(uint8_t col)
+{
+    switch (col) {
+        case 0:
+            PORTB &= ~(1<<4);
+            break;
+        case 1:
+            PORTE &= ~(1<<2);
+            break;
+        case 2:
+            PORTF &= ~(1<<4);
+            break;
+        case 3:
+            PORTF &= ~(1<<7);
+            break;
+        case 4:
+            PORTF &= ~(1<<1);
+            break;
+        case 5:
+            PORTF &= ~(1<<6);
+            break;
+        case 6:
+            PORTC &= ~(1<<6);
+            break;
+        case 7:
+            PORTF &= ~(1<<5);
+            break;
+        case 8:
+            PORTD &= ~(1<<7);
+            break;
+        case 9:
+            PORTC &= ~(1<<7);
+            break;
+    }
+}

From 2d740203318e2b0164e584a853bd0172dd9127cb Mon Sep 17 00:00:00 2001
From: Ralf Schmitt <ralf@bunkertor.net>
Date: Sun, 23 Nov 2014 13:29:07 +0100
Subject: [PATCH 64/95] Added NerD 80% (TKL) support

---
 keyboard/nerd/Makefile            | 17 ++++---
 keyboard/nerd/README.md           |  9 +++-
 keyboard/nerd/backlight.c         |  6 +++
 keyboard/nerd/config.h            |  4 +-
 keyboard/nerd/keymap_60_ansi150.c | 30 ++++++++++++
 keyboard/nerd/keymap_80_ansi150.c | 33 ++++++++++++++
 keyboard/nerd/keymap_ansi150.c    | 39 ----------------
 keyboard/nerd/keymap_common.h     | 76 ++++++++++++++++++++-----------
 keyboard/nerd/led.c               | 25 ----------
 keyboard/nerd/matrix.c            | 21 +++++----
 10 files changed, 149 insertions(+), 111 deletions(-)
 create mode 100644 keyboard/nerd/keymap_60_ansi150.c
 create mode 100644 keyboard/nerd/keymap_80_ansi150.c
 delete mode 100644 keyboard/nerd/keymap_ansi150.c
 delete mode 100644 keyboard/nerd/led.c

diff --git a/keyboard/nerd/Makefile b/keyboard/nerd/Makefile
index 10fa144fbb..5fd382841f 100644
--- a/keyboard/nerd/Makefile
+++ b/keyboard/nerd/Makefile
@@ -50,9 +50,15 @@ TARGET_DIR = .
 # project specific files
 SRC =	keymap_common.c \
 	matrix.c \
-	backlight.c \
-	led.c \
-	keymap_ansi150.c
+	backlight.c
+
+ifdef LAYOUT
+   OPT_DEFS += -DNERD_LAYOUT_$(LAYOUT)
+endif
+
+ifdef KEYMAP
+    SRC := keymap_$(LAYOUT)_$(KEYMAP).c $(SRC)
+endif
 
 CONFIG_H = config.h
 
@@ -103,7 +109,7 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096
 #   comment out to disable the options.
 #
 BOOTMAGIC_ENABLE = yes	# Virtual DIP switch configuration(+1000)
-#MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
+MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
 EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
 CONSOLE_ENABLE = yes	# Console for debug(+400)
 COMMAND_ENABLE = yes    # Commands for debug and configuration
@@ -118,6 +124,3 @@ VPATH += $(TOP_DIR)
 include $(TOP_DIR)/protocol/lufa.mk
 include $(TOP_DIR)/common.mk
 include $(TOP_DIR)/rules.mk
-
-winkey: OPT_DEFS += -DLAYOUT_WINKEY
-winkey: all
diff --git a/keyboard/nerd/README.md b/keyboard/nerd/README.md
index 0130fe49fd..5b4acd3ba9 100644
--- a/keyboard/nerd/README.md
+++ b/keyboard/nerd/README.md
@@ -17,6 +17,7 @@ Supported features
 
 * All layout options are supported
 * All leds are supported
+* 60% and 80% (TKL) pcbs are supported
 
 
 Changing Bootloader
@@ -35,7 +36,13 @@ won't work anymore and you'll lose your warrenty. GON won't provide any support
 Build
 -----
 
-Move to this directory then just run `make`.
+For building you have to specify two build-options, LAYOUT and KEYMAP. The layout option defines
+pcb layout and can be either 60% or 80% at the momemnt. The keymap option selects your
+preferred keymapping.
+
+Move to this directory then just run `make LAYOUT=60 KEYMAP=ansi150`
+
+to compile a firmware for a 60% pcb with ANSI 150 key mapping.
 
 
 Jump to Bootloader
diff --git a/keyboard/nerd/backlight.c b/keyboard/nerd/backlight.c
index 804b4848a6..2dc85c7532 100644
--- a/keyboard/nerd/backlight.c
+++ b/keyboard/nerd/backlight.c
@@ -17,12 +17,18 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <avr/io.h>
 #include "backlight.h"
+#include "led.h"
 
 void backlight_init_ports()
 {
     DDRB |= 0b11100000; // PB7 (switch), PB6 (pcb), PB5 (caps)
 }
 
+void led_set(uint8_t usb_led)
+{
+    (usb_led & (1<<USB_LED_CAPS_LOCK)) ? backlight_caps_enable() : backlight_caps_disable();
+}
+
 void backlight_set(uint8_t level)
 {
     (level & BACKLIGHT_SWITCH) ? backlight_switch_enable() : backlight_switch_disable();
diff --git a/keyboard/nerd/config.h b/keyboard/nerd/config.h
index 7eab1cb090..ac2e6989d6 100644
--- a/keyboard/nerd/config.h
+++ b/keyboard/nerd/config.h
@@ -26,11 +26,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define DESCRIPTION     t.m.k. keyboard firmware for NerD
 
 /* key matrix size */
-#define MATRIX_ROWS 8
+#define MATRIX_ROWS 9
 #define MATRIX_COLS 10
 
 /* Set 0 if debouncing isn't needed */
-#define DEBOUNCE    5
+#define DEBOUNCE 5
 
 /* number of backlight levels */
 #define BACKLIGHT_LEVELS 2
diff --git a/keyboard/nerd/keymap_60_ansi150.c b/keyboard/nerd/keymap_60_ansi150.c
new file mode 100644
index 0000000000..c43d195332
--- /dev/null
+++ b/keyboard/nerd/keymap_60_ansi150.c
@@ -0,0 +1,30 @@
+#include "keymap_common.h"
+#include "backlight.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* Layer 0: Default */
+    KEYMAP_ANSI150(GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
+                   TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
+                   ESC, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
+                   LSFT,     Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,      \
+                   LCTL,LGUI,LALT,          SPC,                          RALT,FN0 ,RCTL),
+    /* Layer 1: Space Fn */
+    KEYMAP_ANSI150(TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
+                   TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
+                   TRNS,TRNS,TRNS,          FN1,                          TRNS,FN0, TRNS),
+    /* Layer 2: Functions */
+    KEYMAP_ANSI150(SLEP,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, MUTE, \
+                   TRNS,BTN1,MS_U,BTN3,PSCR,SLCK,BRK, HOME,INS, END, MPLY,VOLD,VOLU,FN3,  \
+                   CAPS,MS_L,MS_D,MS_R,PGDN,TRNS,LEFT,DOWN,UP  ,RGHT,MPRV,MNXT,     FN2,  \
+                   UP,       TRNS,DEL, TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
+                   LEFT,DOWN,RGHT,          TRNS,                         TRNS,TRNS,TRNS)
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(2),
+    [1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE),
+    [2] = ACTION_LAYER_TOGGLE(1),
+    [3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_SWITCH)
+};
diff --git a/keyboard/nerd/keymap_80_ansi150.c b/keyboard/nerd/keymap_80_ansi150.c
new file mode 100644
index 0000000000..a2ba279c55
--- /dev/null
+++ b/keyboard/nerd/keymap_80_ansi150.c
@@ -0,0 +1,33 @@
+#include "keymap_common.h"
+#include "backlight.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* Layer 0: Default */
+    KEYMAP_ANSI150(ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,   PSCR,SLCK, BRK,  \
+                   GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,  INS, HOME, PGUP, \
+                   TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN, \
+                   CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,                    \
+                   LSFT,     Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,            UP,         \
+                   LCTL,LGUI,LALT,               SPC,                     RALT,FN0, RCTL,  LEFT,DOWN,RGHT),
+    /* Layer 1: Space Fn */
+    KEYMAP_ANSI150(TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,  TRNS,TRNS,TRNS,  \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,  TRNS,TRNS,TRNS,  \
+                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,  TRNS,TRNS,TRNS,  \
+                    ESC,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,                   \
+                   TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,            TRNS,       \
+                   TRNS,TRNS,TRNS,               FN1,                     TRNS,FN0, TRNS,  TRNS,TRNS,TRNS),
+    /* Layer 2: Functions */
+    KEYMAP_ANSI150(SLEP,     MYCM,WSCH,WHOM,MAIL,VOLD,VOLU,MUTE,MSEL,MPLY,MPRV,MNXT,MSTP,  TRNS,TRNS,TRNS,  \
+                   TRNS,TRNS,TRNS,TRNS,END, TRNS,TRNS,TRNS,TRNS,TRNS,HOME,TRNS,TRNS,TRNS,  TRNS,TRNS,TRNS,  \
+                   TRNS,BTN1,MS_U,BTN3,PSCR,SLCK,TRNS,TRNS,INS, TRNS,TRNS,TRNS,TRNS,FN3,   TRNS,TRNS,TRNS,  \
+                   CAPS,MS_L,MS_D,MS_R,PGDN,TRNS,LEFT,DOWN,UP  ,RGHT,TRNS,TRNS,     FN2,                    \
+                   TRNS,     TRNS,DEL, TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,            TRNS,       \
+                   TRNS,TRNS,TRNS,               TRNS,                    TRNS,TRNS,TRNS,  TRNS,TRNS,TRNS),
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(2),
+    [1] = ACTION_LAYER_TAP_KEY(2, KC_SPACE),
+    [2] = ACTION_LAYER_TOGGLE(1),
+    [3] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_SWITCH)
+};
diff --git a/keyboard/nerd/keymap_ansi150.c b/keyboard/nerd/keymap_ansi150.c
deleted file mode 100644
index 645ad6a83d..0000000000
--- a/keyboard/nerd/keymap_ansi150.c
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "keymap_common.h"
-#include "action_layer.h"
-#include "backlight.h"
-
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    /* Layer 0: Default */
-    KEYMAP_ANSI150(GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-                   TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
-                   ESC, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
-                   LSFT,     Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,      \
-                   LCTL,LGUI,LALT,          SPC,                          RALT,FN0 ,RCTL),
-    /* Layer 1: Arrow keys */
-    KEYMAP_ANSI150(TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-                   UP,       TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
-                   LEFT,DOWN,RGHT,          TRNS,                         TRNS,TRNS,TRNS),
-    /* Layer 2: Space Fn */
-    KEYMAP_ANSI150(TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-                   TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-                   TRNS,     TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
-                   TRNS,TRNS,TRNS,          FN1,                          TRNS,TRNS,TRNS),
-    /* Layer 3: Functions */
-    KEYMAP_ANSI150(SLEP,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, FN4,  \
-                   TRNS,TRNS,UP,  END, PSCR,SLCK,BRK, TRNS,INS, HOME,TRNS,VOLD,VOLU,FN5,  \
-                   CAPS,LEFT,DOWN,RGHT,PGDN,TRNS,LEFT,DOWN,UP  ,RGHT,TRNS,TRNS,     TRNS, \
-                   TRNS,     TRNS,DEL, TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
-                   MPRV,MPLY,MNXT,          TRNS,                          FN2,TRNS,FN3),
-};
-
-const uint16_t PROGMEM fn_actions[] = {
-    [0] = ACTION_LAYER_MOMENTARY(3),                // Switch to function layer
-    [1] = ACTION_LAYER_TAP_KEY(3, KC_SPACE),        // Switch to function layer (Space Fn)
-    [2] = ACTION_LAYER_TOGGLE(1),                   // Toggle "Arrow keys" layer
-    [3] = ACTION_LAYER_TOGGLE(2),                   // Toggle "Space fn" layer
-    [4] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_SWITCH), // Toggle switch leds
-    [5] = ACTION_BACKLIGHT_LEVEL(BACKLIGHT_PCB),    // Toggle pcb leds
-};
diff --git a/keyboard/nerd/keymap_common.h b/keyboard/nerd/keymap_common.h
index 2d801654da..e116635918 100644
--- a/keyboard/nerd/keymap_common.h
+++ b/keyboard/nerd/keymap_common.h
@@ -33,35 +33,57 @@ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
 extern const uint16_t fn_actions[];
 
 #define KEYMAP( \
-        K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
-        K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
-        K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, K71, K65, \
-        K07, K79, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, K67, \
-        K06, K05, K78,                K70,                K72, K73, K74, K75  \
+        K08,      K09, K18, K19, K28, K29, K38, K39, K48, K49, K58, K59, K68,    K69, K88, K89, \
+        K00, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61,    K80, K81, K84, \
+        K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63,    K82, K83, K85, \
+        K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, K71, K65,                   \
+        K07, K79, K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, K67,         K86,      \
+        K06, K05, K78,                K70,                K72, K73, K74, K75,    K76, K77, K87  \
 ) { \
-/*          0         1         2         3         4         5         6         7         8         9      */\
-/* 0 */ { KC_NO,    KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_NO },   \
-/* 1 */ { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_NO,    KC_NO },   \
-/* 2 */ { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_NO,    KC_NO },   \
-/* 3 */ { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_NO,    KC_NO },   \
-/* 4 */ { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_NO,    KC_NO },   \
-/* 5 */ { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, KC_NO,    KC_NO },   \
-/* 6 */ { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, KC_NO,    KC_NO },   \
-/* 7 */ { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_NO,    KC_NO,    KC_##K78, KC_##K79 } \
+      { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09 }, \
+      { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19 }, \
+      { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29 }, \
+      { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39 }, \
+      { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47, KC_##K48, KC_##K49 }, \
+      { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57, KC_##K58, KC_##K59 }, \
+      { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67, KC_##K68, KC_##K69 }, \
+      { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77, KC_##K78, KC_##K79 }, \
+      { KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86, KC_##K87, KC_##K88, KC_##K89 }  \
 }
 
-#define KEYMAP_ANSI150( \
-        K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
-        K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
-        K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64,      K65, \
-        K07,      K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66,      \
-        K06, K05, K78,                K70,                     K73, K74, K75  \
-) KEYMAP( \
-        K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
-        K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
-        K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, NO,  K65, \
-        K07, NO,  K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, NO,  \
-        K06, K05, K78,                K70,                NO,  K73, K74, K75  \
-)
+#ifdef NERD_LAYOUT_60
+  #define KEYMAP_ANSI150( \
+          K08, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61, \
+          K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63, \
+          K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64,      K65, \
+          K07,      K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66,      \
+          K06, K05, K78,                K70,                     K73, K74, K75  \
+  ) KEYMAP( \
+          K08,      NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,  NO,   NO,  NO,  NO,  \
+          NO,  K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61,  NO,  NO,  NO,  \
+          K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63,  NO,  NO,  NO,  \
+          K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, NO,  K65,                 \
+          K07, NO,  K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, NO,        NO,       \
+          K06, K05, K78,                K70,                NO,  K73, K74, K75,  NO,  NO,  NO   \
+  )
+#endif
+
+#ifdef NERD_LAYOUT_80
+  #define KEYMAP_ANSI150( \
+          K08,      K09, K18, K19, K28, K29, K38, K39, K48, K49, K58, K59, K68,  K69, K88, K89, \
+          K00, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61,  K80, K81, K84, \
+          K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63,  K82, K83, K85, \
+          K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64,      K65,                 \
+          K07,      K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66,            K86,      \
+          K06, K05, K78,                K70,                     K73, K74, K75,  K76, K77, K87  \
+  ) KEYMAP( \
+          K08,      K09, K18, K19, K28, K29, K38, K39, K48, K49, K58, K59, K68,  K69, K88, K89, \
+          K00, K01, K10, K11, K20, K21, K30, K31, K40, K41, K50, K51, K60, K61,  K80, K81, K84, \
+          K02, K03, K12, K13, K22, K23, K32, K33, K42, K43, K52, K53, K62, K63,  K82, K83, K85, \
+          K04, K14, K15, K24, K25, K34, K35, K44, K45, K54, K55, K64, NO,  K65,                 \
+          K07, NO,  K16, K17, K26, K27, K36, K37, K46, K47, K56, K57, K66, NO,        K86,      \
+          K06, K05, K78,                K70,                NO,  K73, K74, K75,  K76, K77, K87  \
+  )
+#endif
 
 #endif // KEYMAP_COMMON_H
diff --git a/keyboard/nerd/led.c b/keyboard/nerd/led.c
deleted file mode 100644
index 7d9ce6d878..0000000000
--- a/keyboard/nerd/led.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-Copyright 2014 Ralf Schmitt <ralf@bunkertor.net>
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program.  If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include <avr/io.h>
-#include "stdint.h"
-#include "led.h"
-
-void led_set(uint8_t usb_led)
-{
-    (usb_led & (1<<USB_LED_CAPS_LOCK)) ? backlight_caps_enable() : backlight_caps_disable();
-}
diff --git a/keyboard/nerd/matrix.c b/keyboard/nerd/matrix.c
index f0ffe772da..eb5a9ab4f1 100644
--- a/keyboard/nerd/matrix.c
+++ b/keyboard/nerd/matrix.c
@@ -142,19 +142,20 @@ static void init_inputs(void)
     DDRE &= ~0b01000000; // PE6 (Col 0)
     DDRB &= ~0b00001111; // PB0 (Col 1), PB1 (Col 2), PB2 (Col 3), PB3 (Col 4)
     DDRF &= ~0b00000001; // PF0 (Col 5)
-    DDRD &= ~0b00100001; // PD0 (Col 6), PD5 (Col 7)
+    DDRD &= ~0b00100011; // PD0 (Col 6), PD1 (Col 8 TKL), PD5 (Col 7)
 }
 
 static uint16_t read_inputs(void)
 {
-    return (PINE&(1<<6) ? 0 : (1<<0)) |  // PE6 (Row 0)
-           (PINB&(1<<0) ? 0 : (1<<1)) |  // PB0 (Row 1)
-           (PINB&(1<<1) ? 0 : (1<<2)) |  // PB1 (Row 2)
-           (PINB&(1<<2) ? 0 : (1<<3)) |  // PB2 (Row 3)
-           (PINB&(1<<3) ? 0 : (1<<4)) |  // PB3 (Row 4)
-           (PINF&(1<<0) ? 0 : (1<<5)) |  // PF0 (Row 5)
-           (PIND&(1<<0) ? 0 : (1<<6)) |  // PD0 (Row 6)
-           (PIND&(1<<5) ? 0 : (1<<7));   // PD5 (Row 7)
+    return (PINE&(1<<6) ? 0 : (1<<0)) |  // PE6 (Col 0)
+           (PINB&(1<<0) ? 0 : (1<<1)) |  // PB0 (Col 1)
+           (PINB&(1<<1) ? 0 : (1<<2)) |  // PB1 (Col 2)
+           (PINB&(1<<2) ? 0 : (1<<3)) |  // PB2 (Col 3)
+           (PINB&(1<<3) ? 0 : (1<<4)) |  // PB3 (Col 4)
+           (PINF&(1<<0) ? 0 : (1<<5)) |  // PF0 (Col 5)
+           (PIND&(1<<0) ? 0 : (1<<6)) |  // PD0 (Col 6)
+           (PIND&(1<<5) ? 0 : (1<<7)) |  // PD5 (Col 7)
+           (PIND&(1<<1) ? 0 : (1<<8));   // PD1 (Col 8 TKL)
 }
 
 static void reset_inputs(void)
@@ -162,7 +163,7 @@ static void reset_inputs(void)
     PORTE |= 0b01000000; // PE6 (Col 0)
     PORTB |= 0b00001111; // PB0 (Col 1), PB1 (Col 2), PB2 (Col 3), PB3 (Col 4)
     PORTF |= 0b00000001; // PF0 (Col 5)
-    PORTD |= 0b00100001; // PD0 (Col 6), PD5 (Col 7)
+    PORTD |= 0b00100011; // PD0 (Col 6), PD1 (Col 8 TKL), PD5 (Col 7)
 }
 
 static void init_outputs(void)

From 07b54cb513dbc14322158ca531596fe96dd9df0c Mon Sep 17 00:00:00 2001
From: Ralf Schmitt <ralf@bunkertor.net>
Date: Sun, 14 Dec 2014 12:15:17 +0100
Subject: [PATCH 65/95] Added missing keyboards to main README

---
 README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/README.md b/README.md
index e918faa0df..312886402d 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,8 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 * [Lightsaber](keyboard/lightsaber/)        - Korean custom keyboard
 * [Infinity](keyboard/infinity/)            - Massdrop [Infinity keyboard][Infinity]
 * [NerD](keyboard/nerd/)                    - Korean custom keyboard
+* [KittenPaw](keyboard/kittenpaw)           - Custom Majestouch controller
+* [Lightpad](keyboard/lightpad)             - Korean custom keypad
 
 [GH_macway]:    http://geekhack.org/showwiki.php?title=Island:11930
 [GH_hhkb]:      http://geekhack.org/showwiki.php?title=Island:12047

From 40fd75e5ededaa4800419426295f35ff6bccb138 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Sat, 17 Jan 2015 15:34:33 +0900
Subject: [PATCH 66/95] hhkb: Update RN-42 docs

---
 keyboard/hhkb/rn42/PowerSave.txt | 12 +++++++
 keyboard/hhkb/rn42/RN42.txt      | 62 +++++++++++++++++++++++++++-----
 2 files changed, 66 insertions(+), 8 deletions(-)

diff --git a/keyboard/hhkb/rn42/PowerSave.txt b/keyboard/hhkb/rn42/PowerSave.txt
index 8aea1c6dd2..4b9c8f415d 100644
--- a/keyboard/hhkb/rn42/PowerSave.txt
+++ b/keyboard/hhkb/rn42/PowerSave.txt
@@ -10,6 +10,18 @@ Battery drive:
 
 USB powered:
     40.0mA
+    52mA    01/17
+
+Other keyboards:
+HHKB Pro    55mA
+HHKB Pro2   140mA
+HHKB Pro    42mA(Alt)
+HHKB Pro2   52mA(Alt BT controller USB mode)
+HHKB Pro2   88mA(Alt BT controller BT mode connected)
+HHKB Pro2   68mA(Alt BT controller BT mode config mode)
+Poker X     6mA
+Infinity    24mA(TMK)
+            65mA(kiibohd)
 
 
 HHKB key switch power control
diff --git a/keyboard/hhkb/rn42/RN42.txt b/keyboard/hhkb/rn42/RN42.txt
index ace30da4ed..64c3fdd4ec 100644
--- a/keyboard/hhkb/rn42/RN42.txt
+++ b/keyboard/hhkb/rn42/RN42.txt
@@ -3,24 +3,70 @@ RN-42 Bluetooth Module Support
 Bluetooth controller board works with HHKB Pro2, JP, Type-S and Type-S JP and it supports both USB and Bluetooth as keyboard output protocol. Bluetooth module Roving Networks/Microchip RN-42 is installed on the board.
 
 
+RN-42:
+http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
+
+
+Capabitlities:
+- USB keyboard functions
+    completely equivarent to USB controller including mouse keys and NKRO.
+- Switching between USB and Bluetooth
+    You can switch the two connections with BT switch or key combination.
+- RN-42 config mode
+    You can change power/connection configuration of the module if needed.
+- Low battery alert
+    Red LED turns on when low voltage.
+- RN-42 status indicator
+    LED indicates status of Bluetooth connection.
+- Pairing
+    The module stores up to 8 connections.
+- Auto connect
+    The module connects the last connected device automatically.
+- iOS support
+    works as keyboard with iPhone5. No tested completely.
+- Android support
+    works as keyboard and mouse with Nexus5. No tested completely.
+- Mouse keys over BT
+    Note that iOS doesn't accept mouse device.
+
+
 Limitations:
-- short battery life
-- connection switching
-    the module always connects to the last linked device. Remote address setting does not work as expected.
-- HHKB JP requires case modification for power switch and LEDs.
+- Short battery life
+    Around 12hr with 1000mAh
+- No connection switching
+    RN-42 auto-connects to the last connected device.
+    Some of consumer products can switch between devices, for example Logitech K480.
+        http://www.logitech.com/en-us/product/multi-device-keyboard-k480?crid=26
+- HHKB JP requires case modification for BT switch and LEDs.
     without switch power controlled by MCU? Probably using 3.3V regulator enable pin power of RN-42 can be controlled.
-- Wiress certification of RN-42
-    Japan, Korea, Taiwan, Europe, FCC, Canada
-    http://www.microchip.com/wwwproducts/Devices.aspx?product=RN42
 
 NOTE:
-- Lipo battery is not included. Cannot ship it from Japan due to regulations.
+- LIPO BATTERY IS VERY DANGEROUS, TAKE EXTRA CARE OF YOUR SAFETY AND PROPERTY.
+- RN-42 version 6.15 is supported.
+- No NKRO over Bluetooth
+- Check you country's wiress regulation and certification of RN-42.
 
 Bugs:
 
 Todos:
 
 
+Lipo Battery
+------------
+You can use 3.7V Lithium Ion battery with JST PH 2pin connector and protection circuit.
+Battery space inside HHKB is around 54mm x 50mm and its height is 7mm.
+
+Sparkfun 850mAh
+https://www.sparkfun.com/products/341
+Sparkfun 1000mAh
+https://www.sparkfun.com/products/339
+
+Sparkfun 2000mAh battery won't fit due to its size.
+
+Learn about Lipo battery:
+https://learn.adafruit.com/li-ion-and-lipoly-batteries
+
+
 
 
 

From 507e0636f03f7d30f90782353f6f3509006ec696 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Mon, 19 Jan 2015 10:20:20 +0900
Subject: [PATCH 67/95] Revert "Changed hotkey for bootloader jump"

This reverts commit f31cbc7219c9a1903331771c10056302817e68ca.
---
 common/command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/command.c b/common/command.c
index c50d3eb4b1..1a507e3a46 100644
--- a/common/command.c
+++ b/common/command.c
@@ -216,7 +216,7 @@ static bool command_common(uint8_t code)
             print("C> ");
             command_state = CONSOLE;
             break;
-        case KC_B:
+        case KC_PAUSE:
             clear_keyboard();
             print("\n\nJump to bootloader... ");
             _delay_ms(1000);

From 1cda7b79fbae90b3dc40ac862f3c14bfd2f1f679 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Mon, 19 Jan 2015 10:35:06 +0900
Subject: [PATCH 68/95] Fix typo 'keyobard' #166

---
 converter/adb_usb/README.md | 2 +-
 keyboard/hhkb/rn42/MEMO.txt | 2 +-
 protocol/adb.c              | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/converter/adb_usb/README.md b/converter/adb_usb/README.md
index defc477e2c..21ad318c1d 100644
--- a/converter/adb_usb/README.md
+++ b/converter/adb_usb/README.md
@@ -88,7 +88,7 @@ modifiers except for GUI key(Windows/Command).
 And most ADB keyboard has no diodes in its matrix so they are not NKRO,
 though ADB protocol itself supports it. See protocol/adb.c for more info.
 
-If keyobard has ISO layout you need to use ISO keymap with `make KEYMAP=iso`. With ANSI
+If keyboard has ISO layout you need to use ISO keymap with `make KEYMAP=iso`. With ANSI
 keymap you will suffer from swapped keys problem.
 
 https://github.com/tmk/tmk_keyboard/issues/35
diff --git a/keyboard/hhkb/rn42/MEMO.txt b/keyboard/hhkb/rn42/MEMO.txt
index f772c4cb53..0363c2f433 100644
--- a/keyboard/hhkb/rn42/MEMO.txt
+++ b/keyboard/hhkb/rn42/MEMO.txt
@@ -161,7 +161,7 @@ TROUBLE SHOOT
 07/16   After fix of voltage dividor on GPIO6, had a trouble that it could not send a char to BT module, though could receive.
         Found R8 had wrong 1K resistor and changed to 10K, after that it can send to the module again. Not sure how it had sent with the wrong 1K before.
 
-07/18   On Linux, had an USB related trouble; keyobard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
+07/18   On Linux, had an USB related trouble; keyboard or console didn't work for some reason. Changing PID cured this problem. Very annoying, took very long time before resolved it.
 
 12/07   rn42_rts() read 1 every time. R12 broke in open mode(no coductive), idk why, too much heat with soldering? and PF1 pin was not soldered.
         It resolved with resoldering PF1 and new resistor on R12.
diff --git a/protocol/adb.c b/protocol/adb.c
index f57afac937..bbff66df03 100644
--- a/protocol/adb.c
+++ b/protocol/adb.c
@@ -360,7 +360,7 @@ Commands
     3:  mice
 
     Registers:
-    0: application(keyobard uses this to store its data.)
+    0: application(keyboard uses this to store its data.)
     1: application
     2: application(keyboard uses this for LEDs and state of modifiers)
     3: status and command

From 771347c4a66a8ae1c377310a09d43d5a135ffd14 Mon Sep 17 00:00:00 2001
From: tmk <hasu@tmk-kbd.com>
Date: Mon, 19 Jan 2015 12:43:30 +0900
Subject: [PATCH 69/95] Add external projects using tmk_keyboard

---
 README.md | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 3dceb96398..2802625773 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,11 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 * [Lightpad](keyboard/lightpad)             - Korean custom keypad
 * [ghost_squid](keyboard/ghost_squid/)      - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt]
 
+### Extenal projects using tmk_keyboard
+* [ErgoDox_cub-uanic][cub-uanic]            - Split Ergonomic Keyboard [ErgoDox][ergodox_org]
+* [mcdox][mcdox_tmk]                        - [mcdox][mcdox]
+
+
 [GH_macway]:    http://geekhack.org/showwiki.php?title=Island:11930
 [GH_hhkb]:      http://geekhack.org/showwiki.php?title=Island:12047
 [GH_ps2]:       http://geekhack.org/showwiki.php?title=Island:14618
@@ -80,6 +85,10 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 [Infinity]:     https://www.massdrop.com/buy/infinity-keyboard-kit
 [ghost_squid]:  http://deskthority.net/wiki/Costar_replacement_controllers#The_Ghost_Squid
 [cmxt]:         http://gaming.coolermaster.com/en/products/keyboards/quickfirext/
+[ergodox_org]:  http://ergodox.org/
+[cub-uanic]:    https://github.com/cub-uanic/tmk_keyboard/tree/master/keyboard/ergodox
+[mcdox]:        https://github.com/DavidMcEwan/mcdox
+[mcdox_tmk]:    https://github.com/DavidMcEwan/tmk_keyboard/tree/master/keyboard/mcdox
 
 
 
@@ -284,4 +293,4 @@ Coding Style
 
 Other Keyboard Firmware Projects
 ------------------
-See [doc/other_projects.md](doc/other_projects.md).
+You can learn a lot about keyboard firmware from these. See [doc/other_projects.md](doc/other_projects.md).

From 012ec9e3794816e245acabac223c5be230ae67d3 Mon Sep 17 00:00:00 2001
From: Ralf Schmitt <ralf@bunkertor.net>
Date: Mon, 19 Jan 2015 20:10:49 +0100
Subject: [PATCH 70/95] NerD, turn BRK into PAUS to get bootloader jump back.

---
 keyboard/nerd/keymap_60_ansi150.c | 2 +-
 keyboard/nerd/keymap_80_ansi150.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/keyboard/nerd/keymap_60_ansi150.c b/keyboard/nerd/keymap_60_ansi150.c
index c43d195332..f85836ab55 100644
--- a/keyboard/nerd/keymap_60_ansi150.c
+++ b/keyboard/nerd/keymap_60_ansi150.c
@@ -16,7 +16,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
                    TRNS,TRNS,TRNS,          FN1,                          TRNS,FN0, TRNS),
     /* Layer 2: Functions */
     KEYMAP_ANSI150(SLEP,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, MUTE, \
-                   TRNS,BTN1,MS_U,BTN3,PSCR,SLCK,BRK, HOME,INS, END, MPLY,VOLD,VOLU,FN3,  \
+                   TRNS,BTN1,MS_U,BTN3,PSCR,SLCK,PAUS,HOME,INS, END, MPLY,VOLD,VOLU,FN3,  \
                    CAPS,MS_L,MS_D,MS_R,PGDN,TRNS,LEFT,DOWN,UP  ,RGHT,MPRV,MNXT,     FN2,  \
                    UP,       TRNS,DEL, TRNS,TRNS,PGUP,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,      \
                    LEFT,DOWN,RGHT,          TRNS,                         TRNS,TRNS,TRNS)
diff --git a/keyboard/nerd/keymap_80_ansi150.c b/keyboard/nerd/keymap_80_ansi150.c
index a2ba279c55..72a7d83c9b 100644
--- a/keyboard/nerd/keymap_80_ansi150.c
+++ b/keyboard/nerd/keymap_80_ansi150.c
@@ -3,9 +3,9 @@
 
 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     /* Layer 0: Default */
-    KEYMAP_ANSI150(ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,   PSCR,SLCK, BRK,  \
-                   GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,  INS, HOME, PGUP, \
-                   TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END,  PGDN, \
+    KEYMAP_ANSI150(ESC,      F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12,   PSCR,SLCK,PAUS,  \
+                   GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC,  INS, HOME,PGUP,  \
+                   TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS,  DEL, END, PGDN,  \
                    CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,                    \
                    LSFT,     Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,            UP,         \
                    LCTL,LGUI,LALT,               SPC,                     RALT,FN0, RCTL,  LEFT,DOWN,RGHT),

From e0f32742e9df2727409c3694c0bab893eb096971 Mon Sep 17 00:00:00 2001
From: Ralf Schmitt <ralf@bunkertor.net>
Date: Tue, 20 Jan 2015 20:18:33 +0100
Subject: [PATCH 71/95] Kitten Paw, fix main README link to project.

---
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 2802625773..dd03e1403d 100644
--- a/README.md
+++ b/README.md
@@ -55,7 +55,7 @@ You can find some keyboard specific projects under `converter` and `keyboard` di
 * [Lightsaber](keyboard/lightsaber/)        - Korean custom keyboard
 * [Infinity](keyboard/infinity/)            - Massdrop [Infinity keyboard][Infinity]
 * [NerD](keyboard/nerd/)                    - Korean custom keyboard
-* [KittenPaw](keyboard/kittenpaw)           - Custom Majestouch controller
+* [KittenPaw](keyboard/kitten_paw)          - Custom Majestouch controller
 * [Lightpad](keyboard/lightpad)             - Korean custom keypad
 * [ghost_squid](keyboard/ghost_squid/)      - [The Ghost Squid][ghost_squid] controller for [Cooler Master QuickFire XT][cmxt]
 

From 6f735ca1304e2d9f50ef7be1b6242a6062165d44 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Fri, 23 Jan 2015 12:11:28 -0500
Subject: [PATCH 72/95] Update README.md

---
 keyboard/planck/README.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/keyboard/planck/README.md b/keyboard/planck/README.md
index ddd080ff2f..cb009c005d 100644
--- a/keyboard/planck/README.md
+++ b/keyboard/planck/README.md
@@ -5,6 +5,8 @@ DIY/Assembled compact ortholinear keyboard by [Ortholinear Keyboards](http://ort
 ## Notable TMK forks (which some of the keymap files are from)
 - [Shane's Fork](https://github.com/shanecelis/tmk_keyboard/tree/master/keyboard/planck)
 - [Pierre's Fork](https://github.com/pcarrier/tmk_keyboard/blob/pcarrier/planck/keyboard/gh60/keymap_planck.c)
+- [Nathan's Fork](https://github.com/nathanrosspowell/tmk_keyboard/tree/planck-jack/keyboard/planck)
+- [Matthew's Fork](https://github.com/pepers/tmk_keyboard/tree/master/keyboard/planck_grid)
 
 ## Build
 Move to this directory then just run `make` like:

From adf7b56e6fe066992e75bf0c3330d94a7b39d97d Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Fri, 23 Jan 2015 12:13:06 -0500
Subject: [PATCH 73/95] subproject commit?

---
 protocol/usb_hid/USB_Host_Shield_2.0 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/protocol/usb_hid/USB_Host_Shield_2.0 b/protocol/usb_hid/USB_Host_Shield_2.0
index 2b4a56de3d..8bb790f83a 160000
--- a/protocol/usb_hid/USB_Host_Shield_2.0
+++ b/protocol/usb_hid/USB_Host_Shield_2.0
@@ -1 +1 @@
-Subproject commit 2b4a56de3d090686f62d25ea34042759dc4352d6
+Subproject commit 8bb790f83af298b5f3e5516259c9d8ec27efe522

From 09655cc5d55adbeeec25542bcb471ad47546e1ff Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Fri, 23 Jan 2015 12:14:55 -0500
Subject: [PATCH 74/95] Create keymap_nathan.c

---
 keyboard/planck/keymap_nathan.c | 180 ++++++++++++++++++++++++++++++++
 1 file changed, 180 insertions(+)
 create mode 100644 keyboard/planck/keymap_nathan.c

diff --git a/keyboard/planck/keymap_nathan.c b/keyboard/planck/keymap_nathan.c
new file mode 100644
index 0000000000..47539188ed
--- /dev/null
+++ b/keyboard/planck/keymap_nathan.c
@@ -0,0 +1,180 @@
+// Author: Nathan Ross Powell <nathanrospowell@gmail.com>
+// https://github.com/nathanrosspowell/tmk_keyboard/blob/planck-jack/keyboard/planck/keymap_nathan.c
+
+#include "keymap_common.h"
+
+#ifndef KEYMAP_GRID
+   /* Planck keymap definition macro for the 'grid' layout
+    * ,-----------------------------------------------------------------------.
+    * |     |     |     |     |     |     |     |     |     |     |     |     |
+    * |-----------------------------------------------------------------------|
+    * |     |     |     |     |     |     |     |     |     |     |     |     |
+    * |-----------------------------------------------------------------------|
+    * |     |     |     |     |     |     |     |     |     |     |     |     |
+    * |-----------------------------------------------------------------------|
+    * |     |     |     |     |     |     |     |     |     |     |     |     |
+    * `-----------------------------------------------------------------------'
+    */
+#define KEYMAP_GRID( \
+       K00,  K01,  K02,  K03,  K04,  K05,  K06,  K07,  K08,  K09,  K0A,  K0B, \
+       K10,  K11,  K12,  K13,  K14,  K15,  K16,  K17,  K18,  K19,  K1A,  K1B, \
+       K20,  K21,  K22,  K23,  K24,  K25,  K26,  K27,  K28,  K29,  K2A,  K2B, \
+       K30,  K31,  K32,  K33,  K34,  K35,  K36,  K37,  K38,  K39,  K3A,  K3B  \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
+}
+#endif
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+   /* 0: main layer
+    * ,-----------------------------------------------------------------------.
+    * |Tab  | q   | w   | e   | r   | t   | y   | u   | i   | o   | p   | BS  |
+    * |-----------------------------------------------------------------------|
+    * |Ctrl | a   | s   | d   | f   | g   | h   | j   | k   | l   | ;   | Ret |
+    * |-----------------------------------------------------------------------|
+    * |Shift| z   | x   | c   | v   | b   | n   | m   | [   | (   | {   | <   |
+    * |-----------------------------------------------------------------------|
+    * |Meta | \   | /   | Alt |Lower|Space|Space|Upper|Left |Down | Up  |Right|
+    * `-----------------------------------------------------------------------'
+    */
+  [0] = KEYMAP_GRID(
+       TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+       LCTL, A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
+       RSFT, Z,    X,    C,    V,    B,    N,    M,    LBRC, FN10, FN11, FN12,
+       LGUI, BSLS, SLSH, LALT, FN0,  SPC,  SPC,  FN1,  LEFT, DOWN, UP,   RGHT),
+
+   /* 1: fn left/lower layer
+    * The top row are Visual Studio combos:
+    *   'Run', 'Breakpoint', 'Step over', 'Step into', 'Set cursor to line'
+    * 2nd row are key combos:
+    *   'ctrl-alt-delete', 'ctrl-shift-escape' 
+    * 3rd row are macros keys:
+    *   'P0' - 'P5' execute a script on Windows machines 
+    * ,-----------------------------------------------------------------------.
+    * | ESC | F5   | F9 | F10 | F11 |S+F11|CSF10|NLock|Num7 |Num8 |Num9 | Del |
+    * |-----------------------------------------------------------------------|
+    * |     |C/A/D|C/S/E| Ins |Print|Pause|SLock|Num0 |Num4 |Num5 |Num6 |Num= |
+    * |-----------------------------------------------------------------------|
+    * |     | P0  | P1  | P2  | P3  | P4  | P5  |Num. |Num1 |Num2 |Num3 |Num/ |
+    * |-----------------------------------------------------------------------|
+    * |     |User |     |     |     |     |     |     |Home |PgDn |PgUp | End |
+    * `-----------------------------------------------------------------------'
+    */
+  [1] = KEYMAP_GRID(
+       ESC,  F5,   F9,   F10,  F11,  FN30, FN31, NLCK, P7,   P8,   P9,   DEL,
+       TRNS, FN16, FN17, INS,  PSCR, PAUS, SLCK, P0,   P4,   P5,   P6,   PEQL,
+       TRNS, FN2,  FN3,  FN4,  FN5,  FN6,  FN7,  PDOT, P1,   P2,   P3,   PSLS,
+       TRNS, FN8,  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, PGUP, END ),
+
+  /* 2: fn right/raise layer
+    * ,-----------------------------------------------------------------------.
+    * | F1  | F2  | F3  | F4  |F5   | F6  | F7  | F8  | F9  | F10 | F11 | F12 |
+    * |-----------------------------------------------------------------------|
+    * |     | !   | @   | #   | $   | %   | ^   | &   | *   | -   | +   | =   |
+    * |-----------------------------------------------------------------------|
+    * |     | _   | '   | "   | `   | ~   | ,   | .   | ]   | )   | }   | >   |
+    * |-----------------------------------------------------------------------|
+    * |     |NextT|PrevT|     |     |     | Esc |     |Mute |Vol- |Vol+ | P/P |
+    * `-----------------------------------------------------------------------'
+    */
+  [2] = KEYMAP_GRID(
+       F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,
+       TRNS, FN18, FN19, FN20, FN21, FN22, FN23, FN24, FN25, MINS, FN26, PAST,
+       TRNS, FN27, QUOT, FN28, GRV,  FN29, COMM, DOT,  RBRC, FN13, FN14, FN15,
+       TRNS, MNXT, MPRV, TRNS, TRNS, TRNS, ESC,  TRNS, MUTE, VOLD, VOLU, MPLY ),
+};
+
+enum macro_id {
+    M_P0,
+    M_P1,
+    M_P2,
+    M_P3,
+    M_P4,
+    M_P5,
+    M_USERNAME
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+  [0] = ACTION_LAYER_MOMENTARY(1), // left/lower layer
+  [1] = ACTION_LAYER_MOMENTARY(2), // right/raise layer
+  // Program macros
+  [2] = ACTION_MACRO(M_P0),
+  [3] = ACTION_MACRO(M_P1),
+  [4] = ACTION_MACRO(M_P2),
+  [5] = ACTION_MACRO(M_P3),
+  [6] = ACTION_MACRO(M_P4),
+  [7] = ACTION_MACRO(M_P5),
+  [8] = ACTION_MACRO(M_USERNAME),
+  // Braces
+  [10] = ACTION_MODS_KEY(MOD_LSFT, KC_9), // (
+  [11] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC), // {
+  [12] = ACTION_MODS_KEY(MOD_LSFT, KC_COMMA), // <
+  [13] = ACTION_MODS_KEY(MOD_LSFT, KC_0),  // )
+  [14] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), // {
+  [15] = ACTION_MODS_KEY(MOD_LSFT, KC_DOT), // >
+  // Combo
+  [16] = ACTION_MODS_KEY(MOD_LALT | MOD_LCTL, KC_DEL), // Ctrl+Alt+Delete
+  [17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_ESC), // Ctrl+Shft+Escape
+  // Symbols
+  [18] = ACTION_MODS_KEY(MOD_LSFT, KC_1), // !
+  [19] = ACTION_MODS_KEY(MOD_LSFT, KC_2), // @
+  [20] = ACTION_MODS_KEY(MOD_LSFT, KC_3), // #
+  [21] = ACTION_MODS_KEY(MOD_LSFT, KC_4), // $
+  [22] = ACTION_MODS_KEY(MOD_LSFT, KC_5), // %
+  [23] = ACTION_MODS_KEY(MOD_LSFT, KC_6), // ^
+  [24] = ACTION_MODS_KEY(MOD_LSFT, KC_7), // &
+  [25] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
+  [26] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // + 
+  [27] = ACTION_MODS_KEY(MOD_LSFT, KC_MINUS), // _
+  [28] = ACTION_MODS_KEY(MOD_LSFT, KC_QUOTE), // "
+  [29] = ACTION_MODS_KEY(MOD_LSFT, KC_GRAVE), // ~
+  // Debugging
+  [30] = ACTION_MODS_KEY(MOD_LSFT, KC_F11), // Step into
+  [31] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F10), // Set cursor to line
+ };
+
+// Run a script and pass a key number to it. This is Windows specific and the script needs to be on your path.
+// *open run dialog* keypress.py [PRG_NUM]
+#define ADD_PYTHON_PROGRAM_ON_WIN( PRG_NUM )  MACRO( D(LGUI), T(R), U(LGUI), W(100), T(K), T(E), T(Y), T(P), T(R), T(E), T(S), T(S), T(DOT), T(P), T(Y), T(SPC), T(PRG_NUM), END )
+// *return*
+#define RUN_PYTHON_PROGRAM_ON_WIN MACRO( T(ENT), END )
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+    keyevent_t event = record->event;
+    switch (id) {
+        case M_P0:
+            return event.pressed ?
+                ADD_PYTHON_PROGRAM_ON_WIN( 0 ) : 
+                RUN_PYTHON_PROGRAM_ON_WIN;
+        case M_P1:
+            return event.pressed ?
+                ADD_PYTHON_PROGRAM_ON_WIN( 1 ) : 
+                RUN_PYTHON_PROGRAM_ON_WIN;
+        case M_P2:
+            return event.pressed ?
+                ADD_PYTHON_PROGRAM_ON_WIN( 2 ) : 
+                RUN_PYTHON_PROGRAM_ON_WIN;
+        case M_P3:
+            return event.pressed ?
+                ADD_PYTHON_PROGRAM_ON_WIN( 3 ) : 
+                RUN_PYTHON_PROGRAM_ON_WIN;
+        case M_P4:
+            return event.pressed ?
+                ADD_PYTHON_PROGRAM_ON_WIN( 4 ) : 
+                RUN_PYTHON_PROGRAM_ON_WIN;
+        case M_P5:
+            return event.pressed ?
+                ADD_PYTHON_PROGRAM_ON_WIN( 5 ) : 
+                RUN_PYTHON_PROGRAM_ON_WIN;
+        case M_USERNAME:
+            return event.pressed ?
+                MACRO( T(N), T(A), T(T), T(H), T(A), T(N), T(R), T(O), T(S), T(S), T(P), T(O), T(W), T(E), T(L), T(L), END ) :
+                MACRO_NONE;
+
+    }
+    return MACRO_NONE;
+}

From 6cae90793fbf16c5e0550ddad900c933a21a624d Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Fri, 23 Jan 2015 12:15:44 -0500
Subject: [PATCH 75/95] Create keymap_matthew.c

---
 keyboard/planck/keymap_matthew.c | 50 ++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 keyboard/planck/keymap_matthew.c

diff --git a/keyboard/planck/keymap_matthew.c b/keyboard/planck/keymap_matthew.c
new file mode 100644
index 0000000000..4e5a77eaf0
--- /dev/null
+++ b/keyboard/planck/keymap_matthew.c
@@ -0,0 +1,50 @@
+// by Matthew Pepers - https://github.com/pepers
+
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+  /* 0: dvorak */
+  [0] = KEYMAP( ESC, SCLN, COMM,  DOT,    P,    Y,    F,    G,    C,    R,    L, BSPC,   \
+                GRV,    A,    O,    E,    U,    I,    D,    H,    T,    N,    S, MINS,   \
+                TAB, QUOT,    Q,    J,    K,    X,    B,    M,    W,    V,    Z,  ENT,   \
+               LCTL, LGUI, LALT, RALT,  FN1, LSFT,  SPC,  FN2, LEFT, DOWN,   UP, RGHT),
+
+  /* 1: lower (FN1) */
+  [1] = KEYMAP( F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12,   \
+              FN17,    7,    5,    3,    1,    9,    0,    2,    4,    6,    8, FN18,   \
+              TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  INS,   \
+              TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, PGUP,  END),
+
+  /* 2: raise (FN2) */
+  [2] = KEYMAP(PAUS, FN19, FN20, FN21, TRNS, TRNS, TRNS, TRNS, FN22, FN23, FN24,  DEL,   \
+               FN10, SLSH, FN11, FN12, LBRC,  EQL, FN13, RBRC, FN14, FN15, BSLS, FN16,   \
+               TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, PSCR,   \
+               TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
+
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_MOMENTARY(1),               // lower Fn layer
+    [2] = ACTION_LAYER_MOMENTARY(2),               // raise Fn layer
+
+    // lower row1
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_5),        // %
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_SLASH),    // ?
+    
+    // raise row0
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_2),        // @
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLASH),   // |
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_6),        // ^
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_8),        // *
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_3),        // #
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_4),        // $
+    
+    // raise row1
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_7),        // &
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRACKET), // {
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_9),        // (
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_1),        // !
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_0),        // )
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRACKET), // }
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_EQUAL),    // +
+};

From 438ff3465e027f6aa514224b8d282f25e00dfc0e Mon Sep 17 00:00:00 2001
From: pepers <matt.pepers@gmail.com>
Date: Fri, 23 Jan 2015 14:17:32 -0500
Subject: [PATCH 76/95] defined KEYMAP_GRID for grid layouts

---
 keyboard/planck/keymap_common.h  | 18 ++++++++++---
 keyboard/planck/keymap_matthew.c | 44 +++++++++++++++++++++++---------
 2 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/keyboard/planck/keymap_common.h b/keyboard/planck/keymap_common.h
index 264870ef96..8a55fd9ee0 100644
--- a/keyboard/planck/keymap_common.h
+++ b/keyboard/planck/keymap_common.h
@@ -34,9 +34,7 @@ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
 extern const uint16_t fn_actions[];
 
 
-/* GH60 keymap definition macro
- * K2C, K31 and  K3C are extra keys for ISO
- */
+// MIT Layout
 #define KEYMAP( \
     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
@@ -49,4 +47,18 @@ extern const uint16_t fn_actions[];
     { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_NO,    KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
 }
 
+// Grid Layout
+#define KEYMAP_GRID( \
+    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, \
+    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, \
+    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, \
+    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B  \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B }  \
+}
+
+
 #endif
diff --git a/keyboard/planck/keymap_matthew.c b/keyboard/planck/keymap_matthew.c
index 4e5a77eaf0..56e7003a97 100644
--- a/keyboard/planck/keymap_matthew.c
+++ b/keyboard/planck/keymap_matthew.c
@@ -1,25 +1,45 @@
 // by Matthew Pepers - https://github.com/pepers
 
+/* grid planck layout - modified programmer dvorak
+,-----------------------------------------------------------------------------------------------.
+| pause |   @   |   |   |   ^   |       |       |       |       |   *   |   #   |   $   |  del  |
+|  esc  |  ; :  |  , <  |  . >  |   P   |   Y   |   F   |   G   |   G   |   C   |   R   | bkspc |
+|  F1   |  F2   |  F3   |  F4   |  F5   |  F6   |  F7   |  F8   |  F9   |  F10  |  F11  |  F12  |
+|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
+|   &   |   /   |   {   |   (   |   [   |   =   |   !   |   ]   |   )   |   }   |   \   |   +   |
+|  ` ~  |   A   |   O   |   E   |   U   |   I   |   D   |   H   |   T   |   N   |   S   |  - _  |
+|   %   |   7   |   5   |   3   |   1   |   9   |   0   |   2   |   4   |   6   |   8   |   ?   |
+|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
+|       |       |       |       |       |       |       |       |       |       |       | prtsc |
+|  tab  |  ' "  |   Q   |   J   |   K   |   X   |   B   |   M   |   W   |   V   |   Z   | retrn |
+|       |       |       |       |       |       |       |       |       |       |       | insrt |
+|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|
+|       |       |       |       |       |       |       |       |       |       |       |       |
+| lctrl | lgui  | lalt  | ralt  | lower | shift | space | raise | left  | down  |  up   | right |
+|       |       |       |       |       |       |       |       | home  | pgdn  | pgup  |  end  |
+`-----------------------------------------------------------------------------------------------'
+*/
+
 #include "keymap_common.h"
 
 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   /* 0: dvorak */
-  [0] = KEYMAP( ESC, SCLN, COMM,  DOT,    P,    Y,    F,    G,    C,    R,    L, BSPC,   \
-                GRV,    A,    O,    E,    U,    I,    D,    H,    T,    N,    S, MINS,   \
-                TAB, QUOT,    Q,    J,    K,    X,    B,    M,    W,    V,    Z,  ENT,   \
-               LCTL, LGUI, LALT, RALT,  FN1, LSFT,  SPC,  FN2, LEFT, DOWN,   UP, RGHT),
+  [0] = KEYMAP_GRID( ESC, SCLN, COMM,  DOT,    P,    Y,    F,    G,    C,    R,    L, BSPC,   \
+                     GRV,    A,    O,    E,    U,    I,    D,    H,    T,    N,    S, MINS,   \
+                     TAB, QUOT,    Q,    J,    K,    X,    B,    M,    W,    V,    Z,  ENT,   \
+                    LCTL, LGUI, LALT, RALT,  FN1, LSFT,  SPC,  FN2, LEFT, DOWN,   UP, RGHT),
 
   /* 1: lower (FN1) */
-  [1] = KEYMAP( F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12,   \
-              FN17,    7,    5,    3,    1,    9,    0,    2,    4,    6,    8, FN18,   \
-              TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  INS,   \
-              TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, PGUP,  END),
+  [1] = KEYMAP_GRID( F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,  F10,  F11,  F12,   \
+                   FN17,    7,    5,    3,    1,    9,    0,    2,    4,    6,    8, FN18,   \
+                   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,  INS,   \
+                   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, HOME, PGDN, PGUP,  END),
 
   /* 2: raise (FN2) */
-  [2] = KEYMAP(PAUS, FN19, FN20, FN21, TRNS, TRNS, TRNS, TRNS, FN22, FN23, FN24,  DEL,   \
-               FN10, SLSH, FN11, FN12, LBRC,  EQL, FN13, RBRC, FN14, FN15, BSLS, FN16,   \
-               TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, PSCR,   \
-               TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
+  [2] = KEYMAP_GRID(PAUS, FN19, FN20, FN21, TRNS, TRNS, TRNS, TRNS, FN22, FN23, FN24,  DEL,   \
+                    FN10, SLSH, FN11, FN12, LBRC,  EQL, FN13, RBRC, FN14, FN15, BSLS, FN16,   \
+                    TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, PSCR,   \
+                    TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS),
 
 };
 

From abf482de8e62880f27c377c2bdbcb664fda0df0b Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Mon, 26 Jan 2015 11:25:22 +0900
Subject: [PATCH 77/95] Fix call parameter of suspend_power_down()

---
 protocol/bluefruit/main.c | 2 +-
 protocol/pjrc/main.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/protocol/bluefruit/main.c b/protocol/bluefruit/main.c
index 094fdb3662..871062ab11 100644
--- a/protocol/bluefruit/main.c
+++ b/protocol/bluefruit/main.c
@@ -104,7 +104,7 @@ int main(void)
         dprintf("Starting main loop");
         while (1) {
             while (suspend) {
-                suspend_power_down(WDTO_120MS);
+                suspend_power_down();
                 if (remote_wakeup && suspend_wakeup_condition()) {
                     usb_remote_wakeup();
                 }
diff --git a/protocol/pjrc/main.c b/protocol/pjrc/main.c
index 4f87a17364..e7bdcc059a 100644
--- a/protocol/pjrc/main.c
+++ b/protocol/pjrc/main.c
@@ -61,7 +61,7 @@ int main(void)
 #endif
     while (1) {
         while (suspend) {
-            suspend_power_down(WDTO_120MS);
+            suspend_power_down();
             if (remote_wakeup && suspend_wakeup_condition()) {
                 usb_remote_wakeup();
             }

From b8c91951e198b6a0f0149c47c5c280a787cca090 Mon Sep 17 00:00:00 2001
From: pepers <matt.pepers@gmail.com>
Date: Tue, 27 Jan 2015 12:32:23 -0500
Subject: [PATCH 78/95] defined semi-standard and short space layouts

---
 keyboard/atomic/keymap_common.h    |  26 +++++-
 keyboard/atomic/keymap_hasu.c      | 145 -----------------------------
 keyboard/atomic/keymap_hhkb.c      |  52 -----------
 keyboard/atomic/keymap_plain.c     |  32 ++++---
 keyboard/atomic/keymap_planck.c    |  51 ----------
 keyboard/atomic/keymap_poker.c     | 104 ---------------------
 keyboard/atomic/keymap_poker_bit.c |  50 ----------
 keyboard/atomic/keymap_poker_set.c |  82 ----------------
 keyboard/atomic/keymap_spacefn.c   |  55 -----------
 9 files changed, 41 insertions(+), 556 deletions(-)
 delete mode 100644 keyboard/atomic/keymap_hasu.c
 delete mode 100644 keyboard/atomic/keymap_hhkb.c
 delete mode 100644 keyboard/atomic/keymap_planck.c
 delete mode 100644 keyboard/atomic/keymap_poker.c
 delete mode 100644 keyboard/atomic/keymap_poker_bit.c
 delete mode 100644 keyboard/atomic/keymap_poker_set.c
 delete mode 100644 keyboard/atomic/keymap_spacefn.c

diff --git a/keyboard/atomic/keymap_common.h b/keyboard/atomic/keymap_common.h
index 76864aae47..7f807bbc07 100644
--- a/keyboard/atomic/keymap_common.h
+++ b/keyboard/atomic/keymap_common.h
@@ -33,8 +33,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
 extern const uint16_t fn_actions[];
 
-
-#define KEYMAP( \
+// JCK: Semi-Standard layout
+#define KEYMAP_JCK( \
     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
     K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2D,   K2E, \
@@ -48,4 +48,26 @@ extern const uint16_t fn_actions[];
     { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_NO,    KC_NO,    KC_##K46, KC_NO,    KC_NO,    KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
 }
 
+// ASK: Short Space layout
+#define KEYMAP_ASK( \
+    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
+    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
+    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2D,   K2E, \
+    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3C,   K3D, K3E, \
+     K40,  K41,  K43,  K44,        K46,     K48, K49, K4A, K4B, K4C, K4D, K4E  \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO,    KC_##K0E }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_NO,    KC_##K2D, KC_##K2E }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_NO,    KC_##K3C, KC_##K3D, KC_##K3E }, \
+    { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_##K44, KC_NO,    KC_##K46, KC_NO,    KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
+}
+
+
+// MLO: Semi-Grid layout
+
+// KLN: Grid layout
+
+// PKR: Standard layout
+
 #endif
diff --git a/keyboard/atomic/keymap_hasu.c b/keyboard/atomic/keymap_hasu.c
deleted file mode 100644
index e6af28585b..0000000000
--- a/keyboard/atomic/keymap_hasu.c
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "keymap_common.h"
-
-/*
- * Hasu
- */
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    /* Keymap 0: Default Layer
-     * ,-----------------------------------------------------------.
-     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
-     * |-----------------------------------------------------------|
-     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
-     * |-----------------------------------------------------------|
-     * |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|Fn2|Shift     |
-     * |-----------------------------------------------------------|
-     * |Ctrl|Gui |Alt |      Space             |Alt |Fn4 |Fn4 |Fn1 |
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP_ANSI(
-        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
-        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   FN2, QUOT,     ENT,  \
-        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, FN1,           FN9,  \
-        LCTL,LGUI,LALT,          SPC,                     RALT,FN3, FN3, FN0),
-    /* Keymap 1: colemak */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   W,   F,   P,   G,   J,   L,   U,   Y,   SCLN,LBRC,RBRC,BSLS, \
-        BSPC,A,   R,   S,   T,   D,   H,   N,   E,   I,   O,   QUOT,     ENT,  \
-        LSFT,Z,   X,   C,   V,   B,   K,   M,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, FN0),
-    /* Keymap 2: dvorak */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   LBRC,RBRC,BSPC, \
-        TAB, QUOT,COMM,DOT, P,   Y,   F,   G,   C,   R,   L,   SLSH,EQL, BSLS, \
-        CAPS,A,   O,   E,   U,   I,   D,   H,   T,   N,   S,   MINS,     ENT,  \
-        LSFT,SCLN,Q,   J,   K,   X,   B,   M,   W,   V,   Z,             RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, FN0),
-    /* Keymap 3: workman */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   D,   R,   W,   B,   J,   F,   U,   P,   SCLN,LBRC,RBRC,BSLS, \
-        BSPC,A,   S,   H,   T,   G,   Y,   N,   E,   O,   I,   QUOT,     ENT,  \
-        LSFT,Z,   X,   M,   C,   V,   K,   L,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, FN0),
-
-    /* Overlay 4: HHKB mode
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
-     * |-----------------------------------------------------------|
-     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |Inser|
-     * |-----------------------------------------------------------|
-     * |Contro|VoD|VoU|Mut|   |   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |   |  +|  -|End|PgD|Dow|Shift     |
-     * |-----------------------------------------------------------|
-     * |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |    |
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP_ANSI(
-        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL,  \
-        CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP,  TRNS,INS,  \
-        LCTL,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,     ENT,  \
-        LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,FN4, TRNS),
-    /* Overlay 5: Vi mode (Slash)
-     * ,-----------------------------------------------------------.
-     * |  `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
-     * |-----------------------------------------------------------|
-     * |Tab  |Hom|PgD|Up |PgU|End|Hom|PgD|PgU|End|   |   |   |     |
-     * |-----------------------------------------------------------|
-     * |Contro|   |Lef|Dow|Rig|   |Lef|Dow|Up |Rig|   |   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |   |Hom|PgD|PgU|End|   |Shift     |
-     * |-----------------------------------------------------------|
-     * |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |Ctrl|
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP_ANSI(
-        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, BSPC, \
-        TAB, HOME,PGDN,UP,  PGUP,END, HOME,PGDN,PGUP,END, TRNS,TRNS,TRNS,TRNS, \
-        LCTL,TRNS,LEFT,DOWN,RGHT,TRNS,LEFT,DOWN,UP,  RGHT,TRNS,TRNS,     ENT,  \
-        LSFT,TRNS,TRNS,TRNS,TRNS,TRNS,HOME,PGDN,PGUP,END, TRNS,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     RALT,RGUI,APP, RCTL),
-    /* Overlay 6: Mouse mode (Semicolon/App)
-     * ,-----------------------------------------------------------.
-     * |  `| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Backsp |
-     * |-----------------------------------------------------------|
-     * |Tab  |   |   |   |   |   |MwL|MwD|MwU|MwR|   |   |   |     |
-     * |-----------------------------------------------------------|
-     * |Contro|   |Ac0|Ac1|Ac1|   |McL|McD|McU|McR|   |   |Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |   |   |   |   |Mb3|Mb2|Mb1|Mb4|Mb5|   |Shift     |
-     * |-----------------------------------------------------------|
-     * |Ctrl|Gui |Alt |      Space             |    |    |    |    |
-     * `-----------------------------------------------------------'
-     * Mc: Mouse Cursor / Mb: Mouse Button / Mw: Mouse Wheel
-     */
-    KEYMAP_ANSI(
-        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, BSPC, \
-        TAB, TRNS,TRNS,TRNS,TRNS,TRNS,WH_L,WH_D,WH_U,WH_R,TRNS,TRNS,TRNS,TRNS, \
-        LCTL,TRNS,ACL0,ACL1,ACL2,TRNS,MS_L,MS_D,MS_U,MS_R,TRNS,TRNS,     ENT,  \
-        LSFT,TRNS,TRNS,TRNS,TRNS,BTN3,BTN2,BTN1,BTN4,BTN5,TRNS,          RSFT, \
-        LCTL,LGUI,LALT,          BTN1,                    TRNS,TRNS,TRNS,RCTL),
-    /* Overlay 7: Layout selector
-     * ,-----------------------------------------------------------.
-     * | Lq| Lc| Ld| Lw|   |   |   |   |   |   |   |   |   |       |
-     * |-----------------------------------------------------------|
-     * |     |Lq |Lw |   |   |   |   |   |   |   |   |   |   |     |
-     * |-----------------------------------------------------------|
-     * |      |   |   |Ld |   |   |   |   |   |   |   |   |        |
-     * |-----------------------------------------------------------|
-     * |        |   |   |Lc |   |   |   |   |   |   |   |          |
-     * |-----------------------------------------------------------|
-     * |    |    |    |                        |    |    |    |    |
-     * `-----------------------------------------------------------'
-     * Lq: set Qwerty layout
-     * Lc: set Colemak layout
-     * Ld: set Dvorak layout
-     * Lw: set Workman layout
-     */
-    KEYMAP_ANSI(
-        FN5, FN6, FN7, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,FN5, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,FN6, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
-};
-
-/*
- * Fn action definition
- */
-const uint16_t PROGMEM fn_actions[] = {
-    [0] = ACTION_LAYER_MOMENTARY(4),
-    [1] = ACTION_LAYER_TAP_KEY(5, KC_SLASH),
-    [2] = ACTION_LAYER_TAP_KEY(6, KC_SCLN),
-    [3] = ACTION_LAYER_MOMENTARY(6),
-    [4] = ACTION_LAYER_MOMENTARY(7),   // to Layout selector
-    [5] = ACTION_DEFAULT_LAYER_SET(0),  // set qwerty layout
-    [6] = ACTION_DEFAULT_LAYER_SET(1),  // set colemak layout
-    [7] = ACTION_DEFAULT_LAYER_SET(2),  // set dvorak layout
-    [8] = ACTION_DEFAULT_LAYER_SET(3),  // set workman layout
-    [9] = ACTION_MODS_TAP_KEY(MOD_RSFT, KC_GRV),
-};
diff --git a/keyboard/atomic/keymap_hhkb.c b/keyboard/atomic/keymap_hhkb.c
deleted file mode 100644
index ce1b816ecb..0000000000
--- a/keyboard/atomic/keymap_hhkb.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include "keymap_common.h"
-
-/*
- * HHKB Layout
- */
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    /* 0: Default layer
-     * ,-----------------------------------------------------------.
-     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|  \|  `|
-     * |-----------------------------------------------------------|
-     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|Bspc |
-     * |-----------------------------------------------------------|
-     * |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|Fn3|  '|Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift |Fn |
-     * |-----------------------------------------------------------|
-     * |    |Gui |Alt |      Space             |    |Alt |Gui |    |
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP_HHKB(
-        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSLS, GRV, \
-        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSPC,      \
-        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,       \
-        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,     RSFT,FN0,       \
-        NO,  LGUI,LALT,          SPC,                     NO,  RALT,RGUI,NO),
-    /* 1: HHKB Fn layer
-     * ,-----------------------------------------------------------.
-     * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
-     * |-----------------------------------------------------------|
-     * |Caps |   |   |   |   |   |   |   |Psc|Slk|Pus|Up |   |     |
-     * |-----------------------------------------------------------|
-     * |      |VoD|VoU|Mut|Ejc|   |  *|  /|Hom|PgU|Lef|Rig|Enter   |
-     * |-----------------------------------------------------------|
-     * |        |   |   |   |   |   |  +|  -|End|PgD|Dow|      |   |
-     * |-----------------------------------------------------------|
-     * |    |    |    |                        |    |    |    |    |
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP_HHKB(
-        PWR, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL,  \
-        CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS,UP,  TRNS,TRNS,      \
-        TRNS,VOLD,VOLU,MUTE,EJCT,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,     PENT,      \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PPLS,PMNS,END, PGDN,DOWN,     TRNS,TRNS,      \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
-};
-
-/*
- * Fn action definition
- */
-const uint16_t PROGMEM fn_actions[] = {
-    [0] = ACTION_LAYER_MOMENTARY(1),
-};
diff --git a/keyboard/atomic/keymap_plain.c b/keyboard/atomic/keymap_plain.c
index c335fbe16f..e7f53649f0 100644
--- a/keyboard/atomic/keymap_plain.c
+++ b/keyboard/atomic/keymap_plain.c
@@ -1,22 +1,24 @@
 #include "keymap_common.h"
 
+// JCK: Semi-Standard layout
+
 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     /* 0: qwerty */
-    [0] = KEYMAP(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
-                 TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    LBRC, RBRC, BSLS, DEL, \
-                 ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,    ENT,     MPLY, \
-                 LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
-                 LCTL,    LALT,  LGUI,          SPC,                         FN1,  LEFT, DOWN, UP,   RGHT),
-    [1] = KEYMAP(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
-                 TAB,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, LBRC, RBRC, BSLS, DEL, \
-                 ESC,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,    QUOT,    ENT,     MPLY, \
-                 LSFT, Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
-                 LCTL,    LALT,  LGUI,          SPC,                         FN1,  LEFT, DOWN, UP,   RGHT),
-    [2] = KEYMAP(GRV,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,    BSPC, \
-                 TAB,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    LBRC, RBRC, BSLS, DEL, \
-                 ESC,  FN3, FN4, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC,   BSLS,    ENT,     MPLY, \
-                 LSFT, FN9,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
-                 LCTL,    LALT,  LGUI,          SPC,                         TRNS,  MNXT, VOLD, VOLU, MPLY),
+    [0] = KEYMAP_JCK(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
+                     TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    LBRC, RBRC, BSLS, DEL, \
+                     ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,    ENT,     MPLY, \
+                     LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                     LCTL,    LALT,  LGUI,          SPC,                         FN1,  LEFT, DOWN, UP,   RGHT),
+    [1] = KEYMAP_JCK(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
+                     TAB,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, LBRC, RBRC, BSLS, DEL, \
+                     ESC,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,    QUOT,    ENT,     MPLY, \
+                     LSFT, Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                     LCTL,    LALT,  LGUI,          SPC,                         FN1,  LEFT, DOWN, UP,   RGHT),
+    [2] = KEYMAP_JCK(GRV,  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,    BSPC, \
+                     TAB,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    LBRC, RBRC, BSLS, DEL, \
+                     ESC,  FN3, FN4, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC,   BSLS,    ENT,     MPLY, \
+                     LSFT, FN9,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    VOLD, VOLU, \
+                     LCTL,    LALT,  LGUI,          SPC,                         TRNS,  MNXT, VOLD, VOLU, MPLY),
 };
 const uint16_t PROGMEM fn_actions[] = {
     [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
diff --git a/keyboard/atomic/keymap_planck.c b/keyboard/atomic/keymap_planck.c
deleted file mode 100644
index ddacb614e6..0000000000
--- a/keyboard/atomic/keymap_planck.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "keymap_common.h"
-
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    [0] = KEYMAP( /* Native */
-      ESC,     Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    FN2, 
-      BSPC,    A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
-      TAB,     Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
-      DEL,     LCTL, NO,   LSFT, LALT, SPC,        NO,   LEFT, DOWN, UP,  RGHT), 
-    [1] = KEYMAP( /* QWERTY->PHOTOSHOP */
-      DELETE,  0,    1,    2,    3,    4,    5,    6,    7,    8,    9,    FN1,
-      O,       G,    S,    U,    T,    FN27,  F21,  F10,  F11,  F7,   F8,   F9,
-      TAB,     FN4, FN5,  FN6,  F1,   FN7,  F18,  F19,  F23,  F20,  F22,  FN9,
-      COMM,    DOT,  FN10, FN11, FN3,  SPC,        FN12, F2,   FN8,  F3,   F14),
-    [2] = KEYMAP( /* 2: FN3 PHOTOSHOP */
-      ESC,    FN25, FN26,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,
-      NO,      NO,   NO,   NO,   NO,   NO,   NO,   NO,   NO,   FN19, FN20, FN21, 
-      C,       NO,  FN22,  FN5,   NO,   FN23, NO,   NO,   NO,   NO,   FN13, NO,
-      FN14,    FN15, FN16, FN17, FN3,   SPC,        FN18, NO,   NO,   F24,  NO),
-};
-
-const uint16_t PROGMEM fn_actions[] = {
-    [1] = ACTION_DEFAULT_LAYER_SET(0),                             // set Qwerty layout
-    [2] = ACTION_DEFAULT_LAYER_SET(1),                             // set Photoshop presets
-    [3] = ACTION_LAYER_ON_OFF(2),                                  // Photoshop function layer
- 
-    [4] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F9),   // photo folder AHK
-    [5] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_I),              // select inverse
-    [6] = ACTION_MODS_KEY(MOD_LSFT, KC_M),                         // marquee select
-    [7] = ACTION_MODS_KEY(MOD_LALT, KC_BSPC),                      // fill 
-    [8] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_X),    // warp
-    [9] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT | MOD_LSFT, KC_F12),  // merge all new layer
-    [10] = ACTION_MODS_KEY(MOD_LCTL, KC_MINS),                     // zoom out
-    [11] = ACTION_MODS_KEY(MOD_LCTL, KC_H),                        // RBG sliders
-    [12] = ACTION_MODS_KEY(MOD_LCTL, KC_S),                        // save
-    [13] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_F5),           // layer mask from transparancy 
-    [14] = ACTION_MODS_KEY(MOD_LALT, KC_LBRC),                     // prev layer
-    [15] = ACTION_MODS_KEY(MOD_LALT, KC_RBRC),                     // next layer
-    [16] = ACTION_MODS_KEY(MOD_LCTL, KC_EQL),                      // zoom in
-    [17] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_H),             // HSV sliders
-    [18] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F11), // save as PNG
-    [19] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F7),  // gaussian blur
-    [20] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL | MOD_LALT, KC_F8),  // motion blur
-    [21] = ACTION_MODS_KEY(MOD_LSFT | MOD_LCTL, KC_X),            // liquify filter
-    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),                     // prev layer blending
-    [23] = ACTION_MODS_KEY(MOD_LSFT | MOD_LALT, KC_N),             // normal layer blending
-    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),                      // next layer blending
-    [25] = ACTION_MODS_KEY(MOD_LCTL, KC_Z),                        // step back
-    [26] = ACTION_MODS_KEY(MOD_LCTL, KC_Y),                        // step forward
-    [27] = ACTION_MODS_KEY(MOD_LCTL, KC_R),                        // rasterize
-     
-};
diff --git a/keyboard/atomic/keymap_poker.c b/keyboard/atomic/keymap_poker.c
deleted file mode 100644
index 7a612ee44d..0000000000
--- a/keyboard/atomic/keymap_poker.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "keymap_common.h"
-
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    /* 0: qwerty */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
-        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
-        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
-    /* 1: colemak */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   W,   F,   P,   G,   J,   L,   U,   Y,   SCLN,LBRC,RBRC,BSLS, \
-        BSPC,A,   R,   S,   T,   D,   H,   N,   E,   I,   O,   QUOT,     ENT,  \
-        LSFT,Z,   X,   C,   V,   B,   K,   M,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
-    /* 2: dvorak */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   LBRC,RBRC,BSPC, \
-        TAB, QUOT,COMM,DOT, P,   Y,   F,   G,   C,   R,   L,   SLSH,EQL, BSLS, \
-        CAPS,A,   O,   E,   U,   I,   D,   H,   T,   N,   S,   MINS,     ENT,  \
-        LSFT,SCLN,Q,   J,   K,   X,   B,   M,   W,   V,   Z,             RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
-    /* 3: workman */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   D,   R,   W,   B,   J,   F,   U,   P,   SCLN,LBRC,RBRC,BSLS, \
-        BSPC,A,   S,   H,   T,   G,   Y,   N,   E,   O,   I,   QUOT,     ENT,  \
-        LSFT,Z,   X,   M,   C,   V,   K,   L,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
-    /* 4: Poker with Arrow */
-    KEYMAP_ANSI(
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,LEFT,DOWN,RGHT),
-    /* 5: Poker with Esc */
-    KEYMAP_ANSI(
-        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
-    /* 6: Poker Fn
-     * ,-----------------------------------------------------------.
-     * |Esc| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|       |
-     * |-----------------------------------------------------------|
-     * |     |FnQ| Up|   |   |   |   |   |   |Cal|   |Hom|Ins|FnL  |
-     * |-----------------------------------------------------------|
-     * |      |Lef|Dow|Rig|   |   |Psc|Slk|Pau|   |Tsk|End|        |
-     * |-----------------------------------------------------------|
-     * |        |Del|   |Web|Mut|VoU|VoD|   |PgU|PgD|Del|          |
-     * |-----------------------------------------------------------|
-     * |    |    |    |         FnS            |    |    |    |    |
-     * `-----------------------------------------------------------'
-     * Fn:  to Fn overlay
-     * FnL: to Layout selector overaly
-     * FnQ: toggle Esc overlay
-     * FnS: toggle Arrow overlay
-     */
-    KEYMAP_ANSI(
-        ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
-        TRNS,FN2, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, FN4,  \
-        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN3, END,      TRNS, \
-        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
-        TRNS,TRNS,TRNS,          FN1,                     TRNS,TRNS,TRNS,TRNS),
-    /* 7: Layout selector
-     * ,-----------------------------------------------------------.
-     * | Lq| Lc| Ld| Lw|   |   |   |   |   |   |   |   |   |       |
-     * |-----------------------------------------------------------|
-     * |     |Lq |Lw |   |   |   |   |   |   |   |   |   |   |     |
-     * |-----------------------------------------------------------|
-     * |      |   |   |Ld |   |   |   |   |   |   |   |   |        |
-     * |-----------------------------------------------------------|
-     * |        |   |   |Lc |   |   |   |   |   |   |   |          |
-     * |-----------------------------------------------------------|
-     * |    |    |    |                        |    |    |    |    |
-     * `-----------------------------------------------------------'
-     * Lq: set Qwerty layout
-     * Lc: set Colemak layout
-     * Ld: set Dvorak layout
-     * Lw: set Workman layout
-     */
-    KEYMAP_ANSI(
-        FN5, FN6, FN7, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,FN5, FN8, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,FN7, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,FN6, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
-};
-const uint16_t PROGMEM fn_actions[] = {
-    /* Poker Layout */
-    [0] = ACTION_LAYER_MOMENTARY(6),  // to Fn overlay
-    [1] = ACTION_LAYER_TOGGLE(4),     // toggle arrow overlay
-    [2] = ACTION_LAYER_TOGGLE(5),     // toggle Esc overlay
-    [3] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // Task(RControl,RShift+Esc)
-    [4] = ACTION_LAYER_MOMENTARY(7),  // to Layout selector
-    [5] = ACTION_DEFAULT_LAYER_SET(0),  // set qwerty layout
-    [6] = ACTION_DEFAULT_LAYER_SET(1),  // set colemak layout
-    [7] = ACTION_DEFAULT_LAYER_SET(2),  // set dvorak layout
-    [8] = ACTION_DEFAULT_LAYER_SET(3),  // set workman layout
-};
diff --git a/keyboard/atomic/keymap_poker_bit.c b/keyboard/atomic/keymap_poker_bit.c
deleted file mode 100644
index b8870fdd81..0000000000
--- a/keyboard/atomic/keymap_poker_bit.c
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "keymap_common.h"
-
-// Poker fix with toggle and bit operation
-// Fn + Esc = `
-// Fn + {left, down, up, right}  = {home, pgdown, pgup, end}
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    /* 0: qwerty */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
-        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
-        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
-    /* 4: Poker Default + Fn'd */
-    [4] = KEYMAP_ANSI(
-        TRNS,F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
-        CAPS,FN2, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
-        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN4, END,      TRNS, \
-        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
-        TRNS,TRNS,TRNS,          FN1,                     TRNS,TRNS,TRNS,TRNS),
-    /* 5: Poker with Arrow */
-    KEYMAP_ANSI(
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          PGUP, \
-        TRNS,TRNS,TRNS,          TRNS,                    FN3, HOME,PGDN,END),
-    /* 6: Poker with Esc */
-    KEYMAP_ANSI(
-        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
-    /* 7: Poker with Arrow + Fn'd */
-    KEYMAP_ANSI(
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,LEFT,DOWN,RGHT),
-};
-const uint16_t PROGMEM fn_actions[] = {
-    /* Poker Layout */
-    [0] = ACTION_LAYER_BIT_XOR(1, 0b0101, ON_BOTH),   // Poker Fn(with fix for Esc)
-    [1] = ACTION_LAYER_TOGGLE(5),                     // Poker Arrow toggle
-    [2] = ACTION_LAYER_TOGGLE(6),                     // Poker Esc toggle
-    [3] = ACTION_LAYER_BIT_XOR(1, 0b1101, ON_BOTH),   // Poker Fn(with fix for Arrow)
-    [4] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // FN3 Task(RControl,RShift+Esc)
-};
diff --git a/keyboard/atomic/keymap_poker_set.c b/keyboard/atomic/keymap_poker_set.c
deleted file mode 100644
index aaa31fc571..0000000000
--- a/keyboard/atomic/keymap_poker_set.c
+++ /dev/null
@@ -1,82 +0,0 @@
-#include "keymap_common.h"
-
-// Poker fix with set(state transition)
-// Fn + Esc = `
-// Fn + {left, down, up, right}  = {home, pgdown, pgup, end}
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    /* 0: qwerty */
-    KEYMAP_ANSI(
-        GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
-        LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
-        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          SPC,                     FN0, RGUI,APP, RCTL),
-    /* 1: Poker with Arrow */
-    KEYMAP_ANSI(
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
-        TRNS,TRNS,TRNS,          TRNS,                    FN1, LEFT,DOWN,RGHT),
-    /* 2: Poker with Esc */
-    KEYMAP_ANSI(
-        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          TRNS, \
-        TRNS,TRNS,TRNS,          TRNS,                    FN2, TRNS,TRNS,TRNS),
-    /* 3: Poker with Arrow and Esc */
-    KEYMAP_ANSI(
-        ESC, TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,          UP,   \
-        TRNS,TRNS,TRNS,          TRNS,                    FN3, LEFT,DOWN,RGHT),
-    /* 4: Poker Fn'd */
-    KEYMAP_ANSI(
-        ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
-        TRNS,FN6, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
-        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
-        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
-        TRNS,TRNS,TRNS,          FN5,                     FN4, TRNS,TRNS,TRNS),
-    /* 5: Poker Fn'd arrow */
-    KEYMAP_ANSI(
-        ESC, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
-        TRNS,FN7, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
-        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
-        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           PGUP, \
-        TRNS,TRNS,TRNS,          FN4,                     FN5, HOME,PGDN,END),
-    /* 6: Poker Fn'd Esc */
-    KEYMAP_ANSI(
-        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
-        TRNS,FN4, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
-        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
-        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           TRNS, \
-        TRNS,TRNS,TRNS,          FN7,                     FN6, TRNS,TRNS,TRNS),
-    /* 7: Poker Fn'd Arrow + Esc */
-    KEYMAP_ANSI(
-        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, TRNS, \
-        TRNS,FN5, UP,  TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,CALC,TRNS,HOME,INS, TRNS, \
-        TRNS,LEFT,DOWN,RGHT,TRNS,TRNS,PSCR,SLCK,PAUS,TRNS,FN8, END,      TRNS, \
-        TRNS,DEL, TRNS,WHOM,MUTE,VOLU,VOLD,TRNS,PGUP,PGDN,DEL,           PGUP, \
-        TRNS,TRNS,TRNS,          FN6,                     FN7, HOME,PGDN,END),
-};
-
-/*
- * Fn action definition
- */
-const uint16_t PROGMEM fn_actions[] = {
-    /* Poker Layout */
-    [0] = ACTION_LAYER_SET(4, ON_PRESS),     // FN0 move to Fn'd             when press
-    [1] = ACTION_LAYER_SET(5, ON_PRESS),     // FN1 move to Fn'd arrow       when press
-    [2] = ACTION_LAYER_SET(6, ON_PRESS),     // FN2 move to Fn'd Esc         when press
-    [3] = ACTION_LAYER_SET(7, ON_PRESS),     // FN3 move to Fn'd arrow + Esc when press
-
-    //[4] = ACTION_LAYER_CLEAR(ON_RELEASE),    // FN4 clear overlay            when release
-    [4] = ACTION_LAYER_SET(0, ON_RELEASE),   // FN4 clear overlay            when release
-    [5] = ACTION_LAYER_SET(1, ON_RELEASE),   // FN5 move to arrow            when release
-    [6] = ACTION_LAYER_SET(2, ON_RELEASE),   // FN6 move to Esc              when release
-    [7] = ACTION_LAYER_SET(3, ON_RELEASE),   // FN7 move to arrow + Esc      when release
-
-    [8] = ACTION_MODS_KEY(MOD_RCTL|MOD_RSFT, KC_ESC), // FN8 Task(RControl,RShift+Esc)
-};
diff --git a/keyboard/atomic/keymap_spacefn.c b/keyboard/atomic/keymap_spacefn.c
deleted file mode 100644
index 8077dcee7b..0000000000
--- a/keyboard/atomic/keymap_spacefn.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "keymap_common.h"
-
-/*
- * SpaceFN
- * http://geekhack.org/index.php?topic=51069.0
- */
-const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-    /* Keymap 0: Default Layer
-     * ,-----------------------------------------------------------.
-     * |Esc|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|Backsp |
-     * |-----------------------------------------------------------|
-     * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|
-     * |-----------------------------------------------------------|
-     * |Caps  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Return  |
-     * |-----------------------------------------------------------|
-     * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  .|  /|Shift     |
-     * |-----------------------------------------------------------|
-     * |Ctrl|Gui |Alt |      Space             |Alt |Gui |App |Ctrl|
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP_ANSI(
-        ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
-        TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
-        CAPS,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,     ENT,  \
-        LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,          RSFT, \
-        LCTL,LGUI,LALT,          FN0,                     RALT,RGUI,APP, RCTL),
-
-    /* Overlay 1: SpaceFN
-     * ,-----------------------------------------------------------.
-     * |`  | F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Delete |
-     * |-----------------------------------------------------------|
-     * |     |   |   |   |   |   |   |Hom|Up |End|Psc|Slk|Pau|Ins  |
-     * |-----------------------------------------------------------|
-     * |      |   |   |   |   |   |PgU|Lef|Dow|Rig|   |   |        |
-     * |-----------------------------------------------------------|
-     * |        |   |   |   |   |Spc|PgD|`  |~  |   |   |          |
-     * |-----------------------------------------------------------|
-     * |    |    |    |                        |    |    |    |    |
-     * `-----------------------------------------------------------'
-     */
-    KEYMAP_ANSI(
-        GRV, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL,  \
-        TRNS,TRNS,TRNS,ESC, TRNS,TRNS,TRNS,HOME,UP,  END, PSCR,SLCK,PAUS,INS,  \
-        TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PGUP,LEFT,DOWN,RGHT,TRNS,TRNS,     TRNS, \
-        TRNS,TRNS,TRNS,TRNS,TRNS,SPC, PGDN,GRV, FN1, TRNS,TRNS,          TRNS, \
-        TRNS,TRNS,TRNS,          TRNS,                    TRNS,TRNS,TRNS,TRNS),
-};
-
-/*
- * Fn action definition
- */
-const uint16_t PROGMEM fn_actions[] = {
-    [0] = ACTION_LAYER_TAP_KEY(1, KC_SPACE),
-    [1] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),    // tilde
-};

From 4a3c0839f9df1dea8520dee6e420cb27b5337876 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Sun, 15 Feb 2015 16:29:35 -0500
Subject: [PATCH 79/95] sean

---
 keyboard/planck/keymap_sean.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/keyboard/planck/keymap_sean.c b/keyboard/planck/keymap_sean.c
index 4029846640..9ad572a72c 100644
--- a/keyboard/planck/keymap_sean.c
+++ b/keyboard/planck/keymap_sean.c
@@ -13,17 +13,17 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
       Z,    X,    C,    V,    B,    TAB,  ENT,  N,    M,    COMM, DOT,  SLSH,
       LSFT, LCTL, LALT, LGUI, FN1,  SPC,        FN2,  LEFT, DOWN, UP,  RGHT),
       
-    [2] = KEYMAP( /* fn1 */
-      F1,   F2,   F3,   F4,   F5,   NO,   NO,   F6,   F7,   F8,   F9,   F10,
+    [2] = KEYMAP( /* fn1 lower */
+      F1,   F2,   F3,   F4,   F5,   TRNS, TRNS, F6,   F7,   F8,   F9,   F10,
       1,    2,    3,    4,    5,    ESC,  DEL,  6,    7,    8,    9,    0,
-      FN3,   FN4,   NO,  GRV,   MINS, F18,  INS,  BSLS, LBRC, RBRC, NO,   NO,
-      TRNS, TRNS, TRNS, TRNS, FN1,  TRNS,       FN3,  HOME, PGDN, PGUP, END),
+      FN3,  FN4,  TRNS,   GRV,  MINS, TRNS, TRNS, BSLS, LBRC, RBRC, TRNS, TRNS,
+      TRNS, TRNS, TRNS, TRNS, FN1,  TRNS,       TRNS, HOME, PGDN, PGUP, END),
 
-    [3] = KEYMAP( /* fn2 */
-      F11,  F12,  F13,  F14,  F15,  NO,   NO,   F16,  F17,  F18,  F19,  F20,
-      F1,   F2,   F3,   F4,   F5,   ESC,  DEL,  F6,   F7,   F8,   F9,   F10,
-      FN3,  FN4,  NO,   GRV,  MINS, F18,  INS,  INS,  PSCR, SLCK, PAUS, TRNS,
-      TRNS, TRNS, TRNS, TRNS, FN3,  TRNS,       FN2,  MUTE, VOLD, VOLU, MPLY),
+    [3] = KEYMAP( /* fn2 raise */
+      F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,
+      FN10, FN11, FN12, FN13, FN14, ESC,  DEL,  FN15, FN16, FN17, FN18, FN19,
+      FN3,  FN4,  TRNS,   FN22, FN20, TRNS, TRNS, FN28, FN23, FN24, TRNS, TRNS,
+      TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,       FN2,  MNXT, VOLD, VOLU, MPLY),
 };
 const uint16_t PROGMEM fn_actions[] = {
     [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay

From a4d091eb525d574ab24a545ecb22dfdb0b26fc1e Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 19 Feb 2015 19:35:57 -0500
Subject: [PATCH 80/95] joe

---
 keyboard/planck/Makefile      |   3 +-
 keyboard/planck/keymap_jack.c |  16 ++---
 keyboard/planck/keymap_joe.c  | 107 ++++++++++++++++++++++++++++++++++
 3 files changed, 117 insertions(+), 9 deletions(-)
 create mode 100644 keyboard/planck/keymap_joe.c

diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index 22101096e9..3bc12da023 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -55,12 +55,11 @@ SRC =	keymap_common.c \
 ifdef KEYMAP
     SRC := keymap_$(KEYMAP).c $(SRC)
 else
-    SRC := keymap_sean.c $(SRC)
+    SRC := keymap_joe.c $(SRC)
 endif
 
 CONFIG_H = config.h
 
-
 # MCU name
 #MCU = at90usb1287
 MCU = atmega32u4
diff --git a/keyboard/planck/keymap_jack.c b/keyboard/planck/keymap_jack.c
index fd30069ed2..5b226813d0 100644
--- a/keyboard/planck/keymap_jack.c
+++ b/keyboard/planck/keymap_jack.c
@@ -2,23 +2,23 @@
 
 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 [0] = KEYMAP( /* Jack */
-  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
-  TAB,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
+  TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  ESC,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
   LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
   RSFT, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
 [1] = KEYMAP( /* Jack colemak */
-  ESC,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, BSPC,
-  TAB,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,     QUOT,
+  TAB,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, BSPC,
+  ESC,  A,    R,    S,    T,    D,    H,    N,    E,    I,    O,     QUOT,
   LSFT, Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH, ENT,
   FN3, LCTL, LALT, LGUI, FN2,    SPC,     FN1, LEFT, DOWN, UP,  RGHT),
 [2] = KEYMAP( /* Jack RAISE */
   GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    BSPC,
-  TRNS, FN3, FN4, TRNS, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC, BSLS,
+  TRNS, FN3, FN4, PAUSE, TRNS, TRNS, TRNS, MINS, EQL,  LBRC, RBRC, BSLS,
   TRNS, F11,  F12,  F13,  F14,  F15,  F16,  F17,  F18,  F19,  F20, TRNS,
   TRNS, TRNS, TRNS, TRNS, TRNS,    TRNS,   FN1,  MNXT, VOLD, VOLU, MPLY),
 [3] = KEYMAP( /* Jack LOWER */
   FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
-  TRNS, FN3, FN4, TRNS, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+  TRNS, FN3, FN4, PAUSE, TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
   TRNS, F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  TRNS,
   TRNS, TRNS, TRNS, TRNS, FN2,    TRNS,    TRNS, MNXT, VOLD, VOLU, MPLY),
 };
@@ -28,7 +28,7 @@ const uint16_t PROGMEM fn_actions[] = {
     // [1] = ACTION_LAYER_ON_OFF(1),
     // [2] = ACTION_LAYER_ON_OFF(2),
     [3] = ACTION_DEFAULT_LAYER_SET(0), 
-    [4] = ACTION_DEFAULT_LAYER_SET(1),  
+    [4] = ACTION_DEFAULT_LAYER_SET(1),
 
     [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
     [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
@@ -46,4 +46,6 @@ const uint16_t PROGMEM fn_actions[] = {
     [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
     [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
     [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+
+    [29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
 };
diff --git a/keyboard/planck/keymap_joe.c b/keyboard/planck/keymap_joe.c
new file mode 100644
index 0000000000..5e89792180
--- /dev/null
+++ b/keyboard/planck/keymap_joe.c
@@ -0,0 +1,107 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP( /* Joe */
+  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    MINS,
+  BSPC, A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
+  TAB,  Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, QUOT,
+  LCTL, LGUI, LALT, LSFT, FN1,    SPC,      FN0,  LEFT, DOWN, UP,  RGHT),
+[1] = KEYMAP( /* Joe colemak */
+  ESC,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, MINS,
+  BSPC, A,    R,    S,    T,    D,    H,    N,    E,    I,    O,    ENT,
+  TAB,  Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH, QUOT,
+  LCTL, LGUI, LALT, LSFT, FN1,    SPC,      FN0,  LEFT, DOWN, UP,  RGHT),
+[2] = KEYMAP( /* Joe RAISE */
+  F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,
+  DEL,  FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, TRNS,
+  BSLS, FN5,  FN6,  FN3,  FN4,  MENU, CAPS, INS,  PSCR, LBRC, RBRC, FN21,
+  TRNS, TRNS, TRNS, TRNS, FN2,     TRNS,    FN0,  FN26, FN27, FN28, FN29),
+[3] = KEYMAP( /* Joe LOWER */
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN7, FN8, FN9, FN30, FN31,
+  DEL,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    TRNS,
+  FN25, LSFT, RSFT, PAUS, TRNS, TRNS, TRNS, TRNS, TRNS, FN23, FN24, EQL,
+  TRNS, TRNS, TRNS, TRNS, FN1,    TRNS,     FN2,  HOME, PGDN, PGUP, END),
+[4] = KEYMAP( /* Joe LOWER + RAISE */
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS,     TRNS,   TRNS, MNXT, VOLD, VOLU, MPLY),
+};
+
+enum macro_id {
+    M_Q0,
+    M_Q1,
+    M_Q2,
+    M_Q3,
+    M_Q4
+};
+
+const uint16_t PROGMEM fn_actions[] = {
+    [0] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
+    [1] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay
+    [2] = ACTION_LAYER_MOMENTARY(4),  // to Fn overlay
+
+    [3] = ACTION_DEFAULT_LAYER_SET(0), 
+    [4] = ACTION_DEFAULT_LAYER_SET(1),
+
+    [5] = ACTION_MODS_KEY(MOD_LCTL, KC_PGDN),
+    [6] = ACTION_MODS_KEY(MOD_LCTL, KC_PGUP),
+
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+    [25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+
+    [7] = ACTION_MACRO(M_Q0),
+    [8] = ACTION_MACRO(M_Q1),
+    [9] = ACTION_MACRO(M_Q2),
+    [30] = ACTION_MACRO(M_Q3),
+    [31] = ACTION_MACRO(M_Q4),
+
+    [26] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_LEFT),
+    [27] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_DOWN),
+    [28] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_UP),
+    [29] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_RGHT),
+    
+};
+
+const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+    keyevent_t event = record->event;
+    switch (id) {
+        case M_Q0:
+            return event.pressed ?
+                MACRO( D(LSFT), T(SCLN), U(LSFT), T(SLSH), END ) :
+                MACRO_NONE;
+        case M_Q1:
+            return event.pressed ?
+                MACRO( D(LSFT), T(SCLN), T(9), U(LSFT), END ) :
+                MACRO_NONE;
+        case M_Q2:
+            return event.pressed ?
+                MACRO( D(LSFT), T(0), T(SCLN), U(LSFT), END ) :
+                MACRO_NONE;
+        case M_Q3:
+            return event.pressed ?
+                MACRO( D(LSFT), T(9), T(SCLN), U(LSFT), END ) :
+                MACRO_NONE;
+        case M_Q4:
+            return event.pressed ?
+                MACRO( D(LSFT), T(SCLN), T(0), U(LSFT), END ) :
+                MACRO_NONE;
+
+    }
+    return MACRO_NONE;
+}
\ No newline at end of file

From cf4363c9101226593d008d68f518b8378ca0e1b4 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 19 Feb 2015 19:39:35 -0500
Subject: [PATCH 81/95] joe

---
 keyboard/planck/keymap_joe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/keyboard/planck/keymap_joe.c b/keyboard/planck/keymap_joe.c
index 5e89792180..2614c98a80 100644
--- a/keyboard/planck/keymap_joe.c
+++ b/keyboard/planck/keymap_joe.c
@@ -19,7 +19,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 [3] = KEYMAP( /* Joe LOWER */
   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN7, FN8, FN9, FN30, FN31,
   DEL,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    TRNS,
-  FN25, LSFT, RSFT, PAUS, TRNS, TRNS, TRNS, TRNS, TRNS, FN23, FN24, EQL,
+  FN25, FN3,  FN4,  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN23, FN24, EQL,
   TRNS, TRNS, TRNS, TRNS, FN1,    TRNS,     FN2,  HOME, PGDN, PGUP, END),
 [4] = KEYMAP( /* Joe LOWER + RAISE */
   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
@@ -74,7 +74,7 @@ const uint16_t PROGMEM fn_actions[] = {
     [27] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_DOWN),
     [28] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_UP),
     [29] = ACTION_MODS_KEY(MOD_LCTL | MOD_LALT, KC_RGHT),
-    
+
 };
 
 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)

From 88cc5ce8839a14187919a30325cfb3dd2ab3752e Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 19 Feb 2015 19:41:45 -0500
Subject: [PATCH 82/95] joe

---
 keyboard/planck/keymap_joe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/keyboard/planck/keymap_joe.c b/keyboard/planck/keymap_joe.c
index 2614c98a80..e780a9e6e3 100644
--- a/keyboard/planck/keymap_joe.c
+++ b/keyboard/planck/keymap_joe.c
@@ -14,7 +14,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 [2] = KEYMAP( /* Joe RAISE */
   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,
   DEL,  FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, TRNS,
-  BSLS, FN5,  FN6,  FN3,  FN4,  MENU, CAPS, INS,  PSCR, LBRC, RBRC, FN21,
+  BSLS, FN5,  FN6,  TRNS, TRNS, MENU, CAPS, INS,  PSCR, LBRC, RBRC, FN21,
   TRNS, TRNS, TRNS, TRNS, FN2,     TRNS,    FN0,  FN26, FN27, FN28, FN29),
 [3] = KEYMAP( /* Joe LOWER */
   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN7, FN8, FN9, FN30, FN31,

From 7884125b797f0c594e666616caf289122489ec5e Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 19 Feb 2015 20:10:24 -0500
Subject: [PATCH 83/95] joe

---
 keyboard/planck/keymap_joe.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/keyboard/planck/keymap_joe.c b/keyboard/planck/keymap_joe.c
index e780a9e6e3..15b16530e7 100644
--- a/keyboard/planck/keymap_joe.c
+++ b/keyboard/planck/keymap_joe.c
@@ -1,16 +1,16 @@
 #include "keymap_common.h"
 
 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-[0] = KEYMAP( /* Joe */
-  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    MINS,
-  BSPC, A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
-  TAB,  Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, QUOT,
-  LCTL, LGUI, LALT, LSFT, FN1,    SPC,      FN0,  LEFT, DOWN, UP,  RGHT),
-[1] = KEYMAP( /* Joe colemak */
+[0] = KEYMAP( /* Joe colemak */
   ESC,  Q,    W,    F,    P,    G,    J,    L,    U,    Y,    SCLN, MINS,
   BSPC, A,    R,    S,    T,    D,    H,    N,    E,    I,    O,    ENT,
   TAB,  Z,    X,    C,    V,    B,    K,    M,    COMM, DOT,  SLSH, QUOT,
   LCTL, LGUI, LALT, LSFT, FN1,    SPC,      FN0,  LEFT, DOWN, UP,  RGHT),
+[1] = KEYMAP( /* Joe qwerty */
+  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    MINS,
+  BSPC, A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
+  TAB,  Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, QUOT,
+  LCTL, LGUI, LALT, LSFT, FN1,    SPC,      FN0,  LEFT, DOWN, UP,  RGHT),
 [2] = KEYMAP( /* Joe RAISE */
   F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  F11,  F12,
   DEL,  FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, TRNS,

From 64dc4784e46cd5b5b2614569208fd85c9f9a67a9 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Sat, 21 Feb 2015 15:35:09 -0500
Subject: [PATCH 84/95] vlad

---
 keyboard/atomic/Makefile        |  2 +-
 keyboard/atomic/keymap_common.h | 16 +++++++++++++++-
 keyboard/atomic/keymap_vlad.c   | 14 ++++++++++++++
 3 files changed, 30 insertions(+), 2 deletions(-)
 create mode 100644 keyboard/atomic/keymap_vlad.c

diff --git a/keyboard/atomic/Makefile b/keyboard/atomic/Makefile
index a018b6cab8..c4e0cb45d7 100644
--- a/keyboard/atomic/Makefile
+++ b/keyboard/atomic/Makefile
@@ -55,7 +55,7 @@ SRC =	keymap_common.c \
 ifdef KEYMAP
     SRC := keymap_$(KEYMAP).c $(SRC)
 else
-    SRC := keymap_plain.c $(SRC)
+    SRC := keymap_vlad.c $(SRC)
 endif
 
 CONFIG_H = config.h
diff --git a/keyboard/atomic/keymap_common.h b/keyboard/atomic/keymap_common.h
index 7f807bbc07..c582c0135f 100644
--- a/keyboard/atomic/keymap_common.h
+++ b/keyboard/atomic/keymap_common.h
@@ -49,7 +49,7 @@ extern const uint16_t fn_actions[];
 }
 
 // ASK: Short Space layout
-#define KEYMAP_ASK( \
+#define KEYMAP_ASK_MESSY( \
     K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
     K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
     K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2D,   K2E, \
@@ -63,6 +63,20 @@ extern const uint16_t fn_actions[];
     { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_##K44, KC_NO,    KC_##K46, KC_NO,    KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
 }
 
+#define KEYMAP_ASK( \
+    K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C,   K0E,    \
+    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, \
+    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B,    K2C,   K2E, \
+    K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A,    K3B,   K3D, K3E, \
+     K40,  K41,  K43,  K44,        K46,     K47, K48, K4A, K4B, K4C, K4D, K4E  \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_NO,    KC_##K0E }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_NO,    KC_##K2E }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_NO,    KC_##K3D, KC_##K3E }, \
+    { KC_##K40, KC_##K41, KC_NO,    KC_##K43, KC_##K44, KC_NO,    KC_##K46, KC_##K47, KC_##K48, KC_NO,    KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E }  \
+}
+
 
 // MLO: Semi-Grid layout
 
diff --git a/keyboard/atomic/keymap_vlad.c b/keyboard/atomic/keymap_vlad.c
new file mode 100644
index 0000000000..e56bcf1618
--- /dev/null
+++ b/keyboard/atomic/keymap_vlad.c
@@ -0,0 +1,14 @@
+#include "keymap_common.h"
+
+// JCK: Semi-Standard layout
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    /* 0: qwerty */
+    [0] = KEYMAP_ASK(GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    MINS, EQL,    BSPC, \
+                     TAB,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    LBRC, RBRC, BSLS, DEL, \
+                     CAPS,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,    ENT,     VOLU, \
+                     LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH,    RSFT,    UP, VOLD, \
+                     LCTL,    LGUI,  LALT,   LGUI,     SPC,           RGUI,       RALT, RGUI, RCTL, LEFT, DOWN,   RGHT)
+};
+const uint16_t PROGMEM fn_actions[] = {
+};
\ No newline at end of file

From a538f71e41ad5c594250594b053f05e550667ebc Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 23 Feb 2015 23:44:11 -0500
Subject: [PATCH 85/95] led oops

---
 keyboard/atomic/led.c        |  9 ---------
 keyboard/atomic/matrix.c     |  8 --------
 keyboard/planck/keymap_joe.c |  2 +-
 keyboard/planck/led.c        | 18 +++++++++---------
 4 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/keyboard/atomic/led.c b/keyboard/atomic/led.c
index 7c98510801..2d52fbf1c3 100644
--- a/keyboard/atomic/led.c
+++ b/keyboard/atomic/led.c
@@ -22,13 +22,4 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 void led_set(uint8_t usb_led)
 {
-    if (usb_led & (1<<USB_LED_FUNCTION)) {
-        // Output high.
-        DDRF |= (1<<0);
-        PORTF |= (1<<0);
-    } else {
-        // Output low.
-        DDRF &= ~(1<<0);
-        PORTF &= ~(1<<0);
-    }
 }
diff --git a/keyboard/atomic/matrix.c b/keyboard/atomic/matrix.c
index 86803c9ed0..98102cb694 100644
--- a/keyboard/atomic/matrix.c
+++ b/keyboard/atomic/matrix.c
@@ -56,12 +56,6 @@ uint8_t matrix_cols(void)
     return MATRIX_COLS;
 }
 
-static
-void setup_leds(void) {
-  DDRF  |=  0x00;
-  PORTF |=  0x00;
-}
-
 
 void matrix_init(void)
 {
@@ -69,8 +63,6 @@ void matrix_init(void)
     unselect_rows();
     init_cols();
 
-    setup_leds();
-
     // initialize matrix state: all keys off
     for (uint8_t i=0; i < MATRIX_ROWS; i++) {
         matrix[i] = 0;
diff --git a/keyboard/planck/keymap_joe.c b/keyboard/planck/keymap_joe.c
index 15b16530e7..07122b702c 100644
--- a/keyboard/planck/keymap_joe.c
+++ b/keyboard/planck/keymap_joe.c
@@ -78,7 +78,7 @@ const uint16_t PROGMEM fn_actions[] = {
 };
 
 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
-{
+{ 
     keyevent_t event = record->event;
     switch (id) {
         case M_Q0:
diff --git a/keyboard/planck/led.c b/keyboard/planck/led.c
index 7c98510801..6cffd5ea7b 100644
--- a/keyboard/planck/led.c
+++ b/keyboard/planck/led.c
@@ -22,13 +22,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 void led_set(uint8_t usb_led)
 {
-    if (usb_led & (1<<USB_LED_FUNCTION)) {
-        // Output high.
-        DDRF |= (1<<0);
-        PORTF |= (1<<0);
-    } else {
-        // Output low.
-        DDRF &= ~(1<<0);
-        PORTF &= ~(1<<0);
-    }
+    // if (usb_led & (1<<USB_LED_FUNCTION)) {
+    //     // Output high.
+    //     DDRF |= (1<<0);
+    //     PORTF |= (1<<0);
+    // } else {
+    //     // Output low.
+    //     DDRF &= ~(1<<0);
+    //     PORTF &= ~(1<<0);
+    // }
 }

From ea6de22aeed15eb5009698979065b0b504ac26cc Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 26 Feb 2015 16:35:54 -0500
Subject: [PATCH 86/95] brett

---
 keyboard/planck/Makefile       |  2 +-
 keyboard/planck/keymap_brett.c | 42 ++++++++++++++++++++++++++++++++++
 keyboard/planck/keymap_jack.c  |  5 ++--
 3 files changed, 45 insertions(+), 4 deletions(-)
 create mode 100644 keyboard/planck/keymap_brett.c

diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index 3bc12da023..c456cb51b3 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -55,7 +55,7 @@ SRC =	keymap_common.c \
 ifdef KEYMAP
     SRC := keymap_$(KEYMAP).c $(SRC)
 else
-    SRC := keymap_joe.c $(SRC)
+    SRC := keymap_jack.c $(SRC)
 endif
 
 CONFIG_H = config.h
diff --git a/keyboard/planck/keymap_brett.c b/keyboard/planck/keymap_brett.c
new file mode 100644
index 0000000000..16a12837cc
--- /dev/null
+++ b/keyboard/planck/keymap_brett.c
@@ -0,0 +1,42 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP( 
+  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  LCTL, A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
+  LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, RSFT,
+  LGUI, TAB,  LCTL, LALT, FN2,     SPC,     FN1,  LEFT, DOWN, UP,   RGHT),
+[1] = KEYMAP( /* RAISE */
+  GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    DEL,
+  TRNS, F1,   F2,   F3,   F4,   F5,   F6,   4,    5,    6,    TRNS, TRNS,
+  TRNS, F7,   F8,   F9,   F10,  F11,  F12,  1,    2,    3,    TRNS, PGUP,
+  MPRV, MNXT, TRNS, MUTE, TRNS,    TRNS,    FN1,  TRNS, TRNS, TRNS, PGDN),
+[2] = KEYMAP( /* LOWER */
+  FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, MINS,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, EQL,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  MPLY, MSTP, VOLU, VOLD, FN2,     TRNS,    TRNS, TRNS, TRNS, TRNS, TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_MOMENTARY(1),  // to Fn overlay
+    [2] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay 
+
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+
+    [29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
+};
diff --git a/keyboard/planck/keymap_jack.c b/keyboard/planck/keymap_jack.c
index 5b226813d0..3724bca49f 100644
--- a/keyboard/planck/keymap_jack.c
+++ b/keyboard/planck/keymap_jack.c
@@ -25,9 +25,8 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 const uint16_t PROGMEM fn_actions[] = {
     [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
     [2] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay 
-    // [1] = ACTION_LAYER_ON_OFF(1),
-    // [2] = ACTION_LAYER_ON_OFF(2),
-    [3] = ACTION_DEFAULT_LAYER_SET(0), 
+
+    [3] = ACTION_DEFAULT_LAYER_SET(0),  
     [4] = ACTION_DEFAULT_LAYER_SET(1),
 
     [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),

From ceff93844bdde7b002fb9abc66b583126c2ae907 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 2 Mar 2015 20:37:17 -0500
Subject: [PATCH 87/95] simon

---
 keyboard/planck/keymap_brett.c |  4 ++--
 keyboard/planck/keymap_jack.c  |  2 +-
 keyboard/planck/keymap_simon.c | 44 ++++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 3 deletions(-)
 create mode 100644 keyboard/planck/keymap_simon.c

diff --git a/keyboard/planck/keymap_brett.c b/keyboard/planck/keymap_brett.c
index 16a12837cc..378e78149f 100644
--- a/keyboard/planck/keymap_brett.c
+++ b/keyboard/planck/keymap_brett.c
@@ -5,7 +5,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
   LCTL, A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
   LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, RSFT,
-  LGUI, TAB,  LCTL, LALT, FN2,     SPC,     FN1,  LEFT, DOWN, UP,   RGHT),
+  LGUI, TAB,  RSFT, LALT, FN2,     SPC,     FN1,  LEFT, DOWN, UP,   RGHT),
 [1] = KEYMAP( /* RAISE */
   GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    DEL,
   TRNS, F1,   F2,   F3,   F4,   F5,   F6,   4,    5,    6,    TRNS, TRNS,
@@ -13,7 +13,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   MPRV, MNXT, TRNS, MUTE, TRNS,    TRNS,    FN1,  TRNS, TRNS, TRNS, PGDN),
 [2] = KEYMAP( /* LOWER */
   FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, MINS,
-  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, EQL,
+  TRNS, TRNS, TRNS, PAUSE, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, EQL,
   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
   MPLY, MSTP, VOLU, VOLD, FN2,     TRNS,    TRNS, TRNS, TRNS, TRNS, TRNS),
 };
diff --git a/keyboard/planck/keymap_jack.c b/keyboard/planck/keymap_jack.c
index 3724bca49f..c74812121f 100644
--- a/keyboard/planck/keymap_jack.c
+++ b/keyboard/planck/keymap_jack.c
@@ -24,7 +24,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
 };
 const uint16_t PROGMEM fn_actions[] = {
     [1] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
-    [2] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay 
+    [2] = ACTION_LAYER_MOMENTARY(3),  // to Fn overlay
 
     [3] = ACTION_DEFAULT_LAYER_SET(0),  
     [4] = ACTION_DEFAULT_LAYER_SET(1),
diff --git a/keyboard/planck/keymap_simon.c b/keyboard/planck/keymap_simon.c
new file mode 100644
index 0000000000..37951364be
--- /dev/null
+++ b/keyboard/planck/keymap_simon.c
@@ -0,0 +1,44 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP( /* Jack */
+  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  TAB,  A,    S,    D,    F,    G,    H,    J,    K,    L,    DOT,  ENT,
+  LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SCLN, DEL,
+  LCTL, ENT,  LALT, CAPS, FN2,    SPC,      FN1,  LEFT, DOWN, UP,   RGHT),
+[1] = KEYMAP( /* Jack RAISE */
+  TRNS, F1,   F2,   F3,   F4,   NO,   FN11, FN9,  FN12, NO,   FN14, TRNS,
+  TRNS, F5,   F6,   F7,   F8,   FN16, SLSH, MINS, EQL,  LBRC, FN8,  TRNS,
+  TRNS, F9,   F10,  F11,  F12,  F15,  F16,  FN22, SCLN, MINS, QUOT, TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS,    TRNS,    TRNS, TRNS, TRNS, TRNS, TRNS),
+[2] = KEYMAP( /* Jack LOWER */
+  FN22, 1,    2,    3,   FN13, FN14, FN15, FN16, FN17, FN18, FN19, BSPC,
+  TRNS, 4,    5,    6,   TRNS, TRNS, TRNS, FN20, FN21, FN23, FN24, FN28,
+  TRNS, 7,    8,    9,   0,    FN28, FN15,   F7,   F8,   F9,   F10,  TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS,    TRNS,    TRNS, TRNS, TRNS, TRNS, TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_MOMENTARY(1),  // to Fn overlay
+    [2] = ACTION_LAYER_MOMENTARY(2),  // to Fn overlay
+
+    [8]  = ACTION_MODS_KEY(MOD_LSFT, KC_SLSH),
+    [9]  = ACTION_MODS_KEY(MOD_LSFT, KC_QUOT),
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1),
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2),
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3),
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4),
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5),
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6),
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7),
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8),
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9),
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0),
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS),
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL),
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV),
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC),
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC),
+    [28] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),
+
+    [29] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
+};

From c35c4283b9c2c65d62fe8dc5e4b7ca49a8f5af33 Mon Sep 17 00:00:00 2001
From: Jun Wako <wakojun@gmail.com>
Date: Thu, 5 Mar 2015 10:38:18 +0900
Subject: [PATCH 88/95] infinity: For production model and add SpaceFn

---
 keyboard/infinity/Makefile        |  7 ++++++-
 keyboard/infinity/config.h        |  4 ++++
 keyboard/infinity/keymap.c        |  3 ++-
 keyboard/infinity/keymap_common.h | 28 +++++++++++++++++++++++++---
 4 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/keyboard/infinity/Makefile b/keyboard/infinity/Makefile
index 758296f335..e33c239afb 100644
--- a/keyboard/infinity/Makefile
+++ b/keyboard/infinity/Makefile
@@ -12,11 +12,16 @@ OBJDIR = ./build
 
 OBJECTS = \
 	$(OBJDIR)/matrix.o \
-	$(OBJDIR)/keymap.o \
 	$(OBJDIR)/keymap_common.o \
 	$(OBJDIR)/led.o \
 	$(OBJDIR)/main.o
 
+ifdef KEYMAP
+    OBJECTS := $(OBJDIR)/keymap_$(KEYMAP).o $(OBJECTS)
+else
+    OBJECTS := $(OBJDIR)/keymap.o $(OBJECTS)
+endif
+
 CONFIG_H = config.h
 
 INCLUDE_PATHS = -I.
diff --git a/keyboard/infinity/config.h b/keyboard/infinity/config.h
index 28f2ca0293..dc734dbdbe 100644
--- a/keyboard/infinity/config.h
+++ b/keyboard/infinity/config.h
@@ -36,4 +36,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* key combination for command */
 #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) 
 
+
+/* for prototype */
+//#define INFINITY_PROTOTYPE
+
 #endif
diff --git a/keyboard/infinity/keymap.c b/keyboard/infinity/keymap.c
index 100142f41c..4726cee653 100644
--- a/keyboard/infinity/keymap.c
+++ b/keyboard/infinity/keymap.c
@@ -20,6 +20,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
            LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT,  \
            LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,FN0, \
            NO,  LGUI,LALT,          SPC,                RALT,RGUI,NO, NO),
+
     /* Layer 1: HHKB mode (HHKB Fn)
      * ,-----------------------------------------------------------.
      * |Pwr| F1| F2| F3| F4| F5| F6| F7| F8| F9|F10|F11|F12|Ins|Del|
@@ -33,7 +34,7 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
      * |     |Gui|Alt  |         Space         |Alt  |Gui|   |     |
      * `-----------------------------------------------------------'
      */ 
-    [1]= 
+    [1] = 
     KEYMAP(PWR, F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, INS, DEL,   \
            CAPS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,PSCR,SLCK,PAUS, UP, TRNS, BSPC,      \
            TRNS,VOLD,VOLU,MUTE,TRNS,TRNS,PAST,PSLS,HOME,PGUP,LEFT,RGHT,PENT,            \
diff --git a/keyboard/infinity/keymap_common.h b/keyboard/infinity/keymap_common.h
index 7a5f778f2d..b0f765bfeb 100644
--- a/keyboard/infinity/keymap_common.h
+++ b/keyboard/infinity/keymap_common.h
@@ -33,9 +33,9 @@ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
 extern const uint16_t fn_actions[];
 
 
-/* GH60 keymap definition macro
- * K2C, K31 and  K3C are extra keys for ISO
- */
+#ifdef INFINITY_PROTOTYPE
+
+/* Infinity prototype */
 #define KEYMAP( \
     K00, K10, K20, K30, K40, K50, K60, K70, K80, K01, K11, K21, K31, K41, K86, \
     K51, K61, K71, K81, K02, K12, K22, K32, K42, K52, K62, K72, K82, K03, \
@@ -54,5 +54,27 @@ extern const uint16_t fn_actions[];
     { KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86 }  \
 }
 
+#else
+
+/* Infinity production */
+#define KEYMAP( \
+    K00, K10, K20, K30, K40, K50, K60, K70, K80, K01, K11, K21, K31, K41, K51, \
+    K61, K71, K81, K02, K12, K22, K32, K42, K52, K62, K72, K82, K03, K13, \
+    K23, K33, K43, K53, K63, K73, K83, K04, K14, K24, K34, K44, K54, \
+    K64, K74, K84, K05, K15, K25, K35, K45, K55, K65, K75, K85, K06, \
+    K16, K26, K36,           K46,                K56, K66, K76, K86 \
+) { \
+    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06 }, \
+    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16 }, \
+    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26 }, \
+    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36 }, \
+    { KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46 }, \
+    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56 }, \
+    { KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66 }, \
+    { KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76 }, \
+    { KC_##K80, KC_##K81, KC_##K82, KC_##K83, KC_##K84, KC_##K85, KC_##K86 }  \
+}
+
 #endif
 
+#endif

From 0fcb3b65f8f980bee606b3be44cad1469c42ea86 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Thu, 5 Mar 2015 14:29:33 -0500
Subject: [PATCH 89/95] brett

---
 keyboard/planck/keymap_brett.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/keyboard/planck/keymap_brett.c b/keyboard/planck/keymap_brett.c
index 378e78149f..97d832b47a 100644
--- a/keyboard/planck/keymap_brett.c
+++ b/keyboard/planck/keymap_brett.c
@@ -5,15 +5,15 @@ const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
   ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
   LCTL, A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, ENT,
   LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, RSFT,
-  LGUI, TAB,  RSFT, LALT, FN2,     SPC,     FN1,  LEFT, DOWN, UP,   RGHT),
+  TAB, LGUI,  RSFT, LALT, FN2,     SPC,     FN1,  LEFT, DOWN, UP,   RGHT),
 [1] = KEYMAP( /* RAISE */
   GRV,  1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    DEL,
-  TRNS, F1,   F2,   F3,   F4,   F5,   F6,   4,    5,    6,    TRNS, TRNS,
-  TRNS, F7,   F8,   F9,   F10,  F11,  F12,  1,    2,    3,    TRNS, PGUP,
-  MPRV, MNXT, TRNS, MUTE, TRNS,    TRNS,    FN1,  TRNS, TRNS, TRNS, PGDN),
+  TRNS, F1,   F2,   F3,   F4,   F5,   F6,   4,    5,    6,   QUOT, TRNS,
+  TRNS, F7,   F8,   F9,   F10,  F11,  F12,  1,    2,    3,   TRNS, PGUP,
+  MPRV, MNXT, TRNS, MUTE, TRNS,    TRNS,    FN1,  0,  0,  TRNS, PGDN),
 [2] = KEYMAP( /* LOWER */
-  FN22, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, MINS,
-  TRNS, TRNS, TRNS, PAUSE, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, EQL,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MINS,
+  TRNS, TRNS, TRNS, PAUSE, TRNS, TRNS, TRNS, TRNS, LBRC, RBRC, BSLS, EQL,
   TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
   MPLY, MSTP, VOLU, VOLD, FN2,     TRNS,    TRNS, TRNS, TRNS, TRNS, TRNS),
 };

From 15b9bce6bab13d85529fe9aaa91b3df9cd773e13 Mon Sep 17 00:00:00 2001
From: Wilba6582 <Jason.S.Wiliams@gmail.com>
Date: Tue, 17 Mar 2015 00:43:37 +1100
Subject: [PATCH 90/95] Initial commit for Planck PCB Rev 1. - Backlight on PB7
 controlled by Timer1 Fast PWM (no interrupts). - Backlight commands connected
 temporarily to top left keys. - Backlight init called from matrix.c, since
 there's no generic keyboard_init() override function.

---
 keyboard/planck/Makefile       |  6 ++-
 keyboard/planck/config.h       |  4 ++
 keyboard/planck/keymap_wilba.c | 56 +++++++++++++++++++++++++
 keyboard/planck/led.c          | 22 +++++-----
 keyboard/planck/matrix.c       | 74 +++++++++++++++++++++++-----------
 5 files changed, 127 insertions(+), 35 deletions(-)
 create mode 100644 keyboard/planck/keymap_wilba.c

diff --git a/keyboard/planck/Makefile b/keyboard/planck/Makefile
index c456cb51b3..001f17f316 100644
--- a/keyboard/planck/Makefile
+++ b/keyboard/planck/Makefile
@@ -50,7 +50,8 @@ TARGET_DIR = .
 # project specific files
 SRC =	keymap_common.c \
 	matrix.c \
-	led.c
+	led.c \
+	backlight.c
 
 ifdef KEYMAP
     SRC := keymap_$(KEYMAP).c $(SRC)
@@ -118,9 +119,10 @@ MOUSEKEY_ENABLE = yes	# Mouse keys(+4700)
 EXTRAKEY_ENABLE = yes	# Audio control and System control(+450)
 CONSOLE_ENABLE = yes	# Console for debug(+400)
 COMMAND_ENABLE = yes    # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
 #SLEEP_LED_ENABLE = yes  # Breathing sleep LED during USB suspend
 NKRO_ENABLE = yes	# USB Nkey Rollover - not yet supported in LUFA
-
+BACKLIGHT_ENABLE = yes  # Enable keyboard backlight functionality
 
 # Optimize size but this may cause error "relocation truncated to fit"
 #EXTRALDFLAGS = -Wl,--relax
diff --git a/keyboard/planck/config.h b/keyboard/planck/config.h
index 81637f45b2..0b0c152479 100644
--- a/keyboard/planck/config.h
+++ b/keyboard/planck/config.h
@@ -34,6 +34,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* define if matrix has ghost */
 //#define MATRIX_HAS_GHOST
 
+/* number of backlight levels */
+/* NOTE: this is the max value of 0..BACKLIGHT_LEVELS so really 16 levels. */
+#define BACKLIGHT_LEVELS 15
+
 /* Set 0 if debouncing isn't needed */
 #define DEBOUNCE    5
 
diff --git a/keyboard/planck/keymap_wilba.c b/keyboard/planck/keymap_wilba.c
new file mode 100644
index 0000000000..696fda42e3
--- /dev/null
+++ b/keyboard/planck/keymap_wilba.c
@@ -0,0 +1,56 @@
+#include "keymap_common.h"
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = KEYMAP( /* Wilba */
+  FN27, FN28, FN29, E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  TAB,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
+  LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
+  LCTL, LGUI, LALT, RSFT, FN1,  SPC,        FN2,  LEFT, DOWN, UP,   RGHT),
+[1] = KEYMAP( /* Wilba Alternate */
+  ESC,  Q,    W,    E,    R,    T,    Y,    U,    I,    O,    P,    BSPC,
+  TAB,  A,    S,    D,    F,    G,    H,    J,    K,    L,    SCLN, QUOT,
+  LSFT, Z,    X,    C,    V,    B,    N,    M,    COMM, DOT,  SLSH, ENT,
+  LCTL, LGUI, LALT, RSFT, FN1,  SPC,        FN2,  LEFT, DOWN, UP,   RGHT),
+[2] = KEYMAP( /* Wilba LOWER */
+  TRNS, 1,    2,    3,    4,    5,    6,    7,    8,    9,    0,    TRNS,
+  TRNS, F11,  F12,  LBRC, RBRC, FN20, EQL,  FN23, FN24, MINS, FN21, TRNS,
+  TRNS, BSLS, GRV,  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, FN1,  TRNS,       TRNS, MNXT, VOLD, VOLU, MPLY),
+[3] = KEYMAP( /* Wilba RAISE */
+  TRNS, FN10, FN11, FN12, FN13, FN14, FN15, FN16, FN17, FN18, FN19, TRNS,
+  TRNS, F1,   F2,   F3,   F4,   F5,   F6,   F7,   F8,   F9,   F10,  TRNS,  
+  TRNS, FN25, FN22, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,
+  TRNS, TRNS, TRNS, TRNS, TRNS, TRNS,       FN2,  TRNS, TRNS, TRNS, TRNS),
+};
+const uint16_t PROGMEM fn_actions[] = {
+    [1] = ACTION_LAYER_MOMENTARY(2),  // LOWER
+    [2] = ACTION_LAYER_MOMENTARY(3),  // RAISE
+
+    [3] = ACTION_DEFAULT_LAYER_SET(0),  
+    [4] = ACTION_DEFAULT_LAYER_SET(1),
+
+    [10] = ACTION_MODS_KEY(MOD_LSFT, KC_1), // !
+    [11] = ACTION_MODS_KEY(MOD_LSFT, KC_2), // @
+    [12] = ACTION_MODS_KEY(MOD_LSFT, KC_3), // #
+    [13] = ACTION_MODS_KEY(MOD_LSFT, KC_4), // $
+    [14] = ACTION_MODS_KEY(MOD_LSFT, KC_5), // %
+    [15] = ACTION_MODS_KEY(MOD_LSFT, KC_6), // ^
+    [16] = ACTION_MODS_KEY(MOD_LSFT, KC_7), // &
+    [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
+    [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9), // (
+    [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0), // )
+	
+    [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // _
+    [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // +
+    [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // ~
+    [23] = ACTION_MODS_KEY(MOD_LSFT, KC_LBRC), // {
+    [24] = ACTION_MODS_KEY(MOD_LSFT, KC_RBRC), // }
+    [25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), // |
+
+    [26] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
+	
+	[27] = ACTION_BACKLIGHT_TOGGLE(),
+	[28] = ACTION_BACKLIGHT_INCREASE(),
+	[29] = ACTION_BACKLIGHT_DECREASE()
+	
+};
diff --git a/keyboard/planck/led.c b/keyboard/planck/led.c
index 6cffd5ea7b..448df2ccfb 100644
--- a/keyboard/planck/led.c
+++ b/keyboard/planck/led.c
@@ -22,13 +22,17 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 void led_set(uint8_t usb_led)
 {
-    // if (usb_led & (1<<USB_LED_FUNCTION)) {
-    //     // Output high.
-    //     DDRF |= (1<<0);
-    //     PORTF |= (1<<0);
-    // } else {
-    //     // Output low.
-    //     DDRF &= ~(1<<0);
-    //     PORTF &= ~(1<<0);
-    // }
+	// Using PE6 Caps Lock LED
+	if (usb_led & (1<<USB_LED_CAPS_LOCK))
+    {
+        // Output high.
+        DDRE |= (1<<6);
+        PORTE |= (1<<6);
+    }
+    else
+    {
+        // Output low.
+        DDRE &= ~(1<<6);
+        PORTE &= ~(1<<6);
+    }
 }
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c
index 38d35e3e07..8cd9ac85b6 100644
--- a/keyboard/planck/matrix.c
+++ b/keyboard/planck/matrix.c
@@ -27,6 +27,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "debug.h"
 #include "util.h"
 #include "matrix.h"
+#include "backlight.h" // TODO fix this dependency 
 
 
 #ifndef DEBOUNCE
@@ -57,6 +58,13 @@ uint8_t matrix_cols(void)
 
 void matrix_init(void)
 {
+    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
+    MCUCR |= (1<<JTD);
+    MCUCR |= (1<<JTD);
+
+	// TODO fix this dependency 
+	backlight_init_ports();
+	
     // initialize row and col
     unselect_rows();
     init_cols();
@@ -134,10 +142,19 @@ uint8_t matrix_key_count(void)
     return count;
 }
 
+//
+// Planck PCB Rev 1 Pin Assignments
+//
+// Column: 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11
+// Pin:    F1, F0, B0, C7, F4, F5, F6, F7, D4, D6, B4, D7
+//
+
 static void init_cols(void)
 {
-    DDRB &= ~(1<<6 | 1<<5 | 1<<4);
-    PORTB |= (1<<6 | 1<<5 | 1<<4);
+    DDRB &= ~(1<<4 | 1<<0);
+    PORTB |= (1<<4 | 1<<0);
+    DDRC &= ~(1<<7);
+    PORTC |= (1<<7);
     DDRD &= ~(1<<7 | 1<<6 | 1<<4);
     PORTD |= (1<<7 | 1<<6 | 1<<4);
     DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
@@ -147,46 +164,55 @@ static void init_cols(void)
 
 static matrix_row_t read_cols(void)
 {
-  return (PIND&(1<<4) ? 0 : (1<<0)) |
-         (PIND&(1<<6) ? 0 : (1<<1)) |
-         (PIND&(1<<7) ? 0 : (1<<2)) |
-         (PINB&(1<<4) ? 0 : (1<<3)) |
-         (PINB&(1<<5) ? 0 : (1<<4)) |
-         (PINB&(1<<6) ? 0 : (1<<5)) |
-         (PINF&(1<<7) ? 0 : (1<<6)) |
-         (PINF&(1<<6) ? 0 : (1<<7)) |
-         (PINF&(1<<5) ? 0 : (1<<8)) |
-         (PINF&(1<<4) ? 0 : (1<<9)) |
-         (PINF&(1<<1) ? 0 : (1<<10)) |
-         (PINF&(1<<0) ? 0 : (1<<11));
+  return (PINF&(1<<1) ? 0 : (1<<0)) |
+         (PINF&(1<<0) ? 0 : (1<<1)) |
+         (PINB&(1<<0) ? 0 : (1<<2)) |
+         (PINC&(1<<7) ? 0 : (1<<3)) |
+         (PINF&(1<<4) ? 0 : (1<<4)) |
+         (PINF&(1<<5) ? 0 : (1<<5)) |
+         (PINF&(1<<6) ? 0 : (1<<6)) |
+         (PINF&(1<<7) ? 0 : (1<<7)) |
+         (PIND&(1<<4) ? 0 : (1<<8)) |
+         (PIND&(1<<6) ? 0 : (1<<9)) |
+         (PINB&(1<<4) ? 0 : (1<<10)) |
+         (PIND&(1<<7) ? 0 : (1<<11));
          
 }
 
 static void unselect_rows(void)
 {
-    DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
-    PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3);
+    DDRB &= ~(1<<5 | 1<<6);
+    PORTB |= (1<<5 | 1<<6);
+    DDRD &= ~(1<<0 | 1<<5);
+    PORTD |= (1<<0 | 1<<5);
     
 }
 
+//
+// Planck PCB Rev 1 Pin Assignments
+//
+// Row: 0,  1,  2,  3
+// Pin: D0, D5, B5, B6
+//
+
 static void select_row(uint8_t row)
 {
     switch (row) {
         case 0:
-            DDRB  |= (1<<0);
-            PORTB &= ~(1<<0);
+            DDRD  |= (1<<0);
+            PORTD &= ~(1<<0);
             break;
         case 1:
-            DDRB  |= (1<<1);
-            PORTB &= ~(1<<1);
+            DDRD  |= (1<<5);
+            PORTD &= ~(1<<5);
             break;
         case 2:
-            DDRB  |= (1<<2);
-            PORTB &= ~(1<<2);
+            DDRB  |= (1<<5);
+            PORTB &= ~(1<<5);
             break;
         case 3:
-            DDRB  |= (1<<3);
-            PORTB &= ~(1<<3);
+            DDRB  |= (1<<6);
+            PORTB &= ~(1<<6);
             break;
         
     }

From b80b6b369c5ecb5c7232edf1e8cebe8c12078d6e Mon Sep 17 00:00:00 2001
From: Wilba6582 <Jason.S.Wiliams@gmail.com>
Date: Tue, 17 Mar 2015 00:51:36 +1100
Subject: [PATCH 91/95] Added backlight.h, backlight.c

---
 keyboard/planck/backlight.c | 46 +++++++++++++++++++++++++++++++++++++
 keyboard/planck/backlight.h |  2 ++
 2 files changed, 48 insertions(+)
 create mode 100644 keyboard/planck/backlight.c
 create mode 100644 keyboard/planck/backlight.h

diff --git a/keyboard/planck/backlight.c b/keyboard/planck/backlight.c
new file mode 100644
index 0000000000..d12dcf2386
--- /dev/null
+++ b/keyboard/planck/backlight.c
@@ -0,0 +1,46 @@
+
+#include <avr/io.h>
+#include "backlight.h"
+
+
+void backlight_init_ports()
+{
+	// Setup PB7 as output and output low.
+	DDRB |= (1<<7);
+	PORTB &= ~(1<<7);
+	
+	// Use full 16-bit resolution. 
+	ICR1 = 0xFFFF;
+
+	// I could write a wall of text here to explain... but TL;DW
+	// Go read the ATmega32u4 datasheet.
+	// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
+	
+	// Pin PB7 = OCR1C (Timer 1, Channel C)
+	// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
+	// (i.e. start high, go low when counter matches.)
+	// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
+	// Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
+	
+	TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
+	TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+	
+	// Default to zero duty cycle.
+	OCR1C = 0x0000;
+}
+
+void backlight_set(uint8_t level)
+{
+	if ( level == 0 )
+	{
+		// Turn off PWM control on PB7, revert to output low.
+		TCCR1A &= ~(_BV(COM1C1));
+	}
+	else
+	{
+		// Turn on PWM control of PB7
+		TCCR1A |= _BV(COM1C1);
+		OCR1C = level << 12 | 0x0FFF;
+	}
+}
+
diff --git a/keyboard/planck/backlight.h b/keyboard/planck/backlight.h
new file mode 100644
index 0000000000..0fe1f4a72b
--- /dev/null
+++ b/keyboard/planck/backlight.h
@@ -0,0 +1,2 @@
+
+void backlight_init_ports(void);

From 65680819df13585a563296f008be1a4b0ee8045a Mon Sep 17 00:00:00 2001
From: Wilba6582 <Jason.S.Wiliams@gmail.com>
Date: Tue, 17 Mar 2015 00:56:41 +1100
Subject: [PATCH 92/95] Replaced tabs with spaces to match TMK convention.

---
 keyboard/planck/backlight.c    | 64 +++++++++++++++++-----------------
 keyboard/planck/keymap_wilba.c | 12 +++----
 keyboard/planck/led.c          |  4 +--
 keyboard/planck/matrix.c       |  6 ++--
 4 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/keyboard/planck/backlight.c b/keyboard/planck/backlight.c
index d12dcf2386..ee7e31ee9c 100644
--- a/keyboard/planck/backlight.c
+++ b/keyboard/planck/backlight.c
@@ -5,42 +5,42 @@
 
 void backlight_init_ports()
 {
-	// Setup PB7 as output and output low.
-	DDRB |= (1<<7);
-	PORTB &= ~(1<<7);
-	
-	// Use full 16-bit resolution. 
-	ICR1 = 0xFFFF;
+    // Setup PB7 as output and output low.
+    DDRB |= (1<<7);
+    PORTB &= ~(1<<7);
+    
+    // Use full 16-bit resolution. 
+    ICR1 = 0xFFFF;
 
-	// I could write a wall of text here to explain... but TL;DW
-	// Go read the ATmega32u4 datasheet.
-	// And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
-	
-	// Pin PB7 = OCR1C (Timer 1, Channel C)
-	// Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
-	// (i.e. start high, go low when counter matches.)
-	// WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
-	// Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
-	
-	TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
-	TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
-	
-	// Default to zero duty cycle.
-	OCR1C = 0x0000;
+    // I could write a wall of text here to explain... but TL;DW
+    // Go read the ATmega32u4 datasheet.
+    // And this: http://blog.saikoled.com/post/43165849837/secret-konami-cheat-code-to-high-resolution-pwm-on
+    
+    // Pin PB7 = OCR1C (Timer 1, Channel C)
+    // Compare Output Mode = Clear on compare match, Channel C = COM1C1=1 COM1C0=0
+    // (i.e. start high, go low when counter matches.)
+    // WGM Mode 14 (Fast PWM) = WGM13=1 WGM12=1 WGM11=1 WGM10=0
+    // Clock Select = clk/1 (no prescaling) = CS12=0 CS11=0 CS10=1
+    
+    TCCR1A = _BV(COM1C1) | _BV(WGM11); // = 0b00001010;
+    TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // = 0b00011001;
+    
+    // Default to zero duty cycle.
+    OCR1C = 0x0000;
 }
 
 void backlight_set(uint8_t level)
 {
-	if ( level == 0 )
-	{
-		// Turn off PWM control on PB7, revert to output low.
-		TCCR1A &= ~(_BV(COM1C1));
-	}
-	else
-	{
-		// Turn on PWM control of PB7
-		TCCR1A |= _BV(COM1C1);
-		OCR1C = level << 12 | 0x0FFF;
-	}
+    if ( level == 0 )
+    {
+        // Turn off PWM control on PB7, revert to output low.
+        TCCR1A &= ~(_BV(COM1C1));
+    }
+    else
+    {
+        // Turn on PWM control of PB7
+        TCCR1A |= _BV(COM1C1);
+        OCR1C = level << 12 | 0x0FFF;
+    }
 }
 
diff --git a/keyboard/planck/keymap_wilba.c b/keyboard/planck/keymap_wilba.c
index 696fda42e3..9781f8fcd8 100644
--- a/keyboard/planck/keymap_wilba.c
+++ b/keyboard/planck/keymap_wilba.c
@@ -39,7 +39,7 @@ const uint16_t PROGMEM fn_actions[] = {
     [17] = ACTION_MODS_KEY(MOD_LSFT, KC_8), // *
     [18] = ACTION_MODS_KEY(MOD_LSFT, KC_9), // (
     [19] = ACTION_MODS_KEY(MOD_LSFT, KC_0), // )
-	
+    
     [20] = ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // _
     [21] = ACTION_MODS_KEY(MOD_LSFT, KC_EQL), // +
     [22] = ACTION_MODS_KEY(MOD_LSFT, KC_GRV), // ~
@@ -48,9 +48,9 @@ const uint16_t PROGMEM fn_actions[] = {
     [25] = ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), // |
 
     [26] = ACTION_MODS_KEY(MOD_LSFT | MOD_RSFT, KC_PAUSE),
-	
-	[27] = ACTION_BACKLIGHT_TOGGLE(),
-	[28] = ACTION_BACKLIGHT_INCREASE(),
-	[29] = ACTION_BACKLIGHT_DECREASE()
-	
+    
+    [27] = ACTION_BACKLIGHT_TOGGLE(),
+    [28] = ACTION_BACKLIGHT_INCREASE(),
+    [29] = ACTION_BACKLIGHT_DECREASE()
+    
 };
diff --git a/keyboard/planck/led.c b/keyboard/planck/led.c
index 448df2ccfb..1f36434883 100644
--- a/keyboard/planck/led.c
+++ b/keyboard/planck/led.c
@@ -22,8 +22,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 void led_set(uint8_t usb_led)
 {
-	// Using PE6 Caps Lock LED
-	if (usb_led & (1<<USB_LED_CAPS_LOCK))
+    // Using PE6 Caps Lock LED
+    if (usb_led & (1<<USB_LED_CAPS_LOCK))
     {
         // Output high.
         DDRE |= (1<<6);
diff --git a/keyboard/planck/matrix.c b/keyboard/planck/matrix.c
index 8cd9ac85b6..e3926caece 100644
--- a/keyboard/planck/matrix.c
+++ b/keyboard/planck/matrix.c
@@ -62,9 +62,9 @@ void matrix_init(void)
     MCUCR |= (1<<JTD);
     MCUCR |= (1<<JTD);
 
-	// TODO fix this dependency 
-	backlight_init_ports();
-	
+    // TODO fix this dependency 
+    backlight_init_ports();
+    
     // initialize row and col
     unselect_rows();
     init_cols();

From a296c83805c051ee0f416f11ded6124fac402579 Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 16 Mar 2015 11:59:21 -0400
Subject: [PATCH 93/95] Create handwire-matrix.c

---
 keyboard/planck/handwire-matrix.c | 193 ++++++++++++++++++++++++++++++
 1 file changed, 193 insertions(+)
 create mode 100644 keyboard/planck/handwire-matrix.c

diff --git a/keyboard/planck/handwire-matrix.c b/keyboard/planck/handwire-matrix.c
new file mode 100644
index 0000000000..2f2dbdb108
--- /dev/null
+++ b/keyboard/planck/handwire-matrix.c
@@ -0,0 +1,193 @@
+/*
+Copyright 2012 Jun Wako 
+Generated by planckkeyboard.com (2014 Jack Humbert)
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+ * scan matrix
+ */
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/io.h>
+#include <util/delay.h>
+#include "print.h"
+#include "debug.h"
+#include "util.h"
+#include "matrix.h"
+
+
+#ifndef DEBOUNCE
+#   define DEBOUNCE 10
+#endif
+static uint8_t debouncing = DEBOUNCE;
+
+/* matrix state(1:on, 0:off) */
+static matrix_row_t matrix[MATRIX_ROWS];
+static matrix_row_t matrix_debouncing[MATRIX_ROWS];
+
+static matrix_row_t read_cols(void);
+static void init_cols(void);
+static void unselect_rows(void);
+static void select_row(uint8_t row);
+
+inline
+uint8_t matrix_rows(void)
+{
+    return MATRIX_ROWS;
+}
+
+inline
+uint8_t matrix_cols(void)
+{
+    return MATRIX_COLS;
+}
+
+void matrix_init(void)
+{
+    // initialize row and col
+    unselect_rows();
+    init_cols();
+
+    // initialize matrix state: all keys off
+    for (uint8_t i=0; i < MATRIX_ROWS; i++) {
+        matrix[i] = 0;
+        matrix_debouncing[i] = 0;
+    }
+}
+
+uint8_t matrix_scan(void)
+{
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        select_row(i);
+        _delay_us(30);  // without this wait read unstable value.
+        matrix_row_t cols = read_cols();
+        if (matrix_debouncing[i] != cols) {
+            matrix_debouncing[i] = cols;
+            if (debouncing) {
+                debug("bounce!: "); debug_hex(debouncing); debug("\n");
+            }
+            debouncing = DEBOUNCE;
+        }
+        unselect_rows();
+    }
+
+    if (debouncing) {
+        if (--debouncing) {
+            _delay_ms(1);
+        } else {
+            for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+                matrix[i] = matrix_debouncing[i];
+            }
+        }
+    }
+
+    return 1;
+}
+
+bool matrix_is_modified(void)
+{
+    if (debouncing) return false;
+    return true;
+}
+
+inline
+bool matrix_is_on(uint8_t row, uint8_t col)
+{
+    return (matrix[row] & ((matrix_row_t)1<col));
+}
+
+inline
+matrix_row_t matrix_get_row(uint8_t row)
+{
+    return matrix[row];
+}
+
+void matrix_print(void)
+{
+    print("\nr/c 0123456789ABCDEF\n");
+    for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
+        phex(row); print(": ");
+        pbin_reverse16(matrix_get_row(row));
+        print("\n");
+    }
+}
+
+uint8_t matrix_key_count(void)
+{
+    uint8_t count = 0;
+    for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
+        count += bitpop16(matrix[i]);
+    }
+    return count;
+}
+
+static void init_cols(void)
+{
+    DDRB &= ~(1<<6 | 1<<5 | 1<<4);
+    PORTB |= (1<<6 | 1<<5 | 1<<4);
+    DDRD &= ~(1<<7 | 1<<6 | 1<<4);
+    PORTD |= (1<<7 | 1<<6 | 1<<4);
+    DDRF &= ~(1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    PORTF |= (1<<0 | 1<<1 | 1<<4 | 1<<5 | 1<<6 | 1<<7);
+    
+}
+
+static matrix_row_t read_cols(void)
+{
+  return (PIND&(1<<4) ? 0 : (1<<0)) |
+         (PIND&(1<<6) ? 0 : (1<<1)) |
+         (PIND&(1<<7) ? 0 : (1<<2)) |
+         (PINB&(1<<4) ? 0 : (1<<3)) |
+         (PINB&(1<<5) ? 0 : (1<<4)) |
+         (PINB&(1<<6) ? 0 : (1<<5)) |
+         (PINF&(1<<7) ? 0 : (1<<6)) |
+         (PINF&(1<<6) ? 0 : (1<<7)) |
+         (PINF&(1<<5) ? 0 : (1<<8)) |
+         (PINF&(1<<4) ? 0 : (1<<9)) |
+         (PINF&(1<<1) ? 0 : (1<<10)) |
+         (PINF&(1<<0) ? 0 : (1<<11));
+         
+}
+
+static void unselect_rows(void)
+{
+    DDRB &= ~(1<<0 | 1<<1 | 1<<2 | 1<<3);
+    PORTB |= (1<<0 | 1<<1 | 1<<2 | 1<<3);
+    
+}
+
+static void select_row(uint8_t row)
+{
+    switch (row) {
+        case 0:
+            DDRB  |= (1<<0);
+            PORTB &= ~(1<<0);
+            break;
+        case 1:
+            DDRB  |= (1<<1);
+            PORTB &= ~(1<<1);
+            break;
+        case 2:
+            DDRB  |= (1<<2);
+            PORTB &= ~(1<<2);
+            break;
+        case 3:
+            DDRB  |= (1<<3);
+            PORTB &= ~(1<<3);
+            break;
+        
+    }
+}

From be86aefdbda560d6810f9594169fee4385c1422d Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Mon, 16 Mar 2015 11:59:49 -0400
Subject: [PATCH 94/95] Rename handwire-matrix.c to matrix-handwire.c

---
 keyboard/planck/{handwire-matrix.c => matrix-handwire.c} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename keyboard/planck/{handwire-matrix.c => matrix-handwire.c} (100%)

diff --git a/keyboard/planck/handwire-matrix.c b/keyboard/planck/matrix-handwire.c
similarity index 100%
rename from keyboard/planck/handwire-matrix.c
rename to keyboard/planck/matrix-handwire.c

From 9c3a95663410a294f2c85ad2d1c016f328730e0b Mon Sep 17 00:00:00 2001
From: Jack Humbert <jack.humb@gmail.com>
Date: Wed, 18 Mar 2015 10:19:40 -0400
Subject: [PATCH 95/95] Update README.md

---
 keyboard/planck/README.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/keyboard/planck/README.md b/keyboard/planck/README.md
index cb009c005d..206d6ad80d 100644
--- a/keyboard/planck/README.md
+++ b/keyboard/planck/README.md
@@ -9,6 +9,11 @@ DIY/Assembled compact ortholinear keyboard by [Ortholinear Keyboards](http://ort
 - [Matthew's Fork](https://github.com/pepers/tmk_keyboard/tree/master/keyboard/planck_grid)
 
 ## Build
+
+Follow [this guide](http://deskthority.net/workshop-f7/how-to-build-your-very-own-keyboard-firmware-t7177.html) to setup your development environment before anything else.
+
+Download the whole firmware [here](https://github.com/jackhumbert/tmk_keyboard/archive/master.zip) and navigate to the keyboard/planck folder. Once your dev env is setup, you'll be able to type "make" to generate your .hex that you can load with the Teensy app onto your Planck (once you've hit reset/shorted GND & RST).
+
 Move to this directory then just run `make` like:
 
     $ make