From 2dacf25f284551fa423bfdb309b4ad99e4253095 Mon Sep 17 00:00:00 2001
From: Joe Wasson <jwasson+github@gmail.com>
Date: Sun, 11 Mar 2018 17:58:23 -0700
Subject: [PATCH] Add layout support for contra.

---
 keyboards/contra/contra.h                     | 48 +++++++++++++++----
 keyboards/contra/rules.mk                     |  3 ++
 keyboards/planck/rules.mk                     |  5 +-
 .../community/ortho_4x12/bakingpy/rules.mk    |  2 +-
 4 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/keyboards/contra/contra.h b/keyboards/contra/contra.h
index e9f9c5418d..873429b53a 100755
--- a/keyboards/contra/contra.h
+++ b/keyboards/contra/contra.h
@@ -3,16 +3,44 @@
 
 #include "quantum.h"
 
-#define KEYMAP( \
-	K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, \
-	K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, \
-	K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, \
-	K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311  \
+#define LAYOUT_grid( \
+  K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, \
+  K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, \
+  K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, \
+  K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311  \
 ) { \
-	{ K000,  K001,  K002,  K003,  K004,  K005,  K006,  K007,  K008,  K009,  K010,  K011 }, \
-	{ K100,  K101,  K102,  K103,  K104,  K105,  K106,  K107,  K108,  K109,  K110,  K111 }, \
-	{ K200,  K201,  K202,  K203,  K204,  K205,  K206,  K207,  K208,  K209,  K210,  K211 }, \
-	{ K300,  K301,  K302,  K303,  K304,  K305,  K306,  K307,  K308,  K309,  K310,  K311 }  \
+  { K000,  K001,  K002,  K003,  K004,  K005,  K006,  K007,  K008,  K009,  K010,  K011 }, \
+  { K100,  K101,  K102,  K103,  K104,  K105,  K106,  K107,  K108,  K109,  K110,  K111 }, \
+  { K200,  K201,  K202,  K203,  K204,  K205,  K206,  K207,  K208,  K209,  K210,  K211 }, \
+  { K300,  K301,  K302,  K303,  K304,  K305,  K306,  K307,  K308,  K309,  K310,  K311 }  \
 }
 
-#endif
\ No newline at end of file
+#define LAYOUT_mit( \
+  K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, \
+  K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, \
+  K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, \
+  K300, K301, K302, K303, K304,    K305,    K307, K308, K309, K310, K311  \
+) { \
+  { K000,  K001,  K002,  K003,  K004,  K005,  K006,  K007,  K008,  K009,  K010,  K011 }, \
+  { K100,  K101,  K102,  K103,  K104,  K105,  K106,  K107,  K108,  K109,  K110,  K111 }, \
+  { K200,  K201,  K202,  K203,  K204,  K205,  K206,  K207,  K208,  K209,  K210,  K211 }, \
+  { K300,  K301,  K302,  K303,  K304,  K305,  K305,  K307,  K308,  K309,  K310,  K311 }  \
+}
+
+#define KC_LAYOUT_grid( \
+  K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, \
+  K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K111, \
+  K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, \
+  K300, K301, K302, K303, K304, K305, K306, K307, K308, K309, K310, K311  \
+) \
+  LAYOUT_grid( \
+    KC_##K000,  KC_##K001,  KC_##K002,  KC_##K003,  KC_##K004,  KC_##K005,  KC_##K006,  KC_##K007,  KC_##K008,  KC_##K009,  KC_##K010,  KC_##K011, \
+    KC_##K100,  KC_##K101,  KC_##K102,  KC_##K103,  KC_##K104,  KC_##K105,  KC_##K106,  KC_##K107,  KC_##K108,  KC_##K109,  KC_##K110,  KC_##K111, \
+    KC_##K200,  KC_##K201,  KC_##K202,  KC_##K203,  KC_##K204,  KC_##K205,  KC_##K206,  KC_##K207,  KC_##K208,  KC_##K209,  KC_##K210,  KC_##K211, \
+    KC_##K300,  KC_##K301,  KC_##K302,  KC_##K303,  KC_##K304,  KC_##K305,  KC_##K306,  KC_##K307,  KC_##K308,  KC_##K309,  KC_##K310,  KC_##K311 \
+    )
+#define KEYMAP LAYOUT_grid
+#define LAYOUT_ortho_4x12 LAYOUT_grid
+#define KC_LAYOUT_ortho_4x12 KC_LAYOUT_grid
+
+#endif
diff --git a/keyboards/contra/rules.mk b/keyboards/contra/rules.mk
index ca2945e63b..a926dfc03e 100755
--- a/keyboards/contra/rules.mk
+++ b/keyboards/contra/rules.mk
@@ -56,3 +56,6 @@ MIDI_ENABLE = no            # MIDI controls
 UNICODE_ENABLE = no         # Unicode
 BLUETOOTH_ENABLE = no       # Enable Bluetooth with the Adafruit EZ-Key HID
 AUDIO_ENABLE = no           # Audio output on port C6
+
+LAYOUTS = ortho_4x12 planck_mit planck_grid
+LAYOUTS_HAS_RGB = no
diff --git a/keyboards/planck/rules.mk b/keyboards/planck/rules.mk
index 4d882d0b0b..511c06d708 100644
--- a/keyboards/planck/rules.mk
+++ b/keyboards/planck/rules.mk
@@ -36,7 +36,7 @@ F_USB = $(F_CPU)
 
 # Bootloader
 #     This definition is optional, and if your keyboard supports multiple bootloaders of
-#     different sizes, comment this out, and the correct address will be loaded 
+#     different sizes, comment this out, and the correct address will be loaded
 #     automatically (+60). See bootloader.mk for all options.
 ifeq ($(strip $(KEYBOARD)), planck/rev3)
     BOOTLOADER = atmel-dfu
@@ -55,7 +55,7 @@ endif
 OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
 
 # Build Options
-#   change to "no" to disable the options, or define them in the Makefile in 
+#   change to "no" to disable the options, or define them in the Makefile in
 #   the appropriate keymap folder that will get included automatically
 #
 BOOTMAGIC_ENABLE = no       # Virtual DIP switch configuration(+1000)
@@ -76,5 +76,6 @@ API_SYSEX_ENABLE = no
 SLEEP_LED_ENABLE = no    # Breathing sleep LED during USB suspend
 
 LAYOUTS = ortho_4x12 planck_mit planck_grid
+LAYOUTS_HAS_RGB = no
 
 DEFAULT_FOLDER = planck/rev5
diff --git a/layouts/community/ortho_4x12/bakingpy/rules.mk b/layouts/community/ortho_4x12/bakingpy/rules.mk
index 45ad262393..02899eafeb 100644
--- a/layouts/community/ortho_4x12/bakingpy/rules.mk
+++ b/layouts/community/ortho_4x12/bakingpy/rules.mk
@@ -1,4 +1,4 @@
 # Enable RGB if not a Planck
-ifeq (,$(findstring planck,$(KEYBOARD)))
+ifeq ($(LAYOUTS_HAS_RGB),yes)
 	RGBLIGHT_ENABLE = yes
 endif