From 1328ab7c7defdca40872273147f387618b1a48c3 Mon Sep 17 00:00:00 2001
From: datafx <2432997+datafx@users.noreply.github.com>
Date: Wed, 20 Jan 2021 02:32:39 -0500
Subject: [PATCH] Correct LED physical mapping on monstargear xo87 rgb pcb
 (#11629)

* corrected LED physical mapping

* Corrected issue that made VIA display layer 1 incorrectly

Co-authored-by: datafx <digitalfx@phreak.tech>
---
 keyboards/monstargear/xo87/rgb/config.h |  4 +-
 keyboards/monstargear/xo87/rgb/rgb.c    | 57 +++++++++++++------------
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/keyboards/monstargear/xo87/rgb/config.h b/keyboards/monstargear/xo87/rgb/config.h
index 939ab574ee..0d92c274e4 100644
--- a/keyboards/monstargear/xo87/rgb/config.h
+++ b/keyboards/monstargear/xo87/rgb/config.h
@@ -26,7 +26,7 @@
 #define PRODUCT         XO87
 
 /* key matrix size */
-#define MATRIX_ROWS 8
+#define MATRIX_ROWS 6
 #define MATRIX_COLS 16
 
 #define BACKLIGHT_PIN F5
@@ -39,7 +39,7 @@
 #define RGB_DISABLE_WHEN_USB_SUSPENDED true
 
 #define RGB_MATRIX_MAXIMUM_BRIGHTNESS 100 // limits maximum brightness of LEDs to 100 out of 255.
-#define RGBLIGHT_LIMIT_VAL 100 // limits maximum brightness of LEDs to 100 out of 255. 
+#define RGBLIGHT_LIMIT_VAL 100 // limits maximum brightness of LEDs to 100 out of 255.
 #define RGB_MATRIX_KEYPRESSES
 #define RGB_MATRIX_FRAMEBUFFER_EFFECTS
 #define RGBLED_NUM 110
diff --git a/keyboards/monstargear/xo87/rgb/rgb.c b/keyboards/monstargear/xo87/rgb/rgb.c
index de8793d4ba..e763995d02 100644
--- a/keyboards/monstargear/xo87/rgb/rgb.c
+++ b/keyboards/monstargear/xo87/rgb/rgb.c
@@ -28,39 +28,40 @@ led_config_t g_led_config = { {
   {  31,  NO_LED,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  70,  43,  23 },
   //ctrl win  alt                             space                           alt  win  mod  left down right
   {  30,  29,  28,  NO_LED,  NO_LED,  NO_LED,  27,  NO_LED,  NO_LED,  NO_LED,  26,  25,  24,  22,  21,  20 },
-  //underglow
-  {  10,  11,  12,  13,  14,  15,  16,  17,  18,  19 },
-  {   0,   1,   2,   3,   4,   5,   6,   7,   8,   9 }
+  //underglow lights
+  //{ 10,  11,  12,  13,  14,  15,  16,  17,  18,  19 },
+  //{  0,   1,   2,   3,   4,   5,   6,   7,   8,   9 }
+
 }, {
-    //Esc, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCN, SLCK, BRK
-    {   0,   0 }, {  15,   0 }, {  30,   0 }, {  45,   0 }, {  60,   0 }, {  75,   0 }, {  90,   0 }, { 105,   0 }, { 120,   0 }, { 135,   0 }, { 150,   0 }, { 165,   0 }, { 180,   0 }, { 202,   0 }, { 225,   0 },
-    //Tilde, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -, =, backspace, ins, home, pgup
-    {   0,  12 }, {  22,  12}, {  37,  12 }, {  52,  12 }, {  67,  12 }, {  82,  12 }, {  97,  12 }, { 112,  12 }, { 127,  12 }, { 142,  12 }, { 157,  12 }, { 172,  12 }, { 187,  12 }, { 202,  12}, { 206,  12 }, {215,  12}, { 225,  12 },
-    //Tab, q, w, e, r, t, y, u, i, o, p, [, ], \, del, end, pgdown
-    {   0,  24 }, {  22,  24}, {  37,  24 }, {  52,  24 }, {  67,  24 }, {  82,  24 }, {  97,  24 }, { 112,  24 }, { 127,  24 }, { 142,  24 }, { 157,  24 }, { 172,  24 }, { 187,  24 }, { 202,  24}, { 206,  24 }, {215,  24}, { 225,  24 },
-    //Capslock, A, S, D, F, G, H, J, K, L, ;, ', Enter
-    {  0,  36 }, {  26,  36 }, {  41,  36 }, {  56,  36 }, {  71,  36 }, {  86,  36 }, { 101,  36 }, { 116,  36 }, { 131,  36 }, { 146,  36 }, { 161,  36 }, { 176,  36 }, { 180,  36 }, { 198,  36 },
-    //LShift, Z, X, C, V, B, N, M, ,, ., slash, RShift, Up
+    // Underglow lights
+    { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 }, { 254,  63 },
+    // right         down         left            rctl         mod           rwin          ralt          space         lalt           lwin         lctl
+    { 225,  63 }, { 215,  63 }, { 206,  63 }, { 180,  63 }, { 168,  63}, { 153,  63 }, { 135,  63 }, { 101,  63 }, {  33,  63 }, {  22,  63 }, {  0,  63 },
+    // lshift          z             x            c              v            b            n              m              comma       period       question       rshift         up
     {  0,  48 }, {  30,  48 }, {  45,  48 }, {  60,  48 }, {  75,  48 }, {  90,  48 }, { 105,  48 }, { 120,  48 }, { 135,  48 }, { 150,  48 }, { 165,  48 }, { 198,  48 }, { 215,  48},
-    //Ctrl, GUI, Alt, Space, RAlt, GUI, FN, CTL, Left, Down, Right
-    {  0,  63 }, {  22,  63 }, {  33,  63 }, { 101,  63 }, { 135,  63 }, { 153,  63 }, { 168,  63}, { 180,  63 }, { 195,  63 }, { 210,  63 }, { 225,  63 },
-    //Underglow
-    {  0,  64 }, {  10,  64 }, {  20,  64 }, { 30,  64 }, { 40,  64 }, { 50,  64 }, { 60,  64}, { 70,  64 }, { 80,  64 }, { 90,  64 }, { 100,  64 }, {  110,  64 }, {  120,  64 }, {  130,  64 }, { 140,  64 }, { 150,  64 }, { 160,  64 }, { 170,  64}, { 180,  64 }, { 190,  64 }
+    // return         '              ;             l              k             j             h             g              f            d            s               a        capslock
+    { 198,  36 }, { 180,  36 }, { 176,  36 }, { 161,  36 }, { 146,  36 }, { 131,  36 }, { 116,  36 }, { 101,  36 }, {  86,  36 }, {  71,  36 }, {  56,  36 }, {  41,  36 }, {  0,  36 },
+    //   tab           q             w             e             r            t             y             u              i             o             p              [             ]         backslash      del          end         pgdn
+    {   0,  24 }, {  22,  24}, {  37,  24 }, {  52,  24 }, {  67,  24 }, {  82,  24 }, {  97,  24 }, { 112,  24 }, { 127,  24 }, { 142,  24 }, { 157,  24 }, { 172,  24 }, { 187,  24 }, { 202,  24}, { 206,  24 }, {215,  24}, { 225,  24 },
+    // pgup          home          ins        backspace        =            -             0              9             8             7            6               5              4             3             2            1         tilde
+    { 225,  12 }, {215,  12}, { 206,  12 }, { 202,  12}, { 187,  12 }, { 172,  12 }, { 157,  12 }, { 142,  12 }, { 127,  12 }, { 112,  12 }, {  97,  12 }, {  82,  12 }, {  67,  12 }, {  52,  12 }, {  37,  12 }, {  22,  12}, {   0,  12 },
+    //   esc          ind1         ind2         ind3           F1           F2           F3            F4            F5             F6             F7               F8            F9            F10          F11           F12        prtscr      scrlck         pause
+    {   0,   0 }, {  0,  0 }, {  0,   0 }, {   0,   0 }, {  25,   0 }, {  40,   0 }, {  55,   0 }, {  82,   0 }, {  108,   0 }, {  120,   0 }, {  130,   0 }, { 148,   0 }, { 172,   0 }, { 187,   0 }, { 190,   0 }, { 195,   0 }, { 206,   0 }, { 215,  0}, { 225,   0 }
 }, {
-    // top row 
-    4, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    // 5th row up
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    // 4th row up 
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    // 3rd row up
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    // 2nd row up
-    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+    // underglow
+    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
     // bottom row
     4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-    // underglow
-    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
+    // 2nd row up
+    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+    // 3rd row up
+    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+    // 4th row up
+    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+    // 5th row up
+    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+    // top row
+    4, 8, 8, 8, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4
 } };
 
 void suspend_power_down_kb(void) {