From f4c55db8dde8fb1590bff7661dae8718a29208b4 Mon Sep 17 00:00:00 2001 From: James Young <18669334+noroadsleft@users.noreply.github.com> Date: Wed, 4 Aug 2021 14:32:27 -0700 Subject: [PATCH] cKeys Handwire 101 Refactor (#13879) * update info.json - use human-friendly formatting - remove `key_count` key * rename LAYOUT to LAYOUT_ortho_4x4 * refactor default keymap - add license header - qmk cformat pass - keycode grid alignment * remove empty config.h file from default keymap * update Manufacturer and Product strings * tidy up handwire_101.c - add license header - remove boilerplate functions * tidy up handwire_101.h - add license header - remove instructive comment * minor rules.mk tidy-up - remove Bootloader selection sample comments * rewrite SEND_STRING() statements per fauxpark Co-authored-by: Ryan Co-authored-by: Ryan --- keyboards/ckeys/handwire_101/config.h | 4 +- keyboards/ckeys/handwire_101/handwire_101.c | 43 +-- keyboards/ckeys/handwire_101/handwire_101.h | 23 +- keyboards/ckeys/handwire_101/info.json | 42 ++- .../handwire_101/keymaps/default/config.h | 3 - .../handwire_101/keymaps/default/keymap.c | 326 +++++++++--------- keyboards/ckeys/handwire_101/rules.mk | 7 - 7 files changed, 237 insertions(+), 211 deletions(-) delete mode 100755 keyboards/ckeys/handwire_101/keymaps/default/config.h diff --git a/keyboards/ckeys/handwire_101/config.h b/keyboards/ckeys/handwire_101/config.h index f1e784fd24..663f5e343d 100755 --- a/keyboards/ckeys/handwire_101/config.h +++ b/keyboards/ckeys/handwire_101/config.h @@ -23,8 +23,8 @@ along with this program. If not, see . #define VENDOR_ID 0xFEED #define PRODUCT_ID 0x6060 #define DEVICE_VER 0x0001 -#define MANUFACTURER ckeys_handwire -#define PRODUCT ckeys_handwire +#define MANUFACTURER cKeys +#define PRODUCT Handwire 101 /* key matrix size */ #define MATRIX_ROWS 4 diff --git a/keyboards/ckeys/handwire_101/handwire_101.c b/keyboards/ckeys/handwire_101/handwire_101.c index a6ff8f0e3d..7d251ddce6 100755 --- a/keyboards/ckeys/handwire_101/handwire_101.c +++ b/keyboards/ckeys/handwire_101/handwire_101.c @@ -1,28 +1,17 @@ +/* Copyright 2019 Branden Byers + * + * 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 "handwire_101.h" - -void matrix_init_kb(void) { - // put your keyboard start-up code here - // runs once when the firmware starts up - // Turn status LED on - //DDRD |= (1<<6); - //PORTD |= (1<<6); - - matrix_init_user(); -} - -void matrix_scan_kb(void) { - // put your looping keyboard code here - // runs every cycle (a lot) - matrix_scan_user(); -} - -bool process_record_kb(uint16_t keycode, keyrecord_t *record) { - // put your per-action keyboard code here - // runs for every action, just before processing by the firmware - return process_record_user(keycode, record); -} - -void led_set_kb(uint8_t usb_led) { - // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here - led_set_user(usb_led); -} diff --git a/keyboards/ckeys/handwire_101/handwire_101.h b/keyboards/ckeys/handwire_101/handwire_101.h index 0f0309c324..5d6ef6ff09 100755 --- a/keyboards/ckeys/handwire_101/handwire_101.h +++ b/keyboards/ckeys/handwire_101/handwire_101.h @@ -1,12 +1,24 @@ +/* Copyright 2019 Branden Byers + * + * 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" -// This a shortcut to help you visually see your layout. -// The following is an example using the Planck MIT layout -// The first section contains all of the arguements -// The second converts the arguments into a two-dimensional array -#define LAYOUT( \ +#define LAYOUT_ortho_4x4( \ k00, k01, k02, k03, \ k10, k11, k12, k13, \ k20, k21, k22, k23, \ @@ -18,4 +30,3 @@ { k20, k21, k22, k23 }, \ { k30, k31, k32, k33 } \ } - diff --git a/keyboards/ckeys/handwire_101/info.json b/keyboards/ckeys/handwire_101/info.json index dfe6c48304..8113e391db 100644 --- a/keyboards/ckeys/handwire_101/info.json +++ b/keyboards/ckeys/handwire_101/info.json @@ -1,13 +1,35 @@ { - "keyboard_name": "cKeys Handwire 101", - "url": "https://ckeys.org/slides/handwire/", - "maintainer": "brandenbyers", - "width": 4, - "height": 4, - "layouts": { - "LAYOUT_ortho_4x4": { - "key_count": 16, - "layout": [{"x":0, "y":0}, {"x":1, "y":0}, {"x":2, "y":0}, {"x":3, "y":0}, {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":1}, {"x":3, "y":1}, {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":2}, {"x":3, "y":2}, {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":3}, {"x":3, "y":3}] + "keyboard_name": "cKeys Handwire 101", + "url": "https://ckeys.org/slides/handwire/", + "maintainer": "brandenbyers", + "width": 4, + "height": 4, + "layout_aliases": { + "LAYOUT": "LAYOUT_ortho_4x4" + }, + "layouts": { + "LAYOUT_ortho_4x4": { + "layout": [ + {"x":0, "y":0}, + {"x":1, "y":0}, + {"x":2, "y":0}, + {"x":3, "y":0}, + + {"x":0, "y":1}, + {"x":1, "y":1}, + {"x":2, "y":1}, + {"x":3, "y":1}, + + {"x":0, "y":2}, + {"x":1, "y":2}, + {"x":2, "y":2}, + {"x":3, "y":2}, + + {"x":0, "y":3}, + {"x":1, "y":3}, + {"x":2, "y":3}, + {"x":3, "y":3} + ] + } } - } } diff --git a/keyboards/ckeys/handwire_101/keymaps/default/config.h b/keyboards/ckeys/handwire_101/keymaps/default/config.h deleted file mode 100755 index 9935accb02..0000000000 --- a/keyboards/ckeys/handwire_101/keymaps/default/config.h +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -// Add overrides here diff --git a/keyboards/ckeys/handwire_101/keymaps/default/keymap.c b/keyboards/ckeys/handwire_101/keymaps/default/keymap.c index 8c65406ddb..fdca99fd07 100755 --- a/keyboards/ckeys/handwire_101/keymaps/default/keymap.c +++ b/keyboards/ckeys/handwire_101/keymaps/default/keymap.c @@ -1,177 +1,191 @@ +/* Copyright 2019 Branden Byers + * + * 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 layers { - _BASE, // base layer - _LAYERS, // layer of all layers - _MUSIC, // music mode - _MUSIC_4_LIFE, // music mode until unplugged - _MOUSE, // mousekeys - _TERMINAL, // terminal - _ADMIN // admin duties + _BASE, // base layer + _LAYERS, // layer of all layers + _MUSIC, // music mode + _MUSIC_4_LIFE, // music mode until unplugged + _MOUSE, // mousekeys + _TERMINAL, // terminal + _ADMIN // admin duties }; enum custom_keycodes { - TERM_ABOUT = SAFE_RANGE, - TERM_PRINT, - TERM_FLUSH, - TERM_HELP, - CKEYS_ABOUT, + TERM_ABOUT = SAFE_RANGE, + TERM_PRINT, + TERM_FLUSH, + TERM_HELP, + CKEYS_ABOUT, }; const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* BASE (numpad) - * ,-----------------------. - * | 7 | 8 | 9 | / | <-- Hold for LAYERS - * |-----+-----+-----+-----| - * | 4 | 5 | 6 | * | - * |-----+-----+-----+-----| - * | 1 | 2 | 3 | - | - * |-----+-----+-----+-----| - * | 0 | . | = | + | - * `---------------------- ' - */ - [_BASE] = LAYOUT( - KC_KP_7, KC_KP_8, KC_KP_9, LT(MO(_LAYERS), KC_PSLS), \ - KC_KP_4, KC_KP_5, KC_KP_6, KC_PAST, \ - KC_KP_1, KC_KP_2, KC_KP_3, KC_PMNS, \ - KC_KP_0, KC_KP_DOT, KC_KP_EQUAL, KC_PPLS \ - ), + * ,-----------------------. + * | 7 | 8 | 9 | / | <-- Hold for LAYERS + * |-----+-----+-----+-----| + * | 4 | 5 | 6 | * | + * |-----+-----+-----+-----| + * | 1 | 2 | 3 | - | + * |-----+-----+-----+-----| + * | 0 | . | = | + | + * `-----------------------' + */ + [_BASE] = LAYOUT_ortho_4x4( + KC_P7, KC_P8, KC_P9, LT(_LAYERS, KC_PSLS), + KC_P4, KC_P5, KC_P6, KC_PAST, + KC_P1, KC_P2, KC_P3, KC_PMNS, + KC_P0, KC_PDOT, KC_PEQL, KC_PPLS + ), /* LAYERS - * ,---------------------------. - * | MUSIC | | | X | - * |---------+-----+-----+-----| - * | MOUSE | | | | - * |---------+-----+-----+-----| - * |TERMINAL | | | | - * |---------+-----+-----+-----| - * | ADMIN | | | | - * `---------------------------' - */ - [_LAYERS] = LAYOUT( - TG(_MUSIC), _______, _______, _______, \ - TG(_MOUSE), _______, _______, _______, \ - TG(_TERMINAL), _______, _______, _______, \ - TG(_ADMIN), _______, _______, _______\ - ), + * ,---------------------------. + * | MUSIC | | | X | + * |---------+-----+-----+-----| + * | MOUSE | | | | + * |---------+-----+-----+-----| + * |TERMINAL | | | | + * |---------+-----+-----+-----| + * | ADMIN | | | | + * `---------------------------' + */ + [_LAYERS] = LAYOUT_ortho_4x4( + TG(_MUSIC), _______, _______, _______, + TG(_MOUSE), _______, _______, _______, + TG(_TERMINAL), _______, _______, _______, + TG(_ADMIN), _______, _______, _______ + ), /* MUSIC - * ,-----------------------. - * | X | | | X | - * |-----+-----+-----+-----| - * | | | |4EVER| - * |-----+-----+-----+-----| - * | OFF | | | | - * |-----+-----+-----+-----| - * | ON | | |MODES| - * `---------------------- ' - */ - // TODO: Make this music layer the one to jump to other music layers (different octaves) - [_MUSIC] = LAYOUT( - _______, _______, _______, _______, \ - _______, _______, _______, TG(_MUSIC_4_LIFE), \ - MU_OFF, _______, _______, _______, \ - MU_ON, _______, _______, MU_MOD \ - ), + * ,-----------------------. + * | X | | | X | + * |-----+-----+-----+-----| + * | | | |4EVER| + * |-----+-----+-----+-----| + * | OFF | | | | + * |-----+-----+-----+-----| + * | ON | | |MODES| + * `-----------------------' + */ + // TODO: Make this music layer the one to jump to other music layers (different octaves) + [_MUSIC] = LAYOUT_ortho_4x4( + _______, _______, _______, _______, + _______, _______, _______, TG(_MUSIC_4_LIFE), + MU_OFF, _______, _______, _______, + MU_ON, _______, _______, MU_MOD + ), /* MUSIC_4_LIFE - * ,-----------------------. - * | ♫ | ♫ | ♫ | ♫ | - * |-----+-----+-----+-----| - * | ♫ | ♫ | ♫ | ♫ | - * |-----+-----+-----+-----| - * | ♫ | ♫ | ♫ | ♫ | - * |-----+-----+-----+-----| - * | ♫ | ♫ | ♫ | ♫ | - * `---------------------- ' - */ - [_MUSIC_4_LIFE] = LAYOUT( - KC_M, KC_M, KC_M, KC_M, \ - KC_M, KC_M, KC_M, KC_M, \ - KC_M, KC_M, KC_M, KC_M, \ - KC_M, KC_M, KC_M, KC_M \ - ), + * ,-----------------------. + * | ♫ | ♫ | ♫ | ♫ | + * |-----+-----+-----+-----| + * | ♫ | ♫ | ♫ | ♫ | + * |-----+-----+-----+-----| + * | ♫ | ♫ | ♫ | ♫ | + * |-----+-----+-----+-----| + * | ♫ | ♫ | ♫ | ♫ | + * `-----------------------' + */ + [_MUSIC_4_LIFE] = LAYOUT_ortho_4x4( + KC_M, KC_M, KC_M, KC_M, + KC_M, KC_M, KC_M, KC_M, + KC_M, KC_M, KC_M, KC_M, + KC_M, KC_M, KC_M, KC_M + ), /* MOUSE - * ,-------------------------------------------------. - * | BUTTON 5 | | SCROLL UP | X | - * |-----------+-----------+------------+------------| - * | X |LEFT CLICK | UP |RIGHT CLICK | - * |-----------+-----------+------------+------------| - * | BUTTON 4 | LEFT | DOWN | RIGHT | - * |-----------+-----------+------------+------=-----| - * | BUTTON 3 |SCROLL LEFT|SCROLL DOWN |SCROLL RIGHT| - * `-------------------------------------------------' - */ - [_MOUSE] = LAYOUT( - KC_MS_BTN5, _______, KC_MS_WH_UP, _______, \ - _______, KC_MS_BTN1, KC_MS_UP, KC_MS_BTN2, \ - KC_MS_BTN4, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, \ - KC_MS_BTN3, KC_MS_WH_LEFT, KC_MS_WH_DOWN, KC_MS_WH_RIGHT \ - ), + * ,-------------------------------------------------. + * | BUTTON 5 | | SCROLL UP | X | + * |-----------+-----------+------------+------------| + * | X |LEFT CLICK | UP |RIGHT CLICK | + * |-----------+-----------+------------+------------| + * | BUTTON 4 | LEFT | DOWN | RIGHT | + * |-----------+-----------+------------+------=-----| + * | BUTTON 3 |SCROLL LEFT|SCROLL DOWN |SCROLL RIGHT| + * `-------------------------------------------------' + */ + [_MOUSE] = LAYOUT_ortho_4x4( + KC_BTN5, _______, KC_WH_U, _______, + _______, KC_BTN1, KC_MS_U, KC_BTN2, + KC_BTN4, KC_MS_L, KC_MS_D, KC_MS_R, + KC_BTN3, KC_WH_L, KC_WH_D, KC_WH_R + ), /* TERMINAL - * ,---------------------------------------. - * | |ABOUT| | X | - * |------------+-----+----------+---------| - * |TERMINAL OFF|PRINT| | | - * |------------+-----+----------+---------| - * | X |FLUSH| | | - * |------------+-----+----------+---------| - * |TERMINAL ON |HELP | | | - * `--------=======------------------------' - */ - [_TERMINAL] = LAYOUT( - _______, TERM_ABOUT, _______, _______, \ - TERM_OFF, TERM_PRINT, _______, _______, \ - _______, TERM_FLUSH, _______, _______, \ - TERM_ON, TERM_HELP , _______, _______\ - ), + * ,---------------------------------------. + * | |ABOUT| | X | + * |------------+-----+----------+---------| + * |TERMINAL OFF|PRINT| | | + * |------------+-----+----------+---------| + * | X |FLUSH| | | + * |------------+-----+----------+---------| + * |TERMINAL ON |HELP | | | + * `--------=======------------------------' + */ + [_TERMINAL] = LAYOUT_ortho_4x4( + _______, TERM_ABOUT, _______, _______, + TERM_OFF, TERM_PRINT, _______, _______, + _______, TERM_FLUSH, _______, _______, + TERM_ON, TERM_HELP , _______, _______ + ), /* ADMIN - * ,-----------------------------------------. - * | RESET | | | X | - * |------------+-----+-----------+----------| - * |ABOUT CKEYS | | | | - * |------------+-----+-----------+----------| - * | | |CLICKY UP |CLICKY OFF| - * |------------+-----+-----------+----------| - * | X | |CLICKY DOWN|CLICKY ON | - * `-----------------------------------------' - */ - [_ADMIN] = LAYOUT( - RESET, _______, _______, _______, \ - CKEYS_ABOUT, _______, _______, _______, \ - _______, _______, _______, CK_OFF, \ - _______, _______, _______, CK_ON \ - ), + * ,-----------------------------------------. + * | RESET | | | X | + * |------------+-----+-----------+----------| + * |ABOUT CKEYS | | | | + * |------------+-----+-----------+----------| + * | | |CLICKY UP |CLICKY OFF| + * |------------+-----+-----------+----------| + * | X | |CLICKY DOWN|CLICKY ON | + * `-----------------------------------------' + */ + [_ADMIN] = LAYOUT_ortho_4x4( + RESET, _______, _______, _______, + CKEYS_ABOUT, _______, _______, _______, + _______, _______, _______, CK_OFF, + _______, _______, _______, CK_ON + ), }; bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case TERM_ABOUT: - if (record->event.pressed) { - // when keycode TERM_ABOUT is pressed - SEND_STRING("about"SS_TAP(X_ENTER)); - } else { - // when keycode TERM_ABOUT is released - } - break; - case TERM_PRINT: - if (record->event.pressed) { - SEND_STRING("print"SS_TAP(X_ENTER)); - } else { } - break; - case TERM_FLUSH: - if (record->event.pressed) { - SEND_STRING("flush"SS_TAP(X_ENTER)); - } else { } - break; - case TERM_HELP: - if (record->event.pressed) { - SEND_STRING("help"SS_TAP(X_ENTER)); - } else { } - break; - case CKEYS_ABOUT: - if (record->event.pressed) { - SEND_STRING("https://cKeys.org"SS_TAP(X_ENTER)"Making people smile one keyboard at a time."SS_TAP(X_ENTER)"cKeys is a volunteer-run 501(c)(3) nonprofit organization."SS_TAP(X_ENTER)); - } else { } - break; - } - return true; + switch (keycode) { + case TERM_ABOUT: + if (record->event.pressed) { + // when keycode TERM_ABOUT is pressed + SEND_STRING("about\n"); + } + break; + case TERM_PRINT: + if (record->event.pressed) { + SEND_STRING("print\n"); + } + break; + case TERM_FLUSH: + if (record->event.pressed) { + SEND_STRING("flush\n"); + } + break; + case TERM_HELP: + if (record->event.pressed) { + SEND_STRING("help\n"); + } + break; + case CKEYS_ABOUT: + if (record->event.pressed) { + SEND_STRING("https://cKeys.org\nMaking people smile one keyboard at a time.\ncKeys is a volunteer-run 501(c)(3) nonprofit organization.\n"); + } + break; + } + return true; }; diff --git a/keyboards/ckeys/handwire_101/rules.mk b/keyboards/ckeys/handwire_101/rules.mk index 715738a0cd..3d47513306 100755 --- a/keyboards/ckeys/handwire_101/rules.mk +++ b/keyboards/ckeys/handwire_101/rules.mk @@ -2,13 +2,6 @@ MCU = atmega32u4 # Bootloader selection -# Teensy halfkay -# Pro Micro caterina -# Atmel DFU atmel-dfu -# LUFA DFU lufa-dfu -# QMK DFU qmk-dfu -# ATmega32A bootloadHID -# ATmega328P USBasp BOOTLOADER = caterina # Build Options