From f33881b1da15955b43c463611f7a24390d4acd5d Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <oni.strech@gmail.com>
Date: Tue, 3 Oct 2023 16:27:00 +0900
Subject: [PATCH] Add Soulstone keyboard (#22093)

---
 keyboards/strech/soulstone/config.h           | 24 ++++++
 keyboards/strech/soulstone/info.json          | 84 +++++++++++++++++++
 .../strech/soulstone/keymaps/default/keymap.c | 44 ++++++++++
 .../strech/soulstone/keymaps/via/keymap.c     | 44 ++++++++++
 .../strech/soulstone/keymaps/via/rules.mk     |  1 +
 keyboards/strech/soulstone/readme.md          | 30 +++++++
 keyboards/strech/soulstone/rules.mk           |  1 +
 keyboards/strech/soulstone/soulstone.c        | 30 +++++++
 8 files changed, 258 insertions(+)
 create mode 100644 keyboards/strech/soulstone/config.h
 create mode 100644 keyboards/strech/soulstone/info.json
 create mode 100644 keyboards/strech/soulstone/keymaps/default/keymap.c
 create mode 100644 keyboards/strech/soulstone/keymaps/via/keymap.c
 create mode 100644 keyboards/strech/soulstone/keymaps/via/rules.mk
 create mode 100644 keyboards/strech/soulstone/readme.md
 create mode 100644 keyboards/strech/soulstone/rules.mk
 create mode 100644 keyboards/strech/soulstone/soulstone.c

diff --git a/keyboards/strech/soulstone/config.h b/keyboards/strech/soulstone/config.h
new file mode 100644
index 000000000000..425546d77eb9
--- /dev/null
+++ b/keyboards/strech/soulstone/config.h
@@ -0,0 +1,24 @@
+/* Copyright 2023 Strech
+ *
+ * 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/>.
+ */
+
+#pragma once
+
+/* 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
+
+#define LAYER_INDICATOR_LED_PIN B3
diff --git a/keyboards/strech/soulstone/info.json b/keyboards/strech/soulstone/info.json
new file mode 100644
index 000000000000..53037d1460fb
--- /dev/null
+++ b/keyboards/strech/soulstone/info.json
@@ -0,0 +1,84 @@
+{
+    "keyboard_name": "Soulstone",
+    "maintainer": "Strech",
+    "manufacturer": "Strech",
+    "usb": {
+        "vid": "0xB030",
+        "pid": "0x0001",
+        "device_version": "1.0.0"
+    },
+    "processor": "atmega32u4",
+    "bootloader": "atmel-dfu",
+    "features": {
+        "bootmagic": true,
+        "mousekey": true,
+        "extrakey": true,
+        "console": false,
+        "command": false,
+        "nkro": true
+    },
+    "diode_direction": "COL2ROW",
+    "matrix_pins": {
+        "cols": ["B7", "F1", "B0", "F4", "E6", "F0", "D5", "D3", "D2", "D1", "B4", "D7", "D6"],
+        "rows": ["D0", "D4", "B5", "F5"]
+    },
+    "indicators": {
+        "caps_lock": "B1",
+        "num_lock": "B2"
+    },
+    "dynamic_keymap": {
+        "layer_count": 6
+    },
+    "layouts": {
+        "LAYOUT": {
+            "layout": [
+                {"matrix": [0, 0], "x": 0, "y": 0, "label": "Esc"},
+                {"matrix": [0, 1], "x": 1, "y": 0, "label": "Q"},
+                {"matrix": [0, 2], "x": 2, "y": 0, "label": "W"},
+                {"matrix": [0, 3], "x": 3, "y": 0, "label": "E"},
+                {"matrix": [0, 4], "x": 4, "y": 0, "label": "R"},
+                {"matrix": [0, 5], "x": 5, "y": 0, "label": "T"},
+                {"matrix": [0, 6], "x": 7, "y": 0, "label": "Y"},
+                {"matrix": [0, 7], "x": 8, "y": 0, "label": "U"},
+                {"matrix": [0, 8], "x": 9, "y": 0, "label": "I"},
+                {"matrix": [0, 9], "x": 10, "y": 0, "label": "O"},
+                {"matrix": [0, 10], "x": 11, "y": 0, "label": "P"},
+                {"matrix": [0, 11], "x": 12, "y": 0, "label": "Del"},
+                {"matrix": [0, 12], "x": 13, "y": 0, "label": "Bspc"},
+                {"matrix": [1, 0], "x": 0, "y": 1, "w": 1.25, "label": "Tab"},
+                {"matrix": [1, 1], "x": 1.25, "y": 1, "label": "A"},
+                {"matrix": [1, 2], "x": 2.25, "y": 1, "label": "S"},
+                {"matrix": [1, 3], "x": 3.25, "y": 1, "label": "D"},
+                {"matrix": [1, 4], "x": 4.25, "y": 1, "label": "F"},
+                {"matrix": [1, 5], "x": 5.25, "y": 1, "label": "G"},
+                {"matrix": [1, 6], "x": 7.25, "y": 1, "label": "H"},
+                {"matrix": [1, 7], "x": 8.25, "y": 1, "label": "J"},
+                {"matrix": [1, 8], "x": 9.25, "y": 1, "label": "K"},
+                {"matrix": [1, 9], "x": 10.25, "y": 1, "label": "L"},
+                {"matrix": [1, 10], "x": 11.25, "y": 1, "label": ";"},
+                {"matrix": [1, 12], "x": 12.25, "y": 1, "w": 1.5, "label": "Enter"},
+                {"matrix": [2, 0], "x": 0, "y": 2, "w": 1.75, "label": "L Shift"},
+                {"matrix": [2, 1], "x": 1.75, "y": 2, "label": "Z"},
+                {"matrix": [2, 2], "x": 2.75, "y": 2, "label": "X"},
+                {"matrix": [2, 3], "x": 3.75, "y": 2, "label": "C"},
+                {"matrix": [2, 4], "x": 4.75, "y": 2, "label": "V"},
+                {"matrix": [2, 5], "x": 5.75, "y": 2, "label": "B"},
+                {"matrix": [2, 6], "x": 6.75, "y": 2, "label": "MO(3)"},
+                {"matrix": [2, 7], "x": 7.75, "y": 2, "label": "N"},
+                {"matrix": [2, 8], "x": 8.75, "y": 2, "label": "M"},
+                {"matrix": [2, 9], "x": 9.75, "y": 2, "label": ","},
+                {"matrix": [2, 10], "x": 10.75, "y": 2, "label": "."},
+                {"matrix": [2, 11], "x": 11.75, "y": 2, "label": "/"},
+                {"matrix": [2, 12], "x": 12.75, "y": 2, "w": 1.25, "label": "R Shift"},
+                {"matrix": [3, 0], "x": 0, "y": 3, "w": 1.25, "label": "L Ctrl"},
+                {"matrix": [3, 1], "x": 1.25, "y": 3, "w": 1.25, "label": "L Alt"},
+                {"matrix": [3, 3], "x": 3.50, "y": 3, "w": 1.25, "label": "MO(2)"},
+                {"matrix": [3, 4], "x": 4.75, "y": 3, "w": 2, "label": "MO(1)"},
+                {"matrix": [3, 6], "x": 6.75, "y": 3, "w": 2.25, "label": "Space"},
+                {"matrix": [3, 8], "x": 9, "y": 3, "w": 1.25, "label": "R Alt"},
+                {"matrix": [3, 11], "x": 11.50, "y": 3, "w": 1.25, "label": "R GUI"},
+                {"matrix": [3, 12], "x": 12.75, "y": 3, "w": 1.25, "label": "R Ctrl"}
+            ]
+        }
+    }
+}
diff --git a/keyboards/strech/soulstone/keymaps/default/keymap.c b/keyboards/strech/soulstone/keymaps/default/keymap.c
new file mode 100644
index 000000000000..7dc655b61932
--- /dev/null
+++ b/keyboards/strech/soulstone/keymaps/default/keymap.c
@@ -0,0 +1,44 @@
+/* Copyright 2023 Strech
+ *
+ * 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 QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = LAYOUT(
+        KC_ESC,   KC_Q,     KC_W,     KC_E,     KC_R,     KC_T,             KC_Y,     KC_U,     KC_I,     KC_O,     KC_P,     KC_DEL,   KC_BSPC,
+        KC_TAB,   KC_A,     KC_S,     KC_D,     KC_F,     KC_G,             KC_H,     KC_J,     KC_K,     KC_L,     KC_QUOT,  KC_ENT,
+        KC_LSFT,  KC_Z,     KC_X,     KC_C,     KC_V,     KC_B,             MO(3),    KC_N,     KC_M,     KC_COMM,  KC_DOT,   KC_SLSH,  KC_RSFT,
+        KC_LCTL,  KC_LALT,                      MO(2),    MO(1),            KC_SPC,   KC_RALT,                                KC_RGUI,  KC_RCTL
+    ),
+    [1] = LAYOUT(
+        KC_GRV,   KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_UP,    KC_TRNS,  KC_MUTE,  KC_VOLD,  KC_VOLU,
+        KC_CAPS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_LEFT,  KC_DOWN,  KC_RGHT,  KC_SCLN,  KC_BSLS,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,                      KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,                                KC_TRNS,  KC_TRNS
+    ),
+    [2] = LAYOUT(
+        KC_TRNS,  KC_1,     KC_2,     KC_3,     KC_4,     KC_5,             KC_6,     KC_7,     KC_8,     KC_9,     KC_0,     KC_MINS,  KC_EQL,
+        KC_LNUM,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_P4,    KC_P5,    KC_P6,    KC_LBRC,  KC_RBRC,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_P1,    KC_P2,    KC_P3,    KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,                      KC_TRNS,  KC_TRNS,          KC_PENT,  KC_PDOT,                                KC_TRNS,  KC_TRNS
+    ),
+    [3] = LAYOUT(
+        KC_TRNS,  KC_F1,    KC_F2,    KC_F3,    KC_F4,    KC_F5,            KC_F6,    KC_F7,    KC_F8,    KC_F9,    KC_F10,   KC_F11,   KC_F12,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,                      KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,                                KC_TRNS,  KC_TRNS
+    )
+};
diff --git a/keyboards/strech/soulstone/keymaps/via/keymap.c b/keyboards/strech/soulstone/keymaps/via/keymap.c
new file mode 100644
index 000000000000..7dc655b61932
--- /dev/null
+++ b/keyboards/strech/soulstone/keymaps/via/keymap.c
@@ -0,0 +1,44 @@
+/* Copyright 2023 Strech
+ *
+ * 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 QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    [0] = LAYOUT(
+        KC_ESC,   KC_Q,     KC_W,     KC_E,     KC_R,     KC_T,             KC_Y,     KC_U,     KC_I,     KC_O,     KC_P,     KC_DEL,   KC_BSPC,
+        KC_TAB,   KC_A,     KC_S,     KC_D,     KC_F,     KC_G,             KC_H,     KC_J,     KC_K,     KC_L,     KC_QUOT,  KC_ENT,
+        KC_LSFT,  KC_Z,     KC_X,     KC_C,     KC_V,     KC_B,             MO(3),    KC_N,     KC_M,     KC_COMM,  KC_DOT,   KC_SLSH,  KC_RSFT,
+        KC_LCTL,  KC_LALT,                      MO(2),    MO(1),            KC_SPC,   KC_RALT,                                KC_RGUI,  KC_RCTL
+    ),
+    [1] = LAYOUT(
+        KC_GRV,   KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_UP,    KC_TRNS,  KC_MUTE,  KC_VOLD,  KC_VOLU,
+        KC_CAPS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_LEFT,  KC_DOWN,  KC_RGHT,  KC_SCLN,  KC_BSLS,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,                      KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,                                KC_TRNS,  KC_TRNS
+    ),
+    [2] = LAYOUT(
+        KC_TRNS,  KC_1,     KC_2,     KC_3,     KC_4,     KC_5,             KC_6,     KC_7,     KC_8,     KC_9,     KC_0,     KC_MINS,  KC_EQL,
+        KC_LNUM,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_P4,    KC_P5,    KC_P6,    KC_LBRC,  KC_RBRC,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_P1,    KC_P2,    KC_P3,    KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,                      KC_TRNS,  KC_TRNS,          KC_PENT,  KC_PDOT,                                KC_TRNS,  KC_TRNS
+    ),
+    [3] = LAYOUT(
+        KC_TRNS,  KC_F1,    KC_F2,    KC_F3,    KC_F4,    KC_F5,            KC_F6,    KC_F7,    KC_F8,    KC_F9,    KC_F10,   KC_F11,   KC_F12,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,  KC_TRNS,
+        KC_TRNS,  KC_TRNS,                      KC_TRNS,  KC_TRNS,          KC_TRNS,  KC_TRNS,                                KC_TRNS,  KC_TRNS
+    )
+};
diff --git a/keyboards/strech/soulstone/keymaps/via/rules.mk b/keyboards/strech/soulstone/keymaps/via/rules.mk
new file mode 100644
index 000000000000..1e5b99807cb7
--- /dev/null
+++ b/keyboards/strech/soulstone/keymaps/via/rules.mk
@@ -0,0 +1 @@
+VIA_ENABLE = yes
diff --git a/keyboards/strech/soulstone/readme.md b/keyboards/strech/soulstone/readme.md
new file mode 100644
index 000000000000..07c792f0eb57
--- /dev/null
+++ b/keyboards/strech/soulstone/readme.md
@@ -0,0 +1,30 @@
+# Soulstone
+
+![Soulstone](https://i.imgur.com/aQBsgZ9h.jpg)
+
+A hotswap PCB inspired by an elegant [prime_e](https://www.primekb.com/products/prime_e-rev-2-pcb),
+45% ergo keyboard. It is compatible with `rev2` (RGB and non-RGB) which makes it
+fit to any `rev2` compatible case.
+
+* Keyboard Maintainer: [Strech](https://github.com/Strech)
+* Hardware Supported: Soulstone
+* Hardware Availability: Coming soon
+
+Make example for this keyboard (after setting up your build environment):
+
+    make strech/soulstone:default
+
+Flashing example for this keyboard:
+
+    make strech/soulstone:default:flash
+
+See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and
+the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information.
+Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
+
+## Bootloader
+
+Enter the bootloader using one of the following methods:
+
+* Tap the Reset switch mounted on the PCB
+* Hold down the key at (0,0) in the matrix (usually the top left key or `Escape`) and plug in the keyboard
diff --git a/keyboards/strech/soulstone/rules.mk b/keyboards/strech/soulstone/rules.mk
new file mode 100644
index 000000000000..6e7633bfe015
--- /dev/null
+++ b/keyboards/strech/soulstone/rules.mk
@@ -0,0 +1 @@
+# This file intentionally left blank
diff --git a/keyboards/strech/soulstone/soulstone.c b/keyboards/strech/soulstone/soulstone.c
new file mode 100644
index 000000000000..4a951aff9d26
--- /dev/null
+++ b/keyboards/strech/soulstone/soulstone.c
@@ -0,0 +1,30 @@
+/* Copyright 2023 Strech
+ *
+ * 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 "quantum.h"
+
+// Prepare layer indicator LED
+void keyboard_post_init_kb(void) {
+    setPinOutput(LAYER_INDICATOR_LED_PIN);
+    writePinLow(LAYER_INDICATOR_LED_PIN);
+    keyboard_post_init_user();
+}
+
+// Function for layer indicator LED
+layer_state_t layer_state_set_kb(layer_state_t state) {
+    writePin(LAYER_INDICATOR_LED_PIN, !layer_state_cmp(state, 0));
+    return layer_state_set_user(state);
+}