From c10d0fc785a8c8972bc129c6db03e26360eddd45 Mon Sep 17 00:00:00 2001 From: Jason Wihardja Date: Mon, 18 Jul 2022 19:20:19 +0700 Subject: [PATCH] Add Support for Massdrop's Stack Overflow The Key V2 (#17696) * Default Factory Settings * Change Keyboard Name in Readme * Fix LED Orders * Change Brightness Step * Enable Lighting Layers * Add RGB Control Mode * Unblink Layer to Clear Stack * Add MacOS RGB Control * Comment Fixes --- keyboards/massdrop/thekey_v2/config.h | 50 ++++++++ keyboards/massdrop/thekey_v2/info.json | 14 +++ .../thekey_v2/keymaps/default-macos/keymap.c | 23 ++++ .../thekey_v2/keymaps/default/keymap.c | 23 ++++ .../keymaps/rgb-control-macos/keymap.c | 109 ++++++++++++++++++ .../thekey_v2/keymaps/rgb-control/keymap.c | 109 ++++++++++++++++++ .../keymaps/url-copy-paste-macos/keymap.c | 39 +++++++ .../thekey_v2/keymaps/url-copy-paste/keymap.c | 40 +++++++ keyboards/massdrop/thekey_v2/readme.md | 38 ++++++ keyboards/massdrop/thekey_v2/rules.mk | 18 +++ keyboards/massdrop/thekey_v2/thekey_v2.c | 17 +++ keyboards/massdrop/thekey_v2/thekey_v2.h | 27 +++++ 12 files changed, 507 insertions(+) create mode 100644 keyboards/massdrop/thekey_v2/config.h create mode 100644 keyboards/massdrop/thekey_v2/info.json create mode 100644 keyboards/massdrop/thekey_v2/keymaps/default-macos/keymap.c create mode 100644 keyboards/massdrop/thekey_v2/keymaps/default/keymap.c create mode 100644 keyboards/massdrop/thekey_v2/keymaps/rgb-control-macos/keymap.c create mode 100644 keyboards/massdrop/thekey_v2/keymaps/rgb-control/keymap.c create mode 100644 keyboards/massdrop/thekey_v2/keymaps/url-copy-paste-macos/keymap.c create mode 100644 keyboards/massdrop/thekey_v2/keymaps/url-copy-paste/keymap.c create mode 100644 keyboards/massdrop/thekey_v2/readme.md create mode 100644 keyboards/massdrop/thekey_v2/rules.mk create mode 100644 keyboards/massdrop/thekey_v2/thekey_v2.c create mode 100644 keyboards/massdrop/thekey_v2/thekey_v2.h diff --git a/keyboards/massdrop/thekey_v2/config.h b/keyboards/massdrop/thekey_v2/config.h new file mode 100644 index 00000000000..9b6235998bd --- /dev/null +++ b/keyboards/massdrop/thekey_v2/config.h @@ -0,0 +1,50 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x0000 +#define DEVICE_VER 0x0002 +#define MANUFACTURER Drop +#define PRODUCT The Key V2 + +/* key matrix size */ +#define MATRIX_ROWS 1 +#define MATRIX_COLS 3 + +/* + * Keyboard Matrix Assignments + */ +#define MATRIX_ROW_PINS { D4 } +#define MATRIX_COL_PINS { D2, D1, D0 } + +#define DIODE_DIRECTION ROW2COL + +#define RGB_DI_PIN B1 +#define RGBLED_NUM 5 +#define RGBLIGHT_LED_MAP {4, 0, 1, 2, 3} +#define RGBLIGHT_ANIMATIONS +#define RGBLIGHT_HUE_STEP 10 +#define RGBLIGHT_SAT_STEP 10 +#define RGBLIGHT_VAL_STEP 15 +#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_LAYERS /* Enable lighting layers */ +#define RGBLIGHT_LAYER_BLINK /* Enable lighting layer blink */ diff --git a/keyboards/massdrop/thekey_v2/info.json b/keyboards/massdrop/thekey_v2/info.json new file mode 100644 index 00000000000..7167d5cf6d3 --- /dev/null +++ b/keyboards/massdrop/thekey_v2/info.json @@ -0,0 +1,14 @@ +{ + "keyboard_name": "The Key V2", + "url": "https://drop.com/buy/stack-overflow-the-key-v2-macropad", + "maintainer": "massdrop", + "layouts": { + "LAYOUT": { + "layout": [ + { "label": "K00 (D4,D2)", "x": 0, "y": 0 }, + { "label": "K01 (D4,D1)", "x": 1, "y": 0 }, + { "label": "K02 (D4,D0)", "x": 2, "y": 0 } + ] + } + } +} diff --git a/keyboards/massdrop/thekey_v2/keymaps/default-macos/keymap.c b/keyboards/massdrop/thekey_v2/keymaps/default-macos/keymap.c new file mode 100644 index 00000000000..fb45d5e2243 --- /dev/null +++ b/keyboards/massdrop/thekey_v2/keymaps/default-macos/keymap.c @@ -0,0 +1,23 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [0] = LAYOUT(KC_LGUI, KC_C, KC_V), + +}; diff --git a/keyboards/massdrop/thekey_v2/keymaps/default/keymap.c b/keyboards/massdrop/thekey_v2/keymaps/default/keymap.c new file mode 100644 index 00000000000..5e1de6068be --- /dev/null +++ b/keyboards/massdrop/thekey_v2/keymaps/default/keymap.c @@ -0,0 +1,23 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#include QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [0] = LAYOUT(KC_LCTL, KC_C, KC_V), + +}; diff --git a/keyboards/massdrop/thekey_v2/keymaps/rgb-control-macos/keymap.c b/keyboards/massdrop/thekey_v2/keymaps/rgb-control-macos/keymap.c new file mode 100644 index 00000000000..f3699e752fe --- /dev/null +++ b/keyboards/massdrop/thekey_v2/keymaps/rgb-control-macos/keymap.c @@ -0,0 +1,109 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#include QMK_KEYBOARD_H + +enum custom_keycodes { + LAYER_SWITCH = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* Default */ + [0] = LAYOUT(LAYER_SWITCH, G(KC_C), G(KC_V)), + + /* RGB Toggle + Mode Change */ + [1] = LAYOUT(LAYER_SWITCH, RGB_TOG, RGB_MOD), + + /* RGB Brightness */ + [2] = LAYOUT(LAYER_SWITCH, RGB_VAD, RGB_VAI), + + /* RGB Hue */ + [3] = LAYOUT(LAYER_SWITCH, RGB_HUD, RGB_HUI), + + /* RGB Saturation */ + [4] = LAYOUT(LAYER_SWITCH, RGB_SAD, RGB_SAI), + +}; + +/* Lighting layers */ + +const rgblight_segment_t PROGMEM layer_indicator_0[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 1, HSV_WHITE}, + {1, 4, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_1[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 1, HSV_OFF}, + {1, 1, HSV_WHITE}, + {2, 3, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_2[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 2, HSV_OFF}, + {2, 1, HSV_WHITE}, + {3, 2, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_3[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 3, HSV_OFF}, + {3, 1, HSV_WHITE}, + {4, 1, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_4[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 4, HSV_OFF}, + {4, 1, HSV_WHITE} +); + +const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST( + layer_indicator_0, + layer_indicator_1, + layer_indicator_2, + layer_indicator_3, + layer_indicator_4 +); + +void keyboard_post_init_user(void) { + /* Enable the LED layers */ + rgblight_layers = rgb_layers; +} + +/* Layer handler */ + +uint16_t layer = 0; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case LAYER_SWITCH: + if (record->event.pressed) { + if (layer > 0) { + layer_off(layer); + } + + rgblight_unblink_layer(layer); + layer = (layer + 1) % 5; + rgblight_blink_layer_repeat(layer, 1000, 1); + + if (layer > 0) { + layer_on(layer); + } + } + return false; + default: + return true; + } +} diff --git a/keyboards/massdrop/thekey_v2/keymaps/rgb-control/keymap.c b/keyboards/massdrop/thekey_v2/keymaps/rgb-control/keymap.c new file mode 100644 index 00000000000..42469736543 --- /dev/null +++ b/keyboards/massdrop/thekey_v2/keymaps/rgb-control/keymap.c @@ -0,0 +1,109 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#include QMK_KEYBOARD_H + +enum custom_keycodes { + LAYER_SWITCH = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* Default */ + [0] = LAYOUT(LAYER_SWITCH, C(KC_C), C(KC_V)), + + /* RGB Toggle + Mode Change */ + [1] = LAYOUT(LAYER_SWITCH, RGB_TOG, RGB_MOD), + + /* RGB Brightness */ + [2] = LAYOUT(LAYER_SWITCH, RGB_VAD, RGB_VAI), + + /* RGB Hue */ + [3] = LAYOUT(LAYER_SWITCH, RGB_HUD, RGB_HUI), + + /* RGB Saturation */ + [4] = LAYOUT(LAYER_SWITCH, RGB_SAD, RGB_SAI), + +}; + +/* Lighting layers */ + +const rgblight_segment_t PROGMEM layer_indicator_0[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 1, HSV_WHITE}, + {1, 4, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_1[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 1, HSV_OFF}, + {1, 1, HSV_WHITE}, + {2, 3, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_2[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 2, HSV_OFF}, + {2, 1, HSV_WHITE}, + {3, 2, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_3[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 3, HSV_OFF}, + {3, 1, HSV_WHITE}, + {4, 1, HSV_OFF} +); + +const rgblight_segment_t PROGMEM layer_indicator_4[] = RGBLIGHT_LAYER_SEGMENTS( + {0, 4, HSV_OFF}, + {4, 1, HSV_WHITE} +); + +const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST( + layer_indicator_0, + layer_indicator_1, + layer_indicator_2, + layer_indicator_3, + layer_indicator_4 +); + +void keyboard_post_init_user(void) { + /* Enable the LED layers */ + rgblight_layers = rgb_layers; +} + +/* Layer handler */ + +uint16_t layer = 0; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case LAYER_SWITCH: + if (record->event.pressed) { + if (layer > 0) { + layer_off(layer); + } + + rgblight_unblink_layer(layer); + layer = (layer + 1) % 5; + rgblight_blink_layer_repeat(layer, 1000, 1); + + if (layer > 0) { + layer_on(layer); + } + } + return false; + default: + return true; + } +} diff --git a/keyboards/massdrop/thekey_v2/keymaps/url-copy-paste-macos/keymap.c b/keyboards/massdrop/thekey_v2/keymaps/url-copy-paste-macos/keymap.c new file mode 100644 index 00000000000..33d19734bcc --- /dev/null +++ b/keyboards/massdrop/thekey_v2/keymaps/url-copy-paste-macos/keymap.c @@ -0,0 +1,39 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#include QMK_KEYBOARD_H + +enum custom_keycodes { + TK_URL = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT(TK_URL, G(KC_C), G(KC_V)), +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case TK_URL: + if (record->event.pressed) { + // when keycode TK_URL is pressed + SEND_STRING("https://stackoverflow.com/\n"); + } + break; + default: + break; + } + return true; +} diff --git a/keyboards/massdrop/thekey_v2/keymaps/url-copy-paste/keymap.c b/keyboards/massdrop/thekey_v2/keymaps/url-copy-paste/keymap.c new file mode 100644 index 00000000000..5becddfa2a5 --- /dev/null +++ b/keyboards/massdrop/thekey_v2/keymaps/url-copy-paste/keymap.c @@ -0,0 +1,40 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#include QMK_KEYBOARD_H + +enum custom_keycodes { + TK_URL = SAFE_RANGE, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = LAYOUT(TK_URL, C(KC_C), C(KC_V)), +}; + + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case TK_URL: + if (record->event.pressed) { + // when keycode TK_URL is pressed + SEND_STRING("https://stackoverflow.com/"); + } + break; + default: + break; + } + return true; +} diff --git a/keyboards/massdrop/thekey_v2/readme.md b/keyboards/massdrop/thekey_v2/readme.md new file mode 100644 index 00000000000..ef4d6ec716e --- /dev/null +++ b/keyboards/massdrop/thekey_v2/readme.md @@ -0,0 +1,38 @@ +# The Key V2 + +![The Key V2](https://massdrop-s3.imgix.net/product-images/stack-overflow-the-key-v2-macropad/FP/vSqOp9eUQNGXW4zl3EVQ_7528-copy-pdp.jpg) + + +The Stack Overflow "The Key V2" is a 3 button macropad based on atmega32u4 with hot-swappble Kailh Black Box switches. + +> Last year, we brought Stack Overflow’s iconic April Fool’s joke to life. Advertised as the new (and only) way to copy and paste on the site, it was an ultra-compact macropad called The Key. The punchline-turned product was a huge hit, selling over 10K units and earning a nearly 5-star average review. Now, we’re back with a second act: The Key V2. The same size as its portable predecessor, this punchline-turned-product has a few notable changes—including an acrylic case to accent its two built-in RGB LEDs. Plus, we made it hot-swappable, so you can easily change out the switches for a truly custom experience. And just like the original, a portion of all proceeds from The Key V2 will go to the data-driven social startup digitalundivided. + +Keyboard Maintainer: [Drop / Massdrop](https://github.com/Massdrop/qmk_firmware) + +Hardware Supported: Massdrop, Inc. **The Key V2** + +Hardware Availability: Limited Release - https://drop.com/buy/stack-overflow-the-key-v2-macropad + + +Make example for this keyboard (after setting up your build environment): +```bash +# default provided by Drop / Stack Overflow +make massdrop/thekey_v2:default +# common modification where C = CTRL+C, V = CTRL+V +make massdrop/thekey_v2:url-copy-paste +``` + +Flashing example for this keyboard: +```bash +# install in dfu mode +make massdrop/thekey_v2:default:dfu +``` + +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). +Make example for this keyboard (after setting up your build environment): + +## Bootloader + +Enter the bootloader as follows: +* **Bootmagic reset**: Hold down the "Stack Overflow" key, the "left-most" or furthest from the USB plug while inserting the USB cable for a few seconds. The LEDs will **NOT** turn on. +* **Physical reset button**: Briefly press and hold the reset button while pluggin in the USB port. The LEDs on the back will **NOT** turn on. Depending on your case revision, you may have to remove the 4 screws on the back plate to access the switch OR you can use the associated access hole on newer releases. diff --git a/keyboards/massdrop/thekey_v2/rules.mk b/keyboards/massdrop/thekey_v2/rules.mk new file mode 100644 index 00000000000..a0a1e94e36d --- /dev/null +++ b/keyboards/massdrop/thekey_v2/rules.mk @@ -0,0 +1,18 @@ +# MCU name +MCU = atmega32u4 + +# Bootloader selection +BOOTLOADER = atmel-dfu + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow +AUDIO_ENABLE = no # Audio output diff --git a/keyboards/massdrop/thekey_v2/thekey_v2.c b/keyboards/massdrop/thekey_v2/thekey_v2.c new file mode 100644 index 00000000000..b1a824d9d42 --- /dev/null +++ b/keyboards/massdrop/thekey_v2/thekey_v2.c @@ -0,0 +1,17 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#include "thekey_v2.h" diff --git a/keyboards/massdrop/thekey_v2/thekey_v2.h b/keyboards/massdrop/thekey_v2/thekey_v2.h new file mode 100644 index 00000000000..c3b8e1a8ead --- /dev/null +++ b/keyboards/massdrop/thekey_v2/thekey_v2.h @@ -0,0 +1,27 @@ +/* Copyright 2022 Jason Wihardja + * + * 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 . + */ + +#pragma once + +#include "quantum.h" + +#define XXX KC_NO + +#define LAYOUT( \ + K00, K01, K02 \ +) { \ + { K00, K01, K02 }, \ +}