From be72a64cf603946102cc2144822b75fa9f92a2ec Mon Sep 17 00:00:00 2001
From: Michele Ferri <ferrimiche@gmail.com>
Date: Mon, 9 Aug 2021 19:04:00 +0200
Subject: [Keyboard] Add TouhouPad (#13915)

* Touhoupad rev 2

* cleanup for PR

* fixes after review
---
 keyboards/pimentoso/touhoupad/config.h             | 52 ++++++++++++++++++++++
 keyboards/pimentoso/touhoupad/info.json            | 12 +++++
 .../pimentoso/touhoupad/keymaps/default/keymap.c   | 25 +++++++++++
 .../pimentoso/touhoupad/keymaps/default/readme.md  |  1 +
 keyboards/pimentoso/touhoupad/readme.md            | 19 ++++++++
 keyboards/pimentoso/touhoupad/rules.mk             | 22 +++++++++
 keyboards/pimentoso/touhoupad/touhoupad.c          | 16 +++++++
 keyboards/pimentoso/touhoupad/touhoupad.h          | 23 ++++++++++
 8 files changed, 170 insertions(+)
 create mode 100644 keyboards/pimentoso/touhoupad/config.h
 create mode 100644 keyboards/pimentoso/touhoupad/info.json
 create mode 100644 keyboards/pimentoso/touhoupad/keymaps/default/keymap.c
 create mode 100644 keyboards/pimentoso/touhoupad/keymaps/default/readme.md
 create mode 100644 keyboards/pimentoso/touhoupad/readme.md
 create mode 100644 keyboards/pimentoso/touhoupad/rules.mk
 create mode 100644 keyboards/pimentoso/touhoupad/touhoupad.c
 create mode 100644 keyboards/pimentoso/touhoupad/touhoupad.h

diff --git a/keyboards/pimentoso/touhoupad/config.h b/keyboards/pimentoso/touhoupad/config.h
new file mode 100644
index 0000000000..8fd4e78116
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/config.h
@@ -0,0 +1,52 @@
+/* Copyright 2021 Michele Ferri <zomgsako@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/>.
+ */
+#pragma once
+
+#include "config_common.h"
+
+/* USB Device descriptor parameter */
+#define VENDOR_ID       0xD00D
+#define PRODUCT_ID      0x0031
+#define DEVICE_VER      0x0001
+#define MANUFACTURER    Pimentoso
+#define PRODUCT         TouhouPad rev2
+
+#define MATRIX_ROWS 1
+#define MATRIX_COLS 10
+
+#define MATRIX_ROW_PINS { D4 }
+#define MATRIX_COL_PINS { C6,D7,E6,B4,B6,B2,B3,B1,F7,F6 }
+
+#define DIODE_DIRECTION COL2ROW
+
+#define RGB_DI_PIN F4
+#ifdef RGB_DI_PIN
+  #define RGBLED_NUM 12
+  #define RGBLIGHT_HUE_STEP 8
+  #define RGBLIGHT_SAT_STEP 8
+  #define RGBLIGHT_VAL_STEP 8
+  #define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
+  #define RGBLIGHT_SLEEP  /* If defined, the RGB lighting will be switched off when the host goes to sleep */
+  #define RGBLIGHT_EFFECT_BREATHING
+  #define RGBLIGHT_EFFECT_RAINBOW_MOOD
+  #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
+  #define RGBLIGHT_EFFECT_STATIC_GRADIENT
+  #define RGBLIGHT_BREATHE_TABLE_SIZE 256      // 256(default) or 128 or 64
+  #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85  // 1 to 2.7
+  #define RGBLIGHT_EFFECT_BREATHE_MAX    255   // 0 to 255
+#endif
+
+#define DEBOUNCE 5
diff --git a/keyboards/pimentoso/touhoupad/info.json b/keyboards/pimentoso/touhoupad/info.json
new file mode 100644
index 0000000000..71698cee9e
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/info.json
@@ -0,0 +1,12 @@
+{
+    "keyboard_name": "TouhouPad",
+    "url": "https://github.com/Pimentoso/TouhouPad_v2",
+    "maintainer": "Pimentoso",
+    "width": 8.25,
+    "height": 4,
+    "layouts": {
+        "LAYOUT": {
+            "layout": [{"label":"esc", "x":5.25, "y":0}, {"label":"enter", "x":6.25, "y":0}, {"label":"slow", "x":0, "y":1}, {"label":"fire", "x":1, "y":1}, {"label":"rapid", "x":2, "y":1}, {"label":"up", "x":6.25, "y":1.75}, {"label":"left", "x":5.25, "y":2.75}, {"label":"down", "x":6.25, "y":2.75}, {"label":"right", "x":7.25, "y":2.75}, {"label":"bomb", "x":3.25, "y":3}]
+        }
+    }
+}
diff --git a/keyboards/pimentoso/touhoupad/keymaps/default/keymap.c b/keyboards/pimentoso/touhoupad/keymaps/default/keymap.c
new file mode 100644
index 0000000000..0d10055110
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/keymaps/default/keymap.c
@@ -0,0 +1,25 @@
+/* Copyright 2021 Michele Ferri <zomgsako@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 QMK_KEYBOARD_H
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+    LAYOUT( /* Base */
+        KC_LSFT, KC_Z,  KC_C,  KC_X,    KC_LEFT, KC_DOWN, KC_RIGHT, KC_UP,     KC_ENT, LT(1, KC_ESC)
+    ),
+    LAYOUT( /* RGB controls */
+        KC_NO,   KC_NO, KC_NO, KC_NO,   RGB_TOG, RGB_VAD, RGB_MOD,  RGB_VAI,   KC_NO, KC_NO
+    )
+};
diff --git a/keyboards/pimentoso/touhoupad/keymaps/default/readme.md b/keyboards/pimentoso/touhoupad/keymaps/default/readme.md
new file mode 100644
index 0000000000..00bf43cb99
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/keymaps/default/readme.md
@@ -0,0 +1 @@
+# The default keymap for 4pack
diff --git a/keyboards/pimentoso/touhoupad/readme.md b/keyboards/pimentoso/touhoupad/readme.md
new file mode 100644
index 0000000000..7e122c327b
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/readme.md
@@ -0,0 +1,19 @@
+# TouhouPad
+
+![TouhouPad](https://i.imgur.com/JeEqeEs.png)
+
+A 10 key gamepad specifically for playing Touhou danmaku games.
+
+You can find building instructions and gerber files to print the circuit board on the [project page.](https://github.com/Pimentoso/TouhouPad_v2)
+
+* Keyboard Maintainer: [Michele Ferri](https://github.com/Pimentoso)
+* Hardware Supported: Paddino02 PCB rev1, rev2 + Arduino Pro Micro
+* Hardware Availability: the PCB is open source and can be freely printed at websites such as [JLCPCB](https://jlcpcb.com/)
+
+Make example for this keyboard (after setting up your build environment):
+
+    make pimentoso/touhoupad:default
+
+The gamepad case is completely exposed on the underside, so to enter bootloader mode, just short the RST and GND pins of the pro micro using a metal object.
+
+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).
diff --git a/keyboards/pimentoso/touhoupad/rules.mk b/keyboards/pimentoso/touhoupad/rules.mk
new file mode 100644
index 0000000000..806a19af38
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/rules.mk
@@ -0,0 +1,22 @@
+# MCU name
+MCU = atmega32u4
+
+# Bootloader selection
+BOOTLOADER = caterina
+
+# Build Options
+#   change yes to no to disable
+#
+BOOTMAGIC_ENABLE = no       # Virtual DIP switch configuration
+MOUSEKEY_ENABLE = yes       # Mouse keys
+EXTRAKEY_ENABLE = yes       # Audio control and System control
+CONSOLE_ENABLE = no         # Console for debug
+COMMAND_ENABLE = no         # Commands for debug and configuration
+# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
+SLEEP_LED_ENABLE = no       # Breathing sleep LED during USB suspend
+# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
+NKRO_ENABLE = no            # USB Nkey Rollover
+BACKLIGHT_ENABLE = no       # Enable keyboard backlight functionality
+RGBLIGHT_ENABLE = yes       # Enable keyboard RGB underglow
+BLUETOOTH_ENABLE = no       # Enable Bluetooth
+AUDIO_ENABLE = no           # Audio output
diff --git a/keyboards/pimentoso/touhoupad/touhoupad.c b/keyboards/pimentoso/touhoupad/touhoupad.c
new file mode 100644
index 0000000000..a7c7fa073f
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/touhoupad.c
@@ -0,0 +1,16 @@
+/* Copyright 2021 Michele Ferri <zomgsako@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 "touhoupad.h"
diff --git a/keyboards/pimentoso/touhoupad/touhoupad.h b/keyboards/pimentoso/touhoupad/touhoupad.h
new file mode 100644
index 0000000000..5a5f233e36
--- /dev/null
+++ b/keyboards/pimentoso/touhoupad/touhoupad.h
@@ -0,0 +1,23 @@
+/* Copyright 2021 Michele Ferri <zomgsako@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/>.
+ */
+#pragma once
+
+#include "quantum.h"
+
+#define LAYOUT(k00, k01, k02, k03, k04, k05, k06, k07, k08, k09) \
+{ \
+    { k00, k01, k02, k03, k04, k05, k06, k07, k08, k09 } \
+}
-- 
cgit v1.2.3