From: Erez Zukerman Date: Mon, 27 Nov 2017 13:25:24 +0000 (-0500) Subject: Merge pull request #2047 from seebs/seebs/ergodox_brightness X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0bd453b5276714b9a33c6a2060851ea5184c52b2;hp=534cd9d45e66b4750d7790fa7230b2108ab3966d;p=qmk_firmware.git Merge pull request #2047 from seebs/seebs/ergodox_brightness Make brightness easier to change --- diff --git a/keyboards/atreus62/keymaps/pcewing/keymap.c b/keyboards/atreus62/keymaps/pcewing/keymap.c new file mode 100644 index 000000000..7ad033eee --- /dev/null +++ b/keyboards/atreus62/keymaps/pcewing/keymap.c @@ -0,0 +1,97 @@ +#include "atreus62.h" + +#define _______ KC_TRNS +#define FN MO(_FN) +#define TODO KC_NO + +enum atreus62_layers { + _DEFAULT, + _FN, + _RESET +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* Default layer + * ,-----------------------------------------. ,-----------------------------------------. + * | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | Tab | Q | W | E | R | T | | Y | U | I | O | P | \ | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | Esc | A | S | D | F | G |,------.,------.| H | J | K | L | ; | " | + * |------+------+------+------+------+------|| || ||------+------+------+------+------+------| + * |Shift | Z | X | C | V | B ||Delete||Enter || N | M | , | . | / |Shift | + * |------+------+------+------+------+------|| || ||------+------+------+------+------+------| + * | Ctrl | Win | Alt | ` | Fn | Bksp |`------'`------'|Space | Fn | | Alt | Win | Ctrl | + * `-----------------------------------------' `-----------------------------------------' + */ +[_DEFAULT] = { /* qwerty */ + { KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, _______, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS }, + { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, _______, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS }, + { KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, _______, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT }, + { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_DEL, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT }, + { KC_LCTL, KC_LGUI, KC_LALT, KC_GRV, FN, KC_BSPC, KC_ENT, KC_SPC, FN, TODO, KC_RALT, KC_RGUI, KC_RCTL } +}, + +/* Function layer + * ,-----------------------------------------. ,-----------------------------------------. + * | | | | | | | | | F10 | F11 | F12 | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | Home | Up | End | PgUp | | | PrSc | F7 | F8 | F9 | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | Caps | Left | Down |Right | PgDn | |,------.,------.|Pause | F4 | F5 | F6 | | | + * |------+------+------+------+------+------|| || ||------+------+------+------+------+------| + * | | { | } | [ | ] | || || ||Insert| F1 | F2 | F3 | | | + * |------+------+------+------+------+------|| || ||------+------+------+------+------+------| + * | | | | | | |`------'`------'| | | | | | | + * `-----------------------------------------' `-----------------------------------------' + */ +[_FN] = { + { _______, _______, _______, _______, _______, _______, _______, _______, KC_F10, KC_F11, KC_F12, _______, TO(_RESET) }, + { _______, KC_HOME, KC_UP, KC_END, KC_PGDN, _______, _______, KC_PSCR, KC_F7, KC_F8, KC_F9, _______, _______ }, + { _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGUP, _______, _______, KC_PAUS, KC_F4, KC_F5, KC_F6, _______, _______ }, + { _______, KC_LCBR, KC_RCBR, KC_LBRC, KC_RBRC, _______, _______, KC_INS, KC_F1, KC_F2, KC_F3, _______, _______ }, + { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ } +}, + +/* + * This layer makes it possible to reset the firmware; don't get rid of it and make sure there is a way to activate it. + */ +[_RESET] = { + { TO(_DEFAULT), KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO }, + { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO }, + { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO }, + { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO }, + { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , RESET } +} + +/* +[_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, 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 } +}, +*/ +}; + +const uint16_t PROGMEM fn_actions[] = { + +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch (id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + } + else { + unregister_code(KC_RSFT); + } + break; + } + return MACRO_NONE; +}; diff --git a/keyboards/ergodox_ez/config.h b/keyboards/ergodox_ez/config.h index 81f749dfa..ae70c4f2e 100644 --- a/keyboards/ergodox_ez/config.h +++ b/keyboards/ergodox_ez/config.h @@ -31,6 +31,7 @@ along with this program. If not, see . /* key matrix size */ #define MATRIX_ROWS 14 +#define MATRIX_ROWS_PER_SIDE (MATRIX_ROWS / 2) #define MATRIX_COLS 6 #define MOUSEKEY_INTERVAL 20 @@ -85,7 +86,16 @@ along with this program. If not, see . #define RGBW 1 -/* Set 0 if debouncing isn't needed */ +/* "debounce" is measured in keyboard scans. Some users reported + * needing values as high as 15, which was at the time around 50ms. + * If you don't define it here, the matrix code will default to + * 5, which is now closer to 10ms, but still plenty according to + * manufacturer specs. + * + * Default is quite high, because of reports with some production + * runs seeming to need it. This may change when configuration for + * this is more directly exposed. + */ #define DEBOUNCE 15 #define PREVENT_STUCK_MODIFIERS diff --git a/keyboards/ergodox_ez/ergodox_ez.c b/keyboards/ergodox_ez/ergodox_ez.c index 1b643cbef..5f197cb2d 100644 --- a/keyboards/ergodox_ez/ergodox_ez.c +++ b/keyboards/ergodox_ez/ergodox_ez.c @@ -38,7 +38,7 @@ void matrix_init_kb(void) { PORTB &= ~(1<<4); // set B(4) internal pull-up disabled // unused pins - C7, D4, D5, D7, E6 - // set as input with internal pull-ip enabled + // set as input with internal pull-up enabled DDRC &= ~(1<<7); DDRD &= ~(1<<5 | 1<<4); DDRE &= ~(1<<6); diff --git a/keyboards/ergodox_ez/matrix.c b/keyboards/ergodox_ez/matrix.c index 70efb43d8..f0550e9b8 100644 --- a/keyboards/ergodox_ez/matrix.c +++ b/keyboards/ergodox_ez/matrix.c @@ -47,7 +47,9 @@ along with this program. If not, see . * Now it's only 317 scans/second, or about 3.15 msec/scan. * According to Cherry specs, debouncing time is 5 msec. * - * And so, there is no sense to have DEBOUNCE higher than 2. + * However, some switches seem to have higher debouncing requirements, or + * something else might be wrong. (Also, the scan speed has improved since + * that comment was written.) */ #ifndef DEBOUNCE @@ -203,16 +205,23 @@ uint8_t matrix_scan(void) #endif #ifdef LEFT_LEDS - mcp23018_status = ergodox_left_leds_update(); + mcp23018_status = ergodox_left_leds_update(); #endif // LEFT_LEDS - for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + for (uint8_t i = 0; i < MATRIX_ROWS_PER_SIDE; i++) { select_row(i); - wait_us(30); // without this wait read unstable value. + // and select on left hand + select_row(i + MATRIX_ROWS_PER_SIDE); + // we don't need a 30us delay anymore, because selecting a + // left-hand row requires more than 30us for i2c. matrix_row_t mask = debounce_mask(i); matrix_row_t cols = (read_cols(i) & mask) | (matrix[i] & ~mask); debounce_report(cols ^ matrix[i], i); matrix[i] = cols; - + // grab cols from right hand + mask = debounce_mask(i + MATRIX_ROWS_PER_SIDE); + cols = (read_cols(i + MATRIX_ROWS_PER_SIDE) & mask) | (matrix[i + MATRIX_ROWS_PER_SIDE] & ~mask); + debounce_report(cols ^ matrix[i + MATRIX_ROWS_PER_SIDE], i + MATRIX_ROWS_PER_SIDE); + matrix[i + MATRIX_ROWS_PER_SIDE] = cols; unselect_rows(); } @@ -295,14 +304,13 @@ static matrix_row_t read_cols(uint8_t row) return data; } } else { - // read from teensy - return - (PINF&(1<<0) ? 0 : (1<<0)) | - (PINF&(1<<1) ? 0 : (1<<1)) | - (PINF&(1<<4) ? 0 : (1<<2)) | - (PINF&(1<<5) ? 0 : (1<<3)) | - (PINF&(1<<6) ? 0 : (1<<4)) | - (PINF&(1<<7) ? 0 : (1<<5)) ; + /* read from teensy + * bitmask is 0b11110011, but we want those all + * in the lower six bits. + * we'll return 1s for the top two, but that's harmless. + */ + + return ~((PINF & 0x03) | ((PINF & 0xF0) >> 2)); } } @@ -325,9 +333,7 @@ static void unselect_rows(void) // set all rows hi-Z : 1 mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out; - mcp23018_status = i2c_write( 0xFF - & ~(0<<7) - ); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0xFF); if (mcp23018_status) goto out; out: i2c_stop(); } @@ -353,9 +359,7 @@ static void select_row(uint8_t row) // set other rows hi-Z : 1 mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; mcp23018_status = i2c_write(GPIOA); if (mcp23018_status) goto out; - mcp23018_status = i2c_write( 0xFF & ~(1< Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability. + +Digipot AD5258 +-------------- +Controller can operate AD5258 via I2C to change actuation point of keys. This may make keyboard unusable accidentally and it will be difficult to recovery in some situation. For safety firmware doesn't support it at this point, though. + +Lower value of RDAC register causes shallower actuation point. + +Resources +--------- +- Pics: https://imgur.com/a/UTR8Z diff --git a/keyboards/fc660c/config.h b/keyboards/fc660c/config.h new file mode 100644 index 000000000..0afd374a0 --- /dev/null +++ b/keyboards/fc660c/config.h @@ -0,0 +1,80 @@ +/* +Copyright 2017 Balz Guenat + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x660C +#define DEVICE_VER 0x0100 +#define MANUFACTURER QMK +#define PRODUCT Leopold FC660C with QMK +#define DESCRIPTION Leopold FC660C with Hasu alternative controller using QMK + +/* key matrix size */ +#define MATRIX_ROWS 8 +#define MATRIX_COLS 16 + +#define DIODE_DIRECTION CUSTOM_MATRIX + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* number of backlight levels */ +// #define BACKLIGHT_LEVELS 1 + +/* mapping backlight LEDs to correct Pin */ +// #define BACKLIGHT_PIN B7 + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCING_DELAY 0 +#define TAPPING_TERM 175 + +/* 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 + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + + + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +#endif diff --git a/keyboards/fc660c/fc660c.c b/keyboards/fc660c/fc660c.c new file mode 100644 index 000000000..f2a561767 --- /dev/null +++ b/keyboards/fc660c/fc660c.c @@ -0,0 +1,48 @@ +/* +Copyright 2017 Balz Guenat + +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 "fc660c.h" + +void matrix_init_kb(void) { + // put your keyboard start-up code here + // runs once when the firmware starts up + + 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) { + if (usb_led & (1<. +*/ +#ifndef FC660C_H +#define FC660C_H + +#include "quantum.h" + + +#define KEYMAP( \ + K13, K10, K11, K12, K14, K16, K17, K15, K1B, K18, K19, K1A, K1C, K1E, K1F, \ + K03, K00, K01, K02, K04, K06, K07, K05, K0B, K08, K09, K0A, K0C, K0E, K0F, \ + K43, K40, K41, K42, K44, K46, K47, K45, K4B, K48, K49, K4A, K4E, \ + K33, K31, K32, K34, K36, K37, K35, K3B, K38, K39, K3A, K3C, K3D, \ + K23, K21, K22, K27, K28, K2A, K2C, K2E, K2D, K2F \ +) { \ + { K00, K01, K02, K03, K04, K05, K06, K07, \ + K08, K09, K0A, K0B, K0C, KC_NO, K0E, K0F }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, \ + K18, K19, K1A, K1B, K1C, KC_NO, K1E, K1F }, \ + { KC_NO, K21, K22, K23, KC_NO, KC_NO, KC_NO, K27, \ + K28, KC_NO, K2A, KC_NO, K2C, K2D, K2E, K2F }, \ + { KC_NO, K31, K32, K33, K34, K35, K36, K37, \ + K38, K39, K3A, K3B, K3C, K3D, KC_NO, KC_NO }, \ + { K40, K41, K42, K43, K44, K45, K46, K47, \ + K48, K49, K4A, K4B, KC_NO, KC_NO, K4E, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \ + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO } \ +} +/* +KEYMAP( + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, + _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, + _______,_______,_______, _______, _______,_______,_______, _______,_______,_______ + ) +*/ + +#endif diff --git a/keyboards/fc660c/keymaps/default/README.md b/keyboards/fc660c/keymaps/default/README.md new file mode 100644 index 000000000..f813ed0c3 --- /dev/null +++ b/keyboards/fc660c/keymaps/default/README.md @@ -0,0 +1,5 @@ +# The default keymap for the FC660C + +Emulates original keymap. + +![](https://i.imgur.com/fg89nez.jpg) \ No newline at end of file diff --git a/keyboards/fc660c/keymaps/default/config.h b/keyboards/fc660c/keymaps/default/config.h new file mode 100644 index 000000000..596198be1 --- /dev/null +++ b/keyboards/fc660c/keymaps/default/config.h @@ -0,0 +1,24 @@ +/* Copyright 2017 Balz Guenat + * + * 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 . + */ + +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "config_common.h" + +// place overrides here + +#endif diff --git a/keyboards/fc660c/keymaps/default/keymap.c b/keyboards/fc660c/keymaps/default/keymap.c new file mode 100644 index 000000000..02f57532b --- /dev/null +++ b/keyboards/fc660c/keymaps/default/keymap.c @@ -0,0 +1,37 @@ +/* +Copyright 2017 Balz Guenat + +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 "fc660c.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [0] = KEYMAP( + KC_ESC, 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_BSPC, KC_INS, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSLS, KC_DEL, + KC_CAPS,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT, KC_ENT, + KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,KC_RSFT, KC_UP, + KC_LCTL,KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RCTL,MO(1), KC_LEFT,KC_DOWN,KC_RGHT + ), + [1] = KEYMAP( + KC_GRV, 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_PSCR,KC_SLCK,KC_PAUS,_______,_______,_______, _______, + _______,_______,_______,_______,_______,_______,_______,_______,KC_HOME,KC_PGUP,_______,_______, _______, + _______,_______,_______,_______,_______,_______,_______,_______,KC_END, KC_PGDN,_______,_______, _______, + _______,_______,_______, _______, _______,_______,MO(1), _______,_______,_______ + ) +}; + +const uint16_t PROGMEM fn_actions[] = { +}; diff --git a/keyboards/fc660c/matrix.c b/keyboards/fc660c/matrix.c new file mode 100644 index 000000000..211506fdf --- /dev/null +++ b/keyboards/fc660c/matrix.c @@ -0,0 +1,226 @@ +/* +Copyright 2017 Balz Guenat +based on work by Jun Wako + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "timer.h" +#include "matrix.h" +#include "led.h" + +// Timer resolution check +#if (1000000/TIMER_RAW_FREQ > 20) +# error "Timer resolution(>20us) is not enough for HHKB matrix scan tweak on V-USB." +#endif + + +/* + * Pin configuration for ATMega32U4 + * + * Row: PD4-6, 7(~EN) + * Col: PB0-2, 3(Z5 ~EN), 4(Z4 ~EN) + * Key: PC6(pull-uped) + * Hys: PC7 + */ +static inline void KEY_ENABLE(void) { (PORTD &= ~(1<<7)); } +static inline void KEY_UNABLE(void) { (PORTD |= (1<<7)); } +static inline bool KEY_STATE(void) { return (PINC & (1<<6)); } +static inline void KEY_HYS_ON(void) { (PORTC |= (1<<7)); } +static inline void KEY_HYS_OFF(void) { (PORTC &= ~(1<<7)); } +static inline void KEY_INIT(void) +{ + /* Col */ + DDRB |= 0x1F; + /* Key: input with pull-up */ + DDRC &= ~(1<<6); + PORTC |= (1<<6); + /* Hys */ + DDRC |= (1<<7); + /* Row */ + DDRD |= 0xF0; + + KEY_UNABLE(); + KEY_HYS_OFF(); +} +static inline void SET_ROW(uint8_t ROW) +{ + // set row with unabling key + PORTD = (PORTD & 0x0F) | (1<<7) | ((ROW & 0x07) << 4); +} +static inline void SET_COL(uint8_t COL) +{ + // |PB3(Z5 ~EN)|PB4(Z4 ~EN) + // --------|-----------|----------- + // Col:0-7 |high |low + // Col:8-F |low |high + PORTB = (PORTB & 0xE0) | ((COL & 0x08) ? 1<<4 : 1<<3) | (COL & 0x07); +} + +static uint32_t matrix_last_modified = 0; + +// matrix state buffer(1:on, 0:off) +static matrix_row_t *matrix; +static matrix_row_t *matrix_prev; +static matrix_row_t _matrix0[MATRIX_ROWS]; +static matrix_row_t _matrix1[MATRIX_ROWS]; + + +__attribute__ ((weak)) +void matrix_init_quantum(void) { + matrix_init_kb(); +} + +__attribute__ ((weak)) +void matrix_scan_quantum(void) { + matrix_scan_kb(); +} + +__attribute__ ((weak)) +void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +__attribute__ ((weak)) +void matrix_init_user(void) { +} + +__attribute__ ((weak)) +void matrix_scan_user(void) { +} + + +void matrix_init(void) +{ + KEY_INIT(); + + // LEDs on CapsLock and Insert + DDRB |= (1<<5) | (1<<6); + PORTB |= (1<<5) | (1<<6); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix0[i] = 0x00; + for (uint8_t i=0; i < MATRIX_ROWS; i++) _matrix1[i] = 0x00; + matrix = _matrix0; + matrix_prev = _matrix1; + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) +{ + matrix_row_t *tmp; + + tmp = matrix_prev; + matrix_prev = matrix; + matrix = tmp; + + uint8_t row, col; + for (col = 0; col < MATRIX_COLS; col++) { + SET_COL(col); + for (row = 0; row < MATRIX_ROWS; row++) { + //KEY_SELECT(row, col); + SET_ROW(row); + _delay_us(2); + + // Not sure this is needed. This just emulates HHKB controller's behaviour. + if (matrix_prev[row] & (1< 20/(1000000/TIMER_RAW_FREQ)) { + matrix[row] = matrix_prev[row]; + } + + _delay_us(5); + KEY_HYS_OFF(); + KEY_UNABLE(); + + // NOTE: KEY_STATE keep its state in 20us after KEY_ENABLE. + // This takes 25us or more to make sure KEY_STATE returns to idle state. + _delay_us(75); + } + if (matrix[row] ^ matrix_prev[row]) { + matrix_last_modified = timer_read32(); + } + } + matrix_scan_quantum(); + return 1; +} + +inline +matrix_row_t matrix_get_row(uint8_t row) { + return matrix[row]; +} + +void matrix_print(void) +{ +#if (MATRIX_COLS <= 8) + print("r/c 01234567\n"); +#elif (MATRIX_COLS <= 16) + print("r/c 0123456789ABCDEF\n"); +#elif (MATRIX_COLS <= 32) + print("r/c 0123456789ABCDEF0123456789ABCDEF\n"); +#endif + + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + +#if (MATRIX_COLS <= 8) + xprintf("%02X: %08b%s\n", row, bitrev(matrix_get_row(row)), +#elif (MATRIX_COLS <= 16) + xprintf("%02X: %016b%s\n", row, bitrev16(matrix_get_row(row)), +#elif (MATRIX_COLS <= 32) + xprintf("%02X: %032b%s\n", row, bitrev32(matrix_get_row(row)), +#endif +#ifdef MATRIX_HAS_GHOST + matrix_has_ghost_in_row(row) ? " Exposure to absolute-maximum-rated conditions for extended periods may affect device reliability. + + +Digipot AD5258 +-------------- +Controller can operate AD5258 via I2C to change actuation point of keys. This may make keyboard unusable accidentally and it will be difficult to recovery in some situation. For safety firmware doesn't support it at this point, though. + +Lower value of RDAC register causes shallower actuation point. + + +USB connector board +------------------- +The keyboard has USB receptacle on small separate 1.0mm-thick PCB. USB receptacle is Hirose UX60SC-MB-5S8 while wire-to-PCB connector is TYU TU1252WNR-05S. + +http://i.imgur.com/Nucn6h9.jpg + + +Resources +--------- +- Pics: http://imgur.com/a/HhyIq diff --git a/keyboards/handwired/dactyl/config.h b/keyboards/handwired/dactyl/config.h new file mode 100644 index 000000000..8129b0a67 --- /dev/null +++ b/keyboards/handwired/dactyl/config.h @@ -0,0 +1,67 @@ +/* +Copyright 2012 Jun Wako +Copyright 2013 Oleg Kostyuk +Copyright 2017 Erin Call + +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 . +*/ + +#ifndef DACTYL_CONFIG_H +#define DACTYL_CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x1308 +#define DEVICE_VER 0x0001 +#define MANUFACTURER Adereth +#define PRODUCT Dactyl +#define DESCRIPTION An ortholinear, split, 3D-curved keyboard with thumb clusters. + +/* key matrix size + * At this time, "row" in the dactyl's code actually means "column" on the + * physical keyboard. It's confusing. I'm sorry. Blame Jack Humbert :P + */ +#define MATRIX_ROWS 12 +#define MATRIX_COLS 6 + +#define MOUSEKEY_INTERVAL 20 +#define MOUSEKEY_DELAY 0 +#define MOUSEKEY_TIME_TO_MAX 60 +#define MOUSEKEY_MAX_SPEED 7 +#define MOUSEKEY_WHEEL_DELAY 0 + +#define TAPPING_TOGGLE 1 + +#define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.) + +/* key combination for command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) || \ + keyboard_report->mods == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \ +) + +/* fix space cadet rollover issue */ +#define DISABLE_SPACE_CADET_ROLLOVER + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCE 15 + +#define PREVENT_STUCK_MODIFIERS + +#define USB_MAX_POWER_CONSUMPTION 500 + +#endif diff --git a/keyboards/handwired/dactyl/dactyl.c b/keyboards/handwired/dactyl/dactyl.c new file mode 100644 index 000000000..3f59154fd --- /dev/null +++ b/keyboards/handwired/dactyl/dactyl.c @@ -0,0 +1,80 @@ +#include "dactyl.h" +#include "i2cmaster.h" + + +bool i2c_initialized = 0; +uint8_t mcp23018_status = 0x20; + +void matrix_init_kb(void) { + DDRB &= ~(1<<4); // set B(4) as input + PORTB &= ~(1<<4); // set B(4) internal pull-up disabled + + // unused pins - C7, D4, D5, D7, E6 + // set as input with internal pull-up enabled + DDRC &= ~(1<<7); + DDRD &= ~(1<<5 | 1<<4); + DDRE &= ~(1<<6); + PORTC |= (1<<7); + PORTD |= (1<<5 | 1<<4); + PORTE |= (1<<6); + + matrix_init_user(); +} + +uint8_t init_mcp23018(void) { + mcp23018_status = 0x20; + + // I2C subsystem + + if (i2c_initialized == 0) { + i2c_init(); // on pins D(1,0) + i2c_initialized = true; + _delay_ms(1000); + } + + // set pin direction + // - unused : input : 1 + // - input : input : 1 + // - driving : output : 0 + mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(IODIRA); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out; + i2c_stop(); + + // set pull-up + // - unused : on : 1 + // - input : on : 1 + // - driving : off : 0 + mcp23018_status = i2c_start(I2C_ADDR_WRITE); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(GPPUA); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00000000); if (mcp23018_status) goto out; + mcp23018_status = i2c_write(0b00111111); if (mcp23018_status) goto out; + +out: + i2c_stop(); + + return mcp23018_status; +} + +#ifdef ONEHAND_ENABLE +__attribute__ ((weak)) +// swap-hands action needs a matrix to define the swap +const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { + /* Left hand, matrix positions */ + {{0,11}, {1,11}, {2,11}, {3,11}, {4,11}, {5,11}}, + {{0,10}, {1,10}, {2,10}, {3,10}, {4,10}, {5,10}}, + {{0,9}, {1,9}, {2,9}, {3,9}, {4,9}, {5,9}}, + {{0,8}, {1,8}, {2,8}, {3,8}, {4,8}, {5,8}}, + {{0,7}, {1,7}, {2,7}, {3,7}, {4,7}, {5,7}}, + {{0,6}, {1,6}, {2,6}, {3,6}, {4,6}, {5,6}}, + + /* Right hand, matrix positions */ + {{0,5}, {1,5}, {2,5}, {3,5}, {4,5}, {5,5}}, + {{0,4}, {1,4}, {2,4}, {3,4}, {4,4}, {5,4}}, + {{0,3}, {1,3}, {2,3}, {3,3}, {4,3}, {5,3}}, + {{0,2}, {1,2}, {2,2}, {3,2}, {4,2}, {5,2}}, + {{0,1}, {1,1}, {2,1}, {3,1}, {4,1}, {5,1}}, + {{0,0}, {1,0}, {2,0}, {3,0}, {4,0}, {5,0}}, +}; +#endif diff --git a/keyboards/handwired/dactyl/dactyl.h b/keyboards/handwired/dactyl/dactyl.h new file mode 100644 index 000000000..aa573ebd2 --- /dev/null +++ b/keyboards/handwired/dactyl/dactyl.h @@ -0,0 +1,74 @@ +#ifndef DACTYL_H +#define DACTYL_H + +#include "quantum.h" +#include +#include +#include "i2cmaster.h" +#include + +#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n)) +#define CPU_16MHz 0x00 + +// I2C aliases and register addresses (see "mcp23018.md") +#define I2C_ADDR 0b0100000 +#define I2C_ADDR_WRITE ( (I2C_ADDR<<1) | I2C_WRITE ) +#define I2C_ADDR_READ ( (I2C_ADDR<<1) | I2C_READ ) +#define IODIRA 0x00 // i/o direction register +#define IODIRB 0x01 +#define GPPUA 0x0C // GPIO pull-up resistor register +#define GPPUB 0x0D +#define GPIOA 0x12 // general purpose i/o port register (write modifies OLAT) +#define GPIOB 0x13 +#define OLATA 0x14 // output latch register +#define OLATB 0x15 + +extern uint8_t mcp23018_status; + +void init_dactyl(void); +uint8_t init_mcp23018(void); + +#define KEYMAP( \ + \ + /* left hand, spatial positions */ \ + k00,k01,k02,k03,k04,k05, \ + k10,k11,k12,k13,k14,k15, \ + k20,k21,k22,k23,k24,k25, \ + k30,k31,k32,k33,k34,k35, \ + k40,k41,k42,k43,k44, \ + k55,k50, \ + k54, \ + k53,k52,k51, \ + \ + /* right hand, spatial positions */ \ + k06,k07,k08,k09,k0A,k0B, \ + k16,k17,k18,k19,k1A,k1B, \ + k26,k27,k28,k29,k2A,k2B, \ + k36,k37,k38,k39,k3A,k3B, \ + k47,k48,k49,k4A,k4B, \ + k5B,k56, \ + k57, \ + k5A,k59,k58 ) \ + \ + /* matrix positions */ \ + { \ + { k00, k10, k20, k30, k40, k50 }, \ + { k01, k11, k21, k31, k41, k51 }, \ + { k02, k12, k22, k32, k42, k52 }, \ + { k03, k13, k23, k33, k43, k53 }, \ + { k04, k14, k24, k34, k44, k54 }, \ + { k05, k15, k25, k35, KC_NO, k55 }, \ + \ + { k06, k16, k26, k36, KC_NO, k56 }, \ + { k07, k17, k27, k37, k47, k57 }, \ + { k08, k18, k28, k38, k48, k58 }, \ + { k09, k19, k29, k39, k49, k59 }, \ + { k0A, k1A, k2A, k3A, k4A, k5A }, \ + { k0B, k1B, k2B, k3B, k4B, k5B } \ + } + + + +#define LAYOUT_dactyl KEYMAP + +#endif diff --git a/keyboards/handwired/dactyl/i2cmaster.h b/keyboards/handwired/dactyl/i2cmaster.h new file mode 100644 index 000000000..3917b9e6c --- /dev/null +++ b/keyboards/handwired/dactyl/i2cmaster.h @@ -0,0 +1,178 @@ +#ifndef _I2CMASTER_H +#define _I2CMASTER_H 1 +/************************************************************************* +* Title: C include file for the I2C master interface +* (i2cmaster.S or twimaster.c) +* Author: Peter Fleury http://jump.to/fleury +* File: $Id: i2cmaster.h,v 1.10 2005/03/06 22:39:57 Peter Exp $ +* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3 +* Target: any AVR device +* Usage: see Doxygen manual +**************************************************************************/ + +#ifdef DOXYGEN +/** + @defgroup pfleury_ic2master I2C Master library + @code #include @endcode + + @brief I2C (TWI) Master Software Library + + Basic routines for communicating with I2C slave devices. This single master + implementation is limited to one bus master on the I2C bus. + + This I2c library is implemented as a compact assembler software implementation of the I2C protocol + which runs on any AVR (i2cmaster.S) and as a TWI hardware interface for all AVR with built-in TWI hardware (twimaster.c). + Since the API for these two implementations is exactly the same, an application can be linked either against the + software I2C implementation or the hardware I2C implementation. + + Use 4.7k pull-up resistor on the SDA and SCL pin. + + Adapt the SCL and SDA port and pin definitions and eventually the delay routine in the module + i2cmaster.S to your target when using the software I2C implementation ! + + Adjust the CPU clock frequence F_CPU in twimaster.c or in the Makfile when using the TWI hardware implementaion. + + @note + The module i2cmaster.S is based on the Atmel Application Note AVR300, corrected and adapted + to GNU assembler and AVR-GCC C call interface. + Replaced the incorrect quarter period delays found in AVR300 with + half period delays. + + @author Peter Fleury pfleury@gmx.ch http://jump.to/fleury + + @par API Usage Example + The following code shows typical usage of this library, see example test_i2cmaster.c + + @code + + #include + + + #define Dev24C02 0xA2 // device address of EEPROM 24C02, see datasheet + + int main(void) + { + unsigned char ret; + + i2c_init(); // initialize I2C library + + // write 0x75 to EEPROM address 5 (Byte Write) + i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode + i2c_write(0x05); // write address = 5 + i2c_write(0x75); // write value 0x75 to EEPROM + i2c_stop(); // set stop conditon = release bus + + + // read previously written value back from EEPROM address 5 + i2c_start_wait(Dev24C02+I2C_WRITE); // set device address and write mode + + i2c_write(0x05); // write address = 5 + i2c_rep_start(Dev24C02+I2C_READ); // set device address and read mode + + ret = i2c_readNak(); // read one byte from EEPROM + i2c_stop(); + + for(;;); + } + @endcode + +*/ +#endif /* DOXYGEN */ + +/**@{*/ + +#if (__GNUC__ * 100 + __GNUC_MINOR__) < 304 +#error "This library requires AVR-GCC 3.4 or later, update to newer AVR-GCC compiler !" +#endif + +#include + +/** defines the data direction (reading from I2C device) in i2c_start(),i2c_rep_start() */ +#define I2C_READ 1 + +/** defines the data direction (writing to I2C device) in i2c_start(),i2c_rep_start() */ +#define I2C_WRITE 0 + + +/** + @brief initialize the I2C master interace. Need to be called only once + @param void + @return none + */ +extern void i2c_init(void); + + +/** + @brief Terminates the data transfer and releases the I2C bus + @param void + @return none + */ +extern void i2c_stop(void); + + +/** + @brief Issues a start condition and sends address and transfer direction + + @param addr address and transfer direction of I2C device + @retval 0 device accessible + @retval 1 failed to access device + */ +extern unsigned char i2c_start(unsigned char addr); + + +/** + @brief Issues a repeated start condition and sends address and transfer direction + + @param addr address and transfer direction of I2C device + @retval 0 device accessible + @retval 1 failed to access device + */ +extern unsigned char i2c_rep_start(unsigned char addr); + + +/** + @brief Issues a start condition and sends address and transfer direction + + If device is busy, use ack polling to wait until device ready + @param addr address and transfer direction of I2C device + @return none + */ +extern void i2c_start_wait(unsigned char addr); + + +/** + @brief Send one byte to I2C device + @param data byte to be transfered + @retval 0 write successful + @retval 1 write failed + */ +extern unsigned char i2c_write(unsigned char data); + + +/** + @brief read one byte from the I2C device, request more data from device + @return byte read from I2C device + */ +extern unsigned char i2c_readAck(void); + +/** + @brief read one byte from the I2C device, read is followed by a stop condition + @return byte read from I2C device + */ +extern unsigned char i2c_readNak(void); + +/** + @brief read one byte from the I2C device + + Implemented as a macro, which calls either i2c_readAck or i2c_readNak + + @param ack 1 send ack, request more data from device
+ 0 send nak, read is followed by a stop condition + @return byte read from I2C device + */ +extern unsigned char i2c_read(unsigned char ack); +#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); + + +/**@}*/ +#endif diff --git a/keyboards/handwired/dactyl/keymaps/default/keymap.c b/keyboards/handwired/dactyl/keymaps/default/keymap.c new file mode 100644 index 000000000..0d414d85b --- /dev/null +++ b/keyboards/handwired/dactyl/keymaps/default/keymap.c @@ -0,0 +1,183 @@ +#include "dactyl.h" +#include "debug.h" +#include "action_layer.h" +#include "version.h" + +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media keys + +enum custom_keycodes { + PLACEHOLDER = SAFE_RANGE, // ensure these codes start after the highest keycode defined in Quantum + VRSN, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,-----------------------------------------. ,-----------------------------------------. + * | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | Del | Q | W | E | R | T | | Y | U | I | O | P | \ | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | BkSp | A | S | D | F | G | | H | J | K | L |; / L2|'/Cmd | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * |LShift|Z/Ctrl| X | C | V | B | | N | M | , | . |//Ctrl|RShift| + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | App | LGui | | Alt | ^/Esc| + * ,------|------|------| |------+------+------. + * | | | Home | | PgUp | | | + * | Space|Backsp|------| |------| Tab |Enter | + * | |ace | End | | PgDn | | | + * `--------------------' `--------------------' + */ +[BASE] = LAYOUT_dactyl( // layer 0 : default + // left hand + KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, + KC_DELT, KC_Q, KC_W, KC_E, KC_R, KC_T, + KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G, + KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, + LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT, KC_RGHT, + ALT_T(KC_APP), KC_LGUI, + KC_HOME, + KC_SPC, KC_BSPC, KC_END, + // right hand + KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, + KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN), GUI_T(KC_QUOT), + KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH), KC_RSFT, + KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, KC_FN1, + KC_RALT, CTL_T(KC_ESC), + KC_PGUP, + KC_PGDN, KC_TAB, KC_ENT + ), +/* Keymap 1: Symbol Layer + * + * ,-----------------------------------------. ,-----------------------------------------. + * |Versn | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | ! | @ | { | } | | | | Up | 7 | 8 | 9 | * | F12 | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | # | $ | ( | ) | ` | | Down | 4 | 5 | 6 | + | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | % | ^ | [ | ] | ~ | | & | 1 | 2 | 3 | \ | | + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * |RESET | | | | | | | . | 0 | = | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = LAYOUT_dactyl( + // left hand + VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, + KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, + KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, + KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, + RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, + KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, + KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +/* Keymap 2: Media and mouse keys + * ,-----------------------------------------. ,-----------------------------------------. + * | | | | | | | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | | | MsUp | | | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | |MsLeft|MsDown|MsRght| | | | | | | | Play | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | | | | | | | | | Prev | Next | | | + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * | | | | Lclk | Rclk | | VolUp| VolDn| Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | |Brwser| + * | | |------| |------| |Back | + * | | | | | | | | + * `--------------------' `--------------------' + * + */ +// MEDIA AND MOUSE +[MDIA] = LAYOUT_dactyl( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + 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_MPLY, + KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, + KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_WBAK +), +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + break; + case 1: + if (record->event.pressed) { // For resetting EEPROM + eeconfig_init(); + } + break; + } + return MACRO_NONE; +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case VRSN: + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + return false; + break; + } + return true; +} + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) {}; diff --git a/keyboards/handwired/dactyl/keymaps/default/readme.md b/keyboards/handwired/dactyl/keymaps/default/readme.md new file mode 100644 index 000000000..e393e396e --- /dev/null +++ b/keyboards/handwired/dactyl/keymaps/default/readme.md @@ -0,0 +1,10 @@ +# Dactyl Default Configuration + +## Changelog + +* Nov 2017: + * Copied and adapted from the Ergodox EZ equivalent + * Notable differences: + - Don't try to have the columns that don't exist, naturally + - Removed RGB keys, since there are no RGB LEDs in the Dactyl (as designed, at least) + diff --git a/keyboards/handwired/dactyl/keymaps/dvorak/keymap.c b/keyboards/handwired/dactyl/keymaps/dvorak/keymap.c new file mode 100644 index 000000000..a0b98b993 --- /dev/null +++ b/keyboards/handwired/dactyl/keymaps/dvorak/keymap.c @@ -0,0 +1,183 @@ +#include "dactyl.h" +#include "debug.h" +#include "action_layer.h" +#include "version.h" + +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media keys + +enum custom_keycodes { + PLACEHOLDER = SAFE_RANGE, // ensure these codes start after the highest keycode defined in Quantum + VRSN, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,-----------------------------------------. ,-----------------------------------------. + * | = | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | Del | '" | , | . | P | Y | | F | G | C | R | L | \ | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | BkSp | A | O | E | U | I | | D | H | T | N | S/L2 |//Cmd | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * |LShift|;/Ctrl| Q | J | K | X | | B | M | W | V |Z/Ctrl|RShift| + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * |Grv/L1| = |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | App | LGui | | Alt | ^/Esc| + * ,------|------|------| |------+------+------. + * | | | Home | | PgUp | | | + * | Space|Backsp|------| |------| Tab |Enter | + * | |ace | End | | PgDn | | | + * `--------------------' `--------------------' + */ +[BASE] = LAYOUT_dactyl( // layer 0 : default + // left hand + KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, + KC_DELT, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, + KC_BSPC, KC_A, KC_O, KC_E, KC_U, KC_I, + KC_LSFT, CTL_T(KC_SCLN), KC_Q, KC_J, KC_K, KC_X, + LT(SYMB,KC_GRV), KC_EQL, LALT(KC_LSFT), KC_LEFT, KC_RGHT, + ALT_T(KC_APP), KC_LGUI, + KC_HOME, + KC_SPC, KC_BSPC, KC_END, + // right hand + KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, + KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSLS, + KC_D, KC_H, KC_T, KC_N, LT(MDIA, KC_S), GUI_T(KC_SLSH), + KC_B, KC_M, KC_W, KC_V, CTL_T(KC_Z), KC_RSFT, + KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, KC_FN1, + KC_RALT, CTL_T(KC_ESC), + KC_PGUP, + KC_PGDN, KC_TAB, KC_ENT + ), +/* Keymap 1: Symbol Layer + * + * ,-----------------------------------------. ,-----------------------------------------. + * |Versn | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | ! | @ | { | } | | | | Up | 7 | 8 | 9 | * | F12 | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | # | $ | ( | ) | ` | | Down | 4 | 5 | 6 | + | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | % | ^ | [ | ] | ~ | | & | 1 | 2 | 3 | \ | | + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * |RESET | | | | | | | . | 0 | = | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[SYMB] = LAYOUT_dactyl( + // left hand + VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, + KC_TRNS, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE, + KC_TRNS, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV, + KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, + RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12, + KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS, + KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS, + KC_TRNS, KC_DOT, KC_0, KC_EQL, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +/* Keymap 2: Media and mouse keys + * ,-----------------------------------------. ,-----------------------------------------. + * | | | | | | | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | | | MsUp | | | | | | | | | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | |MsLeft|MsDown|MsRght| | | | | | | | Play | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | | | | | | | | | Prev | Next | | | + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * | | | | Lclk | Rclk | | VolUp| VolDn| Mute | | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | |Brwser| + * | | |------| |------| |Back | + * | | | | | | | | + * `--------------------' `--------------------' + * + */ +// MEDIA AND MOUSE +[MDIA] = LAYOUT_dactyl( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + 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_MPLY, + KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, + KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_WBAK +), +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + break; + case 1: + if (record->event.pressed) { // For resetting EEPROM + eeconfig_init(); + } + break; + } + return MACRO_NONE; +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case VRSN: + if (record->event.pressed) { + SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION); + } + return false; + break; + } + return true; +} + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) {}; diff --git a/keyboards/handwired/dactyl/keymaps/dvorak/readme.md b/keyboards/handwired/dactyl/keymaps/dvorak/readme.md new file mode 100644 index 000000000..42ec3cd4f --- /dev/null +++ b/keyboards/handwired/dactyl/keymaps/dvorak/readme.md @@ -0,0 +1,9 @@ +# Dactyl Dvorak keymap + +Modifiers and layers 1+ are the same as in the default layout. +Only the layer-0 dvorak-relevant keys are different. + +## Changelog + +* Nov 2017: + * Copied and adapted from the default keymap. diff --git a/keyboards/handwired/dactyl/keymaps/erincalling/keymap.c b/keyboards/handwired/dactyl/keymaps/erincalling/keymap.c new file mode 100644 index 000000000..d22d138a0 --- /dev/null +++ b/keyboards/handwired/dactyl/keymaps/erincalling/keymap.c @@ -0,0 +1,162 @@ +#include "dactyl.h" +#include "debug.h" +#include "action_layer.h" +#include "version.h" + +#define BASE 0 // default layer +#define CONT 1 // control layer +#define QWER 2 // qwerty layer + +enum custom_keycodes { + PLACEHOLDER = SAFE_RANGE, // ensure these codes start after the highest keycode defined in Quantum + COLON_EQ, +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Keymap 0: Basic layer + * + * ,-----------------------------------------. ,-----------------------------------------. + * | Esc | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | \ | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | Tab | '" | , | . | P | Y | | F | G | C | R | L | / | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | := | A | O | E | U | I | | D | H | T | N | S | - | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * |LShift| ; | Q | J | K | X | | B | M | W | V | Z |RShift| + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * | Home | ` | = | Left | Right| | Up | Down | [ | ] | End | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | LCtl | LAlt | | RCtl | Ralt | + * ,------|------|------| |------+------+------. + * | | | L1 | | L1 | | | + * | Back |Delete|------| |------|Enter |Space | + * |Space | | LGui | | RGui | | | + * `--------------------' `--------------------' + */ +[BASE] = LAYOUT_dactyl( // layer 0 : default + // left hand + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, + KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, + COLON_EQ, KC_A, KC_O, KC_E, KC_U, KC_I, + KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, + KC_HOME, KC_GRV, KC_EQL, KC_LEFT, KC_RGHT, + KC_LCTRL, KC_LALT, + MO(CONT), + KC_BSPC, KC_DEL, KC_LGUI, + // right hand + KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, + KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH, + KC_D, KC_H, KC_T, KC_N, KC_S, KC_MINS, + KC_B, KC_M, KC_W, KC_V, KC_Z, KC_RSFT, + KC_UP, KC_DOWN, KC_LBRC, KC_RBRC, KC_END, + KC_RALT, KC_RCTL, + MO(CONT), + KC_RGUI, KC_ENT, KC_SPACE + ), +/* Keymap 1: Control layer (media keys, Fkeys, numpad) + * + * ,-----------------------------------------. ,-----------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | RESET| + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | | Mute | VolD | VolU | | | | 7 | 8 | 9 | + | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | | Prev |PPause| Next | | | | 4 | 5 | 6 | = | | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | | | | | | | | 1 | 2 | 3 | , | | + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * |PageUp| | | | | | 0 | 0 | . | |PageDn| + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + */ +// SYMBOLS +[CONT] = LAYOUT_dactyl( + // left hand + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, + KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, + TG(QWER), KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_PGUP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, RESET, + KC_TRNS, KC_7, KC_8, KC_9, KC_KP_PLUS, KC_TRNS, + KC_TRNS, KC_4, KC_5, KC_6, KC_EQL, KC_TRNS, + KC_TRNS, KC_1, KC_2, KC_3, KC_COMM, KC_TRNS, + KC_0, KC_0, KC_DOT, KC_TRNS, KC_PGDN, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +/* Keymap 2: QWERTY overlay + * ,-----------------------------------------. ,-----------------------------------------. + * | | | | | | | | | | | | | [ | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | Q | W | E | R | T | | Y | U | I | O | P | ] | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | A | S | D | F | G | | H | J | K | L | ; | '" | + * |------+------+------+------+------+------| |------+------+------+------+------+------| + * | | Z | X | C | V | B | | N | M | , | . | / | | + * |------+------+------+------+------+------' `------+------+------+------+------+------| + * | | | | | | | | | - | \ | | + * `----------------------------------' `----------------------------------' + * ,-------------. ,-------------. + * | | | | | | + * ,------|------|------| |------+------+------. + * | | | | | | | | + * | | |------| |------| | | + * | | | | | | | | + * `--------------------' `--------------------' + * + */ +// QWERTY +[QWER] = LAYOUT_dactyl( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_Q, KC_W, KC_E, KC_R, KC_T, + KC_TRNS, KC_A, KC_S, KC_D, KC_F, KC_G, + KC_TRNS, KC_Z, KC_X, KC_C, KC_V, KC_B, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LBRC, + KC_Y, KC_U, KC_I, KC_O, KC_P, KC_RBRC, + KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, + KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_TRNS, + KC_TRNS, KC_TRNS, KC_MINS, KC_BSLS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch(keycode) { + case COLON_EQ: + SEND_STRING(":="); + return false; + break; + } + } + + return true; +} + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) {}; diff --git a/keyboards/handwired/dactyl/keymaps/erincalling/readme.md b/keyboards/handwired/dactyl/keymaps/erincalling/readme.md new file mode 100644 index 000000000..7528ed07e --- /dev/null +++ b/keyboards/handwired/dactyl/keymaps/erincalling/readme.md @@ -0,0 +1,6 @@ +# Erincalling Dactyl keymap + +## Changelog + +* Nov 2017: + * Ported and adapted from the ergodox-firmware layout I'd been using diff --git a/keyboards/handwired/dactyl/matrix.c b/keyboards/handwired/dactyl/matrix.c new file mode 100644 index 000000000..0626f93d7 --- /dev/null +++ b/keyboards/handwired/dactyl/matrix.c @@ -0,0 +1,393 @@ +/* + +Copyright 2013 Oleg Kostyuk +Copyright 2017 Erin Call + +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 . +*/ + +/* + * scan matrix + */ +#include +#include +#include +#include "wait.h" +#include "action_layer.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" +#include "dactyl.h" +#include "i2cmaster.h" +#ifdef DEBUG_MATRIX_SCAN_RATE +#include "timer.h" +#endif + +/* + * This constant define not debouncing time in msecs, but amount of matrix + * scan loops which should be made to get stable debounced results. + * + * On the Dactyl, the matrix scan rate is relatively low, because + * communicating with the left hand's I/O expander is slower than simply + * selecting local pins. + * Now it's only 317 scans/second, or about 3.15 msec/scan. + * According to Cherry specs, debouncing time is 5 msec. + * + * And so, there is no sense to have DEBOUNCE higher than 2. + */ + +#ifndef DEBOUNCE +# define DEBOUNCE 5 +#endif + +/* matrix state(1:on, 0:off) */ +static matrix_row_t matrix[MATRIX_ROWS]; + +// Debouncing: store for each key the number of scans until it's eligible to +// change. When scanning the matrix, ignore any changes in keys that have +// already changed in the last DEBOUNCE scans. +static uint8_t debounce_matrix[MATRIX_ROWS * MATRIX_COLS]; + +static matrix_row_t read_cols(uint8_t row); +static void init_cols(void); +static void unselect_rows(void); +static void select_row(uint8_t row); + +static uint8_t mcp23018_reset_loop; + +#ifdef DEBUG_MATRIX_SCAN_RATE +uint32_t matrix_timer; +uint32_t matrix_scan_count; +#endif + + +__attribute__ ((weak)) +void matrix_init_user(void) {} + +__attribute__ ((weak)) +void matrix_scan_user(void) {} + +__attribute__ ((weak)) +void matrix_init_kb(void) { + matrix_init_user(); +} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +void matrix_init(void) +{ + // initialize row and col + + mcp23018_status = init_mcp23018(); + + + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + for (uint8_t j=0; j < MATRIX_COLS; ++j) { + debounce_matrix[i * MATRIX_COLS + j] = 0; + } + } + +#ifdef DEBUG_MATRIX_SCAN_RATE + matrix_timer = timer_read32(); + matrix_scan_count = 0; +#endif + + matrix_init_quantum(); + +} + +void matrix_power_up(void) { + mcp23018_status = init_mcp23018(); + + unselect_rows(); + init_cols(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + } + +#ifdef DEBUG_MATRIX_SCAN_RATE + matrix_timer = timer_read32(); + matrix_scan_count = 0; +#endif +} + +// Returns a matrix_row_t whose bits are set if the corresponding key should be +// eligible to change in this scan. +matrix_row_t debounce_mask(uint8_t row) { + matrix_row_t result = 0; + for (uint8_t j=0; j < MATRIX_COLS; ++j) { + if (debounce_matrix[row * MATRIX_COLS + j]) { + --debounce_matrix[row * MATRIX_COLS + j]; + } else { + result |= (1 << j); + } + } + return result; +} + +// Report changed keys in the given row. Resets the debounce countdowns +// corresponding to each set bit in 'change' to DEBOUNCE. +void debounce_report(matrix_row_t change, uint8_t row) { + for (uint8_t i = 0; i < MATRIX_COLS; ++i) { + if (change & (1 << i)) { + debounce_matrix[row * MATRIX_COLS + i] = DEBOUNCE; + } + } +} + +uint8_t matrix_scan(void) +{ + if (mcp23018_status) { // if there was an error + if (++mcp23018_reset_loop == 0) { + // since mcp23018_reset_loop is 8 bit - we'll try to reset once in 255 matrix scans + // this will be approx bit more frequent than once per second + print("trying to reset mcp23018\n"); + mcp23018_status = init_mcp23018(); + if (mcp23018_status) { + print("left side not responding\n"); + } else { + print("left side attached\n"); + } + } + } + +#ifdef DEBUG_MATRIX_SCAN_RATE + matrix_scan_count++; + + uint32_t timer_now = timer_read32(); + if (TIMER_DIFF_32(timer_now, matrix_timer)>1000) { + print("matrix scan frequency: "); + pdec(matrix_scan_count); + print("\n"); + + matrix_timer = timer_now; + matrix_scan_count = 0; + } +#endif + + for (uint8_t i = 0; i < MATRIX_ROWS; i++) { + select_row(i); + wait_us(30); // without this wait read unstable value. + matrix_row_t mask = debounce_mask(i); + matrix_row_t cols = (read_cols(i) & mask) | (matrix[i] & ~mask); + debounce_report(cols ^ matrix[i], i); + matrix[i] = cols; + + unselect_rows(); + } + + matrix_scan_quantum(); + + return 1; +} + +bool matrix_is_modified(void) // deprecated and evidently not called. +{ + return true; +} + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1<`, for example `make handwired/dactyl:default` + - This will result in a hex file called `handwired_dactyl_.hex`, e.g. + `handwired_dactyl_default.hex` + + - Start the teensy loader. + + - Load the .hex file into it. + + - Put the Teensy in firmware-loading mode: + * If your current layout has a RESET key, press it. + * If you lack a RESET key, press the reset button on the Teensy board itself. + + - Click the button in the Teensy app to download the firmware. + +To flash with ´teensy-loader-cli´: + + - Build the firmware as above + + - Run `teensy_loader_cli -mmcu=atmega32u4 -w handwired_dactyl_.hex` + + - If you like, you can do both at once: `make handwired/dactyl::teensy` + + - Put the Teensy in firmware-loading mode: + * If your current layout has a RESET key, press it. + * If you lack a RESET key, press the reset button on the Teensy board itself. diff --git a/keyboards/handwired/dactyl/rules.mk b/keyboards/handwired/dactyl/rules.mk new file mode 100644 index 000000000..90a29bd2d --- /dev/null +++ b/keyboards/handwired/dactyl/rules.mk @@ -0,0 +1,86 @@ +#---------------------------------------------------------------------------- +# On command line: +# +# make = Make software. +# +# make clean = Clean out built project files. +# +# That's pretty much all you need. To compile, always go make clean, +# followed by make. +# +# For advanced users only: +# make teensy = Download the hex file to the device, using teensy_loader_cli. +# (must have teensy_loader_cli installed). +# +#---------------------------------------------------------------------------- + +# # project specific files +SRC = twimaster.c \ + matrix.c + +# MCU name +MCU = atmega32u4 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=512 + + +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MIDI_ENABLE = no # MIDI support (+2400 to 4200) +POINTING_DEVICE_ENABLE = no +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+8000) +COMMAND_ENABLE = no # Commands for debug and configuration +CUSTOM_MATRIX = yes # Custom matrix file for the Dactyl +NKRO_ENABLE = yes # USB Nkey Rollover +UNICODE_ENABLE = yes # Unicode +ONEHAND_ENABLE = yes # Allow swapping hands of keyboard +SLEEP_LED_ENABLE = no +API_SYSEX_ENABLE = no +RGBLIGHT_ENABLE = no diff --git a/keyboards/handwired/dactyl/twimaster.c b/keyboards/handwired/dactyl/twimaster.c new file mode 100644 index 000000000..2557f7e22 --- /dev/null +++ b/keyboards/handwired/dactyl/twimaster.c @@ -0,0 +1,207 @@ +/************************************************************************* +* Title: I2C master library using hardware TWI interface +* Author: Peter Fleury http://jump.to/fleury +* File: $Id: twimaster.c,v 1.3 2005/07/02 11:14:21 Peter Exp $ +* Software: AVR-GCC 3.4.3 / avr-libc 1.2.3 +* Target: any AVR device with hardware TWI +* Usage: API compatible with I2C Software Library i2cmaster.h +**************************************************************************/ +#include +#include + +#include + +/* define CPU frequency in Hz here if not defined in Makefile */ +#ifndef F_CPU +#define F_CPU 16000000UL +#endif + +/* I2C clock in Hz */ +#define SCL_CLOCK 400000L + + +/************************************************************************* + Initialization of the I2C bus interface. Need to be called only once +*************************************************************************/ +void i2c_init(void) +{ + /* initialize TWI clock + * minimal values in Bit Rate Register (TWBR) and minimal Prescaler + * bits in the TWI Status Register should give us maximal possible + * I2C bus speed - about 444 kHz + * + * for more details, see 20.5.2 in ATmega16/32 secification + */ + + TWSR = 0; /* no prescaler */ + TWBR = 10; /* must be >= 10 for stable operation */ + +}/* i2c_init */ + + +/************************************************************************* + Issues a start condition and sends address and transfer direction. + return 0 = device accessible, 1= failed to access device +*************************************************************************/ +unsigned char i2c_start(unsigned char address) +{ + uint8_t twst; + + // send START condition + TWCR = (1<event.pressed) { - layer_on(_MOVE); - update_tri_layer(_MOVE, _SYMB, _MORE); - } else { - layer_off(_MOVE); - update_tri_layer(_MOVE, _SYMB, _MORE); + #ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_SONG(colemak_song); + #endif + set_single_persistent_default_layer(_COLEMAK); + } + return false; + break; + case QWERTY: + if (record->event.pressed) { + #ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_SONG(qwerty_song); + #endif + set_single_persistent_default_layer(_QWERTY); } return false; break; case SYMB: if (record->event.pressed) { layer_on(_SYMB); - update_tri_layer(_MOVE, _SYMB, _MORE); } else { layer_off(_SYMB); - update_tri_layer(_MOVE, _SYMB, _MORE); + } + return false; + break; + case MOVE: + if (record->event.pressed) { + layer_on(_MOVE); + } else { + layer_off(_MOVE); } return false; break; diff --git a/keyboards/planck/keymaps/callum/readme.md b/keyboards/planck/keymaps/callum/readme.md index d5a689b8f..176211cd4 100644 --- a/keyboards/planck/keymaps/callum/readme.md +++ b/keyboards/planck/keymaps/callum/readme.md @@ -4,8 +4,8 @@ This is a layout for the grid planck, built with a few ideals in mind: - Consistent and minimal response times should be maintained. Keys that react differently depending on whether they are tapped or held, keys that react - differently if they are double tapped, etc. should be avoided – they - inevitably send their keycode later than a normal key – interrupting the + differently if they are double tapped, etc. should be avoided -- they + inevitably send their keycode later than a normal key -- interrupting the immediate feedback from the screen. Therefore we restrict ourselves to chording as our only means of getting more than one symbol out of a single physical key. @@ -17,70 +17,68 @@ This is a layout for the grid planck, built with a few ideals in mind: - There should be two of every modifier (one on each side), otherwise certain long key combinations become hard to make. -We have five layers. A `BASE` layer, in colemak; a `MOVE` layer, with an arrow -cluster, other movement keys, and hotkeys; a `SYMB` layer, with numbers and -symbols; a `FUNC` layer, with function keys and media keys; and a `MORE` layer, -with stuff that doesn’t fit anywhere else. The `MORE` layer is activated by -holding the Move and Symb keys simultaniously. +Keys are arranged as follows. Blank keys below may actually contain +undocumented shortcuts specific to my workflow. The base layer can be set to +colemak or qwerty (from the function layer). ``` -/* BASE - * ,-----------------------------------------------------------------------------------. - * | Tab | Q | W | F | P | G | J | L | U | Y | ; | - | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | Bksp | A | R | S | T | D | H | N | E | I | O | ' | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | Shift| Z | X | C | V | B | K | M | , | . | / | Shift| - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | Func | Ctrl | Alt | Cmd | Symb | Enter| Space| Move | Cmd | Alt | Ctrl | Func | - * `-----------------------------------------------------------------------------------' +/* COLEMAK + * ,-----------------------------------------------------------------------. + * |Tab | Q | W | F | P | G | J | L | U | Y | ; | - | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * |Bksp | A | R | S | T | D | H | N | E | I | O | ' | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * |Shift| Z | X | C | V | B | K | M | , | . | / |Shift| + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * |FUNC |Super| Alt |Ctrl |SYMB |Enter|Space|MOVE |Ctrl | Alt |Super|FUNC | + * `-----------------------------------------------------------------------' */ -/* MOVE - * ,-----------------------------------------------------------------------------------. - * | H(F7)| H(F8)| H(6) | H(5) | H(4) | H(F9)|H(F10)| Home | Up | End | H(A) | Esc | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | H(F3)| H(F4)| H(3) | H(2) | H(1) | H(F5)| H(F6)| Left | Down | Right| Caps | Del | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | H(0) | H(9) | H(8) | H(7) | H(F1)| H(F2)| Pg Dn| Pg Up|H(F11)|H(F12)| | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | | | | | | | | | | | | - * `-----------------------------------------------------------------------------------' +/* QWERTY + * ,-----------------------------------------------------------------------. + * |Tab | Q | W | E | R | T | Y | U | I | O | P | - | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * |Bksp | A | S | D | F | G | H | J | K | L | ; | ' | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * |Shift| Z | X | C | V | B | N | M | , | . | / |Shift| + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * |FUNC |Super| Alt |Ctrl |SYMB |Enter|Space|MOVE |Ctrl | Alt |Super|FUNC | + * `-----------------------------------------------------------------------' */ /* SYMB - * ,-----------------------------------------------------------------------------------. - * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | – | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | Del | ! | @ | # | $ | % | ^ | & | * | ( | ) | ’ | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | ~ | ` | + | = | | | \ | [ | ] | { | } | | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | | | | | | | | | | | | - * `-----------------------------------------------------------------------------------' + * ,-----------------------------------------------------------------------. + * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | Del | ! | @ | # | $ | % | ^ | & | * | ( | ) | | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | | ~ | ` | + | = | | | \ | [ | ] | { | } | | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | | | | | | | | | | | | | + * `-----------------------------------------------------------------------' */ -/* MORE - * ,-----------------------------------------------------------------------------------. - * | | | | | | | | | | | | | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | | | | £ | | | | | | | | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | | | | | | | “ | ” | ‘ | ’ | | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | | | | | | | | | | | | - * `-----------------------------------------------------------------------------------' +/* MOVE + * ,-----------------------------------------------------------------------. + * | | | | | | | |Home | Up | End | | Esc | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | | | | | | | |Left |Down |Right|Caps | Del | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | | | | | | | |PgDn |PgUp | | | | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | | | | | | | | | | | | | + * `-----------------------------------------------------------------------' */ /* FUNC - * ,-----------------------------------------------------------------------------------. - * | Reset| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | Vol+ | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | Power| F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 | Vol- | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | F21 | F22 | F23 | F24 | | | | | | | | - * |------+------+------+------+------+------+------+------+------+------+------+------| - * | | | | | Prev | Mute | Play | Next | | | | | - * `-----------------------------------------------------------------------------------' + * ,-----------------------------------------------------------------------. + * |Reset| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 |VolUp| + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * |Power| F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 |VolDn| + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | | F21 | F22 | F23 | F24 | | | | |COLMK|QWRTY| | + * |-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----| + * | | | | |Prev |Mute |Play |Next | | | | | + * `-----------------------------------------------------------------------' */ -``` + ``` diff --git a/keyboards/planck/keymaps/callum/rules.mk b/keyboards/planck/keymaps/callum/rules.mk index 1d76966a6..8ee9a45ab 100644 --- a/keyboards/planck/keymaps/callum/rules.mk +++ b/keyboards/planck/keymaps/callum/rules.mk @@ -1,18 +1,16 @@ - - # Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = yes # Mouse keys(+4700) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = no # Console for debug(+400) COMMAND_ENABLE = yes # Commands for debug and configuration NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 +AUDIO_ENABLE = yes # Audio output on port C6 UNICODE_ENABLE = no # Unicode BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. diff --git a/keyboards/satan/keymaps/addcninblue/keymap.c b/keyboards/satan/keymaps/addcninblue/keymap.c new file mode 100644 index 000000000..9034d04d5 --- /dev/null +++ b/keyboards/satan/keymaps/addcninblue/keymap.c @@ -0,0 +1,196 @@ +#include "satan.h" +#include "rgblight.h" + +#define _DEFAULT 0 +#define _FN 1 +#define _VIM 10 +#define _VIM_SHIFT 11 +#define _VIM_CONTROL 12 + +enum custom_keycodes { + DYNAMIC_MACRO_RANGE = SAFE_RANGE, + a_MACRO, + A_MACRO, + I_MACRO, + O_MACRO, +}; + +#define KC_PREV_WORD LCTL(KC_LEFT) +#define KC_NEXT_WORD LCTL(KC_RIGHT) +#define KC_UNDO LCTL(KC_Z) +#define KC_CUT LCTL(KC_X) +#define KC_COPY LCTL(KC_C) +#define KC_PASTE LCTL(KC_V) + +#include "dynamic_macro.h" + +static uint8_t old_layer = 0; + +// Fillers to make layering more clear +#define ______ KC_TRNS +#define XXXXXX KC_NO + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* Qwerty gui/alt/space/alt/gui + * ,-----------------------------------------------------------------------------------------. + * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` | + * |-----------------------------------------------------------------------------------------+ + * | Tab | Q | W | E | R | T | Y | U | I | O | P | [ | ] | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | A | S | D | F | G | H | J | K | L | ; | ' | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | Z | X | C | V | B | N | M | , | . | / | RShift | VIM | + * |-----------------------------------------------------------------------------------------+ + * | FN | LAlt | Space | RAlt |RGUI | + * `-----------------------------------------------------------------' + */ + [_DEFAULT] = KEYMAP_HHKB( /* Basic QWERTY */ + KC_GESC , 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_BSLS , KC_GRV , \ + KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_LBRC , KC_RBRC , KC_BSPC , \ + KC_LCTL , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN , KC_QUOT , KC_ENT , \ + KC_LSFT , KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM , KC_DOT , KC_SLSH , KC_RSFT , TO(_VIM) , \ + ______ , MO(_FN) , KC_LALT , KC_SPC , KC_RALT , KC_RGUI , ______ , ______ \ + ), + +/* FN Layer + * ,-----------------------------------------------------------------------------------------. + * |GRAVE| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | Ins | Del | + * |-----------------------------------------------------------------------------------------+ + * | CAPS | Vol-| Mute| Vol+|MAC+ |MAC |MAC- | PgUp| Home| |Print| Up | | Del | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | End | | PgDn| | | Left| Down| Up |Right| Left|Right| Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | Prev| Play| Next| BL- | BL | BL+ | | | | Down| RShift | DEF | + * |-----------------------------------------------------------------------------------------+ + * | | LAlt | Space | RAlt | Reset | + * `-----------------------------------------------------------------' + */ + [_FN] = KEYMAP_HHKB( /* Layer 2 */ + KC_GRAVE , 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_INS , KC_DEL , \ + KC_CAPS , KC_VOLD , KC_MUTE , KC_VOLU , DYN_REC_START1 , DYN_MACRO_PLAY1 , DYN_REC_STOP , KC_PGUP , KC_HOME , ______ , KC_PSCR , KC_UP , ______ , KC_DEL , \ + KC_LCTL , KC_END , ______ , KC_PGDN , ______ , ______ , KC_LEFT , KC_DOWN , KC_UP , KC_RIGHT , KC_LEFT , KC_RGHT , KC_ENT , \ + KC_LSFT , KC_MPRV , KC_MPLY , KC_MNXT , BL_DEC , BL_TOGG , BL_INC , ______ , ______ , ______ , KC_DOWN , KC_RSFT , TO(_DEFAULT) , \ + ______ , ______ , KC_LALT , KC_SPC , KC_RALT , RESET , ______ , ______ \ + ), + +/* VIM Layer + * ,-----------------------------------------------------------------------------------------. + * | DEF | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` | + * |-----------------------------------------------------------------------------------------+ + * | | | WORD| WORD| | | COPY| UNDO| DEF |ENTER|PASTE| | | Del | + * |-----------------------------------------------------------------------------------------+ + * | V_Ctrl |a_ins| | | | | Left| Down| Up |Right| | | Enter | + * |-----------------------------------------------------------------------------------------+ + * | V_Shift | | | | | PREV| | | | | | RShift | Def | + * |-----------------------------------------------------------------------------------------+ + * | | LAlt | Space | RAlt | | + * `-----------------------------------------------------------------' + */ + [_VIM] = KEYMAP_HHKB( /* Layer 10 */ + TO(_DEFAULT) , 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_BSLS , KC_GRV , \ + XXXXXX , XXXXXX , KC_NEXT_WORD , KC_NEXT_WORD , XXXXXX , XXXXXX , KC_COPY , KC_UNDO , TO(_DEFAULT) , KC_ENTER , KC_PASTE , XXXXXX , XXXXXX , KC_DEL , \ + MO(_VIM_CONTROL) , a_MACRO , XXXXXX , XXXXXX , XXXXXX , XXXXXX , KC_LEFT , KC_DOWN , KC_UP , KC_RIGHT , XXXXXX , XXXXXX , KC_ENTER , \ + MO(_VIM_SHIFT) , XXXXXX , XXXXXX , XXXXXX , XXXXXX , KC_PREV_WORD , XXXXXX , XXXXXX , XXXXXX , XXXXXX , XXXXXX , KC_RSFT , TO(_DEFAULT) , \ + XXXXXX , XXXXXX , KC_LALT , KC_SPC , KC_RALT , XXXXXX , XXXXXX , XXXXXX \ + ), + +/* VIM Layer + * ,-----------------------------------------------------------------------------------------. + * | DEF | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | \ | ` | + * |-----------------------------------------------------------------------------------------+ + * | | | WORD| WORD| | | | |I_ins|ENTER| | | | Del | + * |-----------------------------------------------------------------------------------------+ + * | |A_ins| | | | | Left| Down| Up |Right| | | Enter | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | PREV| | | | | | RShift | Def | + * |-----------------------------------------------------------------------------------------+ + * | | LAlt | Space | RAlt | | + * `-----------------------------------------------------------------' + */ + [_VIM_SHIFT] = KEYMAP_HHKB( /* Layer 11 */ + TO(_DEFAULT) , 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_BSLS , KC_GRV , \ + XXXXXX , XXXXXX , KC_NEXT_WORD , KC_NEXT_WORD , XXXXXX , XXXXXX , XXXXXX , XXXXXX , I_MACRO , O_MACRO , XXXXXX , XXXXXX , XXXXXX , KC_DEL , \ + XXXXXX , A_MACRO , XXXXXX , KC_PGDN , XXXXXX , XXXXXX , KC_LEFT , KC_DOWN , KC_UP , KC_RIGHT , XXXXXX , XXXXXX , KC_ENTER , \ + XXXXXX , XXXXXX , XXXXXX , XXXXXX , XXXXXX , KC_PREV_WORD , XXXXXX , XXXXXX , XXXXXX , XXXXXX , XXXXXX , KC_RSFT , TO(_DEFAULT) , \ + XXXXXX , XXXXXX , KC_LALT , KC_SPC , KC_RALT , RESET , XXXXXX , XXXXXX \ + ), + +/* FN Layer + * ,-----------------------------------------------------------------------------------------. + * | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | Ins | Del | + * |-----------------------------------------------------------------------------------------+ + * | | Vol-| Mute| Vol+| | | | PgUp| Ins | |Print| Up | | Del | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | App | | PgDn| | | Left| Down| Up |Right| Left|Right| Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | Prev| Play| Next| BL- | BL | BL+ | | | | Down| RShift | Def | + * |-----------------------------------------------------------------------------------------+ + * | | LAlt | Space | RAlt | Reset | + * `-----------------------------------------------------------------' + */ + [_VIM_CONTROL] = KEYMAP_HHKB( /* Layer 12 */ + TO(_DEFAULT) , 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_BSLS , KC_GRV , \ + XXXXXX , XXXXXX , KC_NEXT_WORD , KC_NEXT_WORD , XXXXXX , XXXXXX , XXXXXX , XXXXXX , I_MACRO , O_MACRO , XXXXXX , XXXXXX , XXXXXX , KC_DEL , \ + XXXXXX , A_MACRO , XXXXXX , KC_PGDN , XXXXXX , XXXXXX , KC_LEFT , KC_DOWN , KC_UP , KC_RIGHT , XXXXXX , XXXXXX , KC_ENTER , \ + XXXXXX , XXXXXX , XXXXXX , XXXXXX , XXXXXX , KC_PREV_WORD , XXXXXX , XXXXXX , XXXXXX , XXXXXX , XXXXXX , KC_RSFT , TO(_DEFAULT) , \ + XXXXXX , XXXXXX , KC_LALT , KC_SPC , KC_RALT , RESET , XXXXXX , XXXXXX \ + ) , +}; + +void persistent_default_layer_set(uint16_t default_layer) { + eeconfig_update_default_layer(default_layer); + default_layer_set(default_layer); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (!process_record_dynamic_macro(keycode, record)) { + return false; + } + if (record->event.pressed) { + switch(keycode) { + case a_MACRO: + SEND_STRING(SS_TAP(X_RIGHT)); + layer_off(_VIM); + return false; + break; + case A_MACRO: + SEND_STRING(SS_TAP(X_END)); + layer_off(_VIM_SHIFT); + layer_off(_VIM); + return false; + break; + case I_MACRO: + SEND_STRING(SS_TAP(X_HOME)); + layer_off(_VIM_SHIFT); + layer_off(_VIM); + return false; + break; + case O_MACRO: + SEND_STRING(SS_TAP(X_ENTER)); + layer_off(_VIM_SHIFT); + layer_off(_VIM); + return false; + break; + } + } + return true; +} + +void matrix_scan_user(void) { + uint8_t layer = biton32(layer_state); + + if (old_layer != layer) { + switch (layer) { + case _DEFAULT: + case _FN: + backlight_set(1); + break; + case _VIM: + case _VIM_SHIFT: + case _VIM_CONTROL: + backlight_set(4); + break; + } + old_layer = layer; + } +}; diff --git a/keyboards/satan/keymaps/addcninblue/readme.md b/keyboards/satan/keymaps/addcninblue/readme.md new file mode 100644 index 000000000..7e6520534 --- /dev/null +++ b/keyboards/satan/keymaps/addcninblue/readme.md @@ -0,0 +1,13 @@ +# Addcninblue's HHKB-ish Layout + +Inspired by Dbroqua's layout + +[Layer 1](http://www.keyboard-layout-editor.com/#/gists/0e7798cb81c8f76baa5066ec1c34df8e): pretty standard layout. Shift + esc = ~, unlike normal hhkb. +[Layer 2](http://www.keyboard-layout-editor.com/#/gists/096099221ac48d4d0c84a2b859bbb7c0): Vim-like layout. +[Layer Vim](http://www.keyboard-layout-editor.com/#/gists/73b27b51c5e18d7999cc5fa39b4f3389) : vim layout until exit layout + +## Programming Instructions: +Enter into programming mode and run the following command: +``` +$ sudo make satan:addcninblue:dfu +``` diff --git a/keyboards/satan/keymaps/addcninblue/rules.mk b/keyboards/satan/keymaps/addcninblue/rules.mk new file mode 100644 index 000000000..c2937fd57 --- /dev/null +++ b/keyboards/satan/keymaps/addcninblue/rules.mk @@ -0,0 +1,21 @@ +# Build Options +# change to "no" to disable the options, or define them in the Makefile in +# the appropriate keymap folder that will get included automatically +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = yes # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +SLEEP_LED_ENABLE = no # Enables your LED to breathe while your computer is sleeping. +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ # nkro-doesnt-work +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODEMAP_ENABLE = no # This allows sending unicode symbols using X() in your keymap. +UNICODE_ENABLE = no # Unicode +UCIS_ENABLE = no # Keep in mind that not all will work (See WinCompose for details on Windows). +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +API_SYSEX_ENABLE = no # This enables using the Quantum SYSEX API to send strings diff --git a/keyboards/tkc1800/README.md b/keyboards/tkc1800/README.md new file mode 100644 index 000000000..7a0528ce3 --- /dev/null +++ b/keyboards/tkc1800/README.md @@ -0,0 +1,18 @@ +The Key Company TKC1800 +=== + +![TKC1800](https://imgur.com/a/Xlttp) + + +The Key Company TKC1800 is a Cherry 1800 form factor replacement PCB utilizing the AT90USB1286 microcontroller. + +Keyboard Maintainer: [Terry Mathews](https://github.com/TerryMathews/) +Hardware Supported: AT90USB1286 +Hardware Availability: Via GB + + +Make example for this keyboard (after setting up your build environment): + + make tkc1800 + +See [build environment setup](https://docs.qmk.fm/build_environment_setup.html) then the [make instructions](https://docs.qmk.fm/make_instructions.html) for more information. \ No newline at end of file diff --git a/keyboards/tkc1800/config.h b/keyboards/tkc1800/config.h new file mode 100644 index 000000000..cd34ede09 --- /dev/null +++ b/keyboards/tkc1800/config.h @@ -0,0 +1,186 @@ +/* +Copyright 2012 Jun Wako + +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 . +*/ + +#ifndef CONFIG_H +#define CONFIG_H + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0xFEED +#define PRODUCT_ID 0x6060 +#define DEVICE_VER 0x0003 +#define MANUFACTURER The Key Company +#define PRODUCT TKC1800 +#define DESCRIPTION QMK keyboard firmware for TKC1800 + +/* key matrix size */ +#define MATRIX_ROWS 7 +#define MATRIX_COLS 19 + +// ROWS: Top to bottom, COLS: Left to right +/* Row pin configuration +*/ +#define MATRIX_ROW_PINS { F4, F3, F2, F1, F0, E1, E0 } +/* Column pin configuration + */ +#define MATRIX_COL_PINS { A0, A1, A2, A3, A4, A5, A6, A7, C7, C6, C5, C4, C3, C2, C1, C0, F5, F6, F7 } +#define UNUSED_PINS + +/* COL2ROW or ROW2COL */ +#define DIODE_DIRECTION COL2ROW + +// #define BACKLIGHT_PIN B7 +// #define BACKLIGHT_BREATHING +// #define BACKLIGHT_LEVELS 3 + +/* Underlight configuration + */ +#define RGB_DI_PIN D7 +#define RGBLIGHT_ANIMATIONS +#define RGBLED_NUM 30 // Number of LEDs +#define RGBLIGHT_HUE_STEP 5 +#define RGBLIGHT_SAT_STEP 10 +#define RGBLIGHT_VAL_STEP 10 + +/* define if matrix has ghost */ +//#define MATRIX_HAS_GHOST + +/* Set 0 if debouncing isn't needed */ +#define DEBOUNCING_DELAY 5 + +/* 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 + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +//#define FORCE_NKRO + +/* + * Magic Key Options + * + * Magic keys are hotkey commands that allow control over firmware functions of + * the keyboard. They are best used in combination with the HID Listen program, + * found here: https://www.pjrc.com/teensy/hid_listen.html + * + * The options below allow the magic key functionality to be changed. This is + * useful if your keyboard/keypad is missing keys and you want magic key support. + * + */ + +/* key combination for magic key command */ +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) + +/* control how magic key switches layers */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false + +/* override magic key keymap */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM +//#define MAGIC_KEY_HELP1 H +//#define MAGIC_KEY_HELP2 SLASH +//#define MAGIC_KEY_DEBUG D +//#define MAGIC_KEY_DEBUG_MATRIX X +//#define MAGIC_KEY_DEBUG_KBD K +//#define MAGIC_KEY_DEBUG_MOUSE M +//#define MAGIC_KEY_VERSION V +//#define MAGIC_KEY_STATUS S +//#define MAGIC_KEY_CONSOLE C +//#define MAGIC_KEY_LAYER0_ALT1 ESC +//#define MAGIC_KEY_LAYER0_ALT2 GRAVE +//#define MAGIC_KEY_LAYER0 0 +//#define MAGIC_KEY_LAYER1 1 +//#define MAGIC_KEY_LAYER2 2 +//#define MAGIC_KEY_LAYER3 3 +//#define MAGIC_KEY_LAYER4 4 +//#define MAGIC_KEY_LAYER5 5 +//#define MAGIC_KEY_LAYER6 6 +//#define MAGIC_KEY_LAYER7 7 +//#define MAGIC_KEY_LAYER8 8 +//#define MAGIC_KEY_LAYER9 9 +//#define MAGIC_KEY_BOOTLOADER PAUSE +//#define MAGIC_KEY_LOCK CAPS +//#define MAGIC_KEY_EEPROM E +//#define MAGIC_KEY_NKRO N +//#define MAGIC_KEY_SLEEP_LED Z + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +//#define NO_DEBUG + +/* disable print */ +//#define NO_PRINT + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + +/* + * MIDI options + */ + +/* Prevent use of disabled MIDI features in the keymap */ +//#define MIDI_ENABLE_STRICT 1 + +/* enable basic MIDI features: + - MIDI notes can be sent when in Music mode is on +*/ +//#define MIDI_BASIC + +/* enable advanced MIDI features: + - MIDI notes can be added to the keymap + - Octave shift and transpose + - Virtual sustain, portamento, and modulation wheel + - etc. +*/ +//#define MIDI_ADVANCED + +/* override number of MIDI tone keycodes (each octave adds 12 keycodes and allocates 12 bytes) */ +//#define MIDI_TONE_KEYCODE_OCTAVES 1 + +#endif diff --git a/keyboards/tkc1800/keymaps/default/config.h b/keyboards/tkc1800/keymaps/default/config.h new file mode 100644 index 000000000..a3828f7d5 --- /dev/null +++ b/keyboards/tkc1800/keymaps/default/config.h @@ -0,0 +1,24 @@ +/* Copyright 2017 Mathias Andersson + * + * 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 . + */ + +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "../../config.h" + +// place overrides here + +#endif diff --git a/keyboards/tkc1800/keymaps/default/keymap.c b/keyboards/tkc1800/keymaps/default/keymap.c new file mode 100644 index 000000000..1b9f390b2 --- /dev/null +++ b/keyboards/tkc1800/keymaps/default/keymap.c @@ -0,0 +1,85 @@ +/* Copyright 2017 Mathias Andersson + * + * 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 "tkc1800.h" + +#define MODS_SHFT_MASK (MOD_BIT(KC_LSHIFT)|MOD_BIT(KC_RSHIFT)|MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)) +#define MODS_GUI_MASK (MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)) + +// Helpful defines +#define ______ KC_TRNS +#define XXXXXX KC_NO + +#define _DEFAULT 0 +#define _FUNCTION 1 + +//RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap _BL: (Base Layer) Default Layer + * ,-------------------------------------------------------. ,-------------------. + * |Esc| F1| F2| F3| F4| | F5| F6| F7| F8| | F9|F10|F11|F12| |Ins |Home|PgUp|PrSc| + * `-------------------------------------------------------' |-------------------| + * |Del |End |PgDn|ScrL| + * ,-----------------------------------------------------------. |-------------------| + * | ~ | 1 | 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |NumL| / | * |Paus| + * |-----------------------------------------------------------| |-------------------| + * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \ | | 7 | 8 | 9 | - | + * |-----------------------------------------------------------| |-------------------| + * |CAPS | A| S| D| F| G| H| J| K| L| ;| '|Return | | 4 | 5 | 6 | + | + * |-----------------------------------------------------------' |-------------------| + * |Shift | Z| X| C| V| B| N| M| ,| .| /|Shift | Up | 1 | 2 | 3 | Ent| + * |--------------------------------------------------------'----`--------------| | + * |Ctrl|Gui |Alt | Space |Alt |Gui|Ctr|Left |Down|Rght| 0 | . | | + * `---------------------------------------------------------------------------------' + */ + [_DEFAULT] = KEYMAP( + KC_ESC, 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_INS, KC_HOME, KC_PGUP, KC_PSCR, \ + KC_DEL, KC_END, KC_PGDN, KC_SLCK, \ + KC_TILD, 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_BSPC, XXXXXX, KC_NLCK, KC_PSLS, KC_PAST, KC_PAUS, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PMNS, \ + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, XXXXXX, KC_ENT, KC_P4, KC_P5, KC_P6, KC_PPLS, \ + KC_LSFT, XXXXXX, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT,KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT, \ + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, MO(_FUNCTION), KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT, XXXXXX + ), + [_FUNCTION] = KEYMAP( + KC_ESC, 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_INS, KC_HOME, KC_PGUP, KC_PSCR, \ + KC_DEL, KC_END, KC_PGDN, KC_SLCK, \ + KC_TILD, 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_BSPC, XXXXXX, KC_NLCK, KC_PSLS, KC_PAST, KC_PAUS, \ + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_P7, KC_P8, KC_P9, KC_PMNS, \ + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, XXXXXX, KC_ENT, KC_P4, KC_P5, KC_P6, KC_PPLS, \ + KC_LSFT, XXXXXX, RGB_TOG,RGB_MOD,RGB_HUI,RGB_HUD,RGB_SAI,RGB_SAD,RGB_VAI,RGB_VAD, KC_DOT,KC_SLSH, KC_RSFT, KC_UP, KC_P1, KC_P2, KC_P3, KC_PENT, \ + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, ______, KC_RGUI, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT, KC_P0, KC_PDOT, XXXXXX + ), +}; + +// const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {}; + + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { + +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + return true; +} + +void led_set_user(uint8_t usb_led) { + +} \ No newline at end of file diff --git a/keyboards/tkc1800/rules.mk b/keyboards/tkc1800/rules.mk new file mode 100644 index 000000000..1729f648b --- /dev/null +++ b/keyboards/tkc1800/rules.mk @@ -0,0 +1,68 @@ + +# MCU name +MCU = at90usb1286 + +# Processor frequency. +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to +# calculate timings. Do NOT tack on a 'UL' at the end, this will be done +# automatically to create a 32-bit value in your source code. +# +# This will be an integer division of F_USB below, as it is sourced by +# F_USB after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +F_CPU = 16000000 + + +# +# LUFA specific +# +# Target architecture (see library "Board Types" documentation). +ARCH = AVR8 + +# Input clock frequency. +# This will define a symbol, F_USB, in all source code files equal to the +# input clock frequency (before any prescaling is performed) in Hz. This value may +# differ from F_CPU if prescaling is used on the latter, and is required as the +# raw input clock is fed directly to the PLL sections of the AVR for high speed +# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' +# at the end, this will be done automatically to create a 32-bit value in your +# source code. +# +# If no clock division is performed on the input clock inside the AVR (via the +# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. +F_USB = $(F_CPU) + +# Interrupt driven control endpoint task(+60) +OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT + + +# Boot Section Size in *bytes* +# Teensy halfKay 512 +# Teensy++ halfKay 1024 +# Atmel DFU loader 4096 +# LUFA bootloader 4096 +# USBaspLoader 2048 +OPT_DEFS += -DBOOTLOADER_SIZE=4096 + + +# Build Options +# change yes to no to disable +# +BOOTMAGIC_ENABLE ?= yes # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700) +EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450) +CONSOLE_ENABLE ?= yes # Console for debug(+400) +COMMAND_ENABLE ?= yes # 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 ?= yes # USB Nkey Rollover +BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default +RGBLIGHT_ENABLE ?= yes # Enable WS2812 RGB underlight. Do not enable this with audio at the same time. +MIDI_ENABLE ?= no # MIDI controls +UNICODE_ENABLE ?= no # Unicode +BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID +AUDIO_ENABLE ?= no # Audio output on port C6 diff --git a/keyboards/tkc1800/tkc1800.c b/keyboards/tkc1800/tkc1800.c new file mode 100644 index 000000000..bc6676846 --- /dev/null +++ b/keyboards/tkc1800/tkc1800.c @@ -0,0 +1,69 @@ +/* Copyright 2017 Mathias Andersson + * + * 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 "tkc1800.h" +#include "led.h" + +void matrix_init_kb(void) { + // put your keyboard start-up code here + // runs once when the firmware starts up + led_init_ports(); + 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_init_ports(void) { + DDRD |= (1<<2) | (1<<3) | (1<<4); // OUT + DDRB |= (1<<7); // OUT + PORTB |= (1<<7); +} + +void led_set_kb(uint8_t usb_led) { +// led_set_user(usb_led); + if (usb_led & (1< + * + * 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 . + */ +#ifndef TKC1800_H +#define TKC1800_H + +#include "quantum.h" + +#define KEYMAP( \ + K00, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0F, K0G, K0H, K0I, \ + K1F, K1G, K1H, K1I, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I, \ + K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, K3F, K3G, K3H, K3I, \ + K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, K4F, K4G, K4H, K4I, \ + K50, K51, K52, K53, K54, K55, K56, K57, K58, K59, K5A, K5B, K5C, K5D, K5F, K5G, K5H, K5I, \ + K60, K61, K62, K65, K69, K6A, K6B, K6C, K6D, K6E, K6G, K6H, K6I \ +) { \ + { K00, KC_NO, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, KC_NO, K0F, K0G, K0H, K0I }, \ + { KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K1F, K1G, K1H, K1I }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, K2F, K2G, K2H, K2I }, \ + { K30, K31, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D, KC_NO, K3F, K3G, K3H, K3I }, \ + { K40, K41, K42, K43, K44, K45, K46, K47, K48, K49, K4A, K4B, K4C, K4D, KC_NO, K4F, K4G, K4H, K4I }, \ + { K50, K51, K52, K53, K54, K55, K56, K57, K58, K59, K5A, K5B, K5C, K5D, KC_NO, K5F, K5G, K5H, K5I }, \ + { K60, K61, K62, KC_NO, KC_NO, K65, KC_NO, KC_NO, KC_NO, K69, K6A, K6B, K6C, K6D, K6E, KC_NO, K6G, K6H, K6I } \ +} + +#endif diff --git a/keyboards/xd75/keymaps/colinta/config.h b/keyboards/xd75/keymaps/colinta/config.h new file mode 100644 index 000000000..3b39bee81 --- /dev/null +++ b/keyboards/xd75/keymaps/colinta/config.h @@ -0,0 +1,28 @@ +/* Copyright 2017 Colin T.A. Gray + * + * 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 . + */ + +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include "../../config.h" + +// QMK customization: +// - after 1.5s, turn off one-shot keys +#define ONESHOT_TIMEOUT 1500 +// - TT(layer) only needs one press +#define TAPPING_TOGGLE 1 + +#endif diff --git a/keyboards/xd75/keymaps/colinta/keymap.c b/keyboards/xd75/keymaps/colinta/keymap.c new file mode 100644 index 000000000..a50a02c36 --- /dev/null +++ b/keyboards/xd75/keymaps/colinta/keymap.c @@ -0,0 +1,268 @@ +/* Copyright 2017 Colin T.A. Gray + * + * 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 "xd75.h" + +#ifdef IS_COLINTA +#include "secrets.h" +#else +#define SENDSTRING_MM0 "" +#define SENDSTRING_MM1 "" +#define SENDSTRING_MM2 "" +#endif + +// layers: +// - colemak, +// - record-mode (adds stop buttons) +// - qwerty +// - fn (recording, changing layers) +#define LAYER_COLEMAK 0 +#define LAYER_RECORD 1 +#define LAYER_QWERTY 2 +#define LAYER_FN 3 + +// custom keys: +// - goto layer keys +#define GOTO_FN TT(LAYER_FN) +#define GOTO_CM TO(LAYER_COLEMAK) +#define GOTO_QW TO(LAYER_QWERTY) +// - sticky keys, aka one-shot +#define OSCTL OSM(MOD_LCTL) +#define OSALT OSM(MOD_LALT) +#define OSSFT OSM(MOD_LSFT) +#define OSGUI OSM(MOD_LGUI) +// "MMENU" is a macro for "CMD+SPC" (aka Spotlight/Alfred) +#define MMENU LGUI(KC_SPC) +#define _____ KC_TRNS +#define MM_0 DYN_MACRO_PLAY1 +#define MM_1 DYN_MACRO_PLAY2 + +// tap-hold settings +#define LONGPRESS_DELAY 250 +#define TH_EVENTS_COUNT 13 + +enum my_keycods { + TH_M0 = SAFE_RANGE, + TH_M1, + TH_M2, + TH_F1, + TH_F2, + TH_F3, + TH_F4, + TH_F5, + TH_F6, + TH_F7, + TH_F8, + TH_F9, + TH_F10, + TH_LAST, + MM_2, + DM_CLEAR, + DYNAMIC_MACRO_RANGE, +}; + +#include "dynamic_macro.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* COLEMAK + * .--------------------------------------------------------------------------------------------------------------------------------------. + * | ESC | 1 | 2 | 3 | 4 | 5 | M(0) | M(1) | DEL | 6 | 7 | 8 | 9 | 0 | - | + * |--------+-/F1----+-/F2----+-/F3----+-/F4----+-/F5----+--------+--------+--------+-/F6----+-/F7----+-/F8----+-/F9----+-/F10---+--------| + * | TAB | Q | W | F | P | G | M(2) | (FN) | BKSP | J | L | U | Y | ; | = | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------+--------| + * | SHIFT | A | R | S | T | D | [ | ] | ENTER | H | N | E | I | O | ' | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------------+--------| + * | CTRL | Z | X | C | V | B | HOME | END | PG UP | K | M | , | . | / | \ | + * |--------+--------+--------+--------+--------+-----------------+--------+--------+--------+--------+-----------------+--------+--------| + * | VOL- | PLAY | VOL+ | ALT | GUI | SPACE | PG DN | MENU | ESC | LEFT | DOWN | UP | RIGHT | + * '--/RRND----/MUTE----/FFWD-------------------------------------------------------------------------------------------------------------' + */ + + [LAYER_COLEMAK] = KEYMAP( + KC_GRV, TH_F1, TH_F2, TH_F3, TH_F4, TH_F5, MM_0, MM_1, KC_DEL, TH_F6, TH_F7, TH_F8, TH_F9, TH_F10, KC_MINS, + KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, MM_2, GOTO_FN, KC_BSPC, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_EQL, + OSCTL, KC_A, KC_R, KC_S, KC_T, KC_D, KC_LBRC, KC_RBRC, KC_ENT, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, + OSSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_HOME, KC_END, KC_PGUP, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, + TH_M0, TH_M1, TH_M2, OSALT, OSGUI, _____ , KC_SPC, _____ , KC_PGDN, MMENU, KC_ESC, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT + ), + +/* DYN_REC LAYER - recording tap/hold keys is possible, but they will always "tap" (macros don't record holding duration) + * .--------------------------------------------------------------------------------------------------------------------------------------. + * | | | | | | | STOP | STOP | | | | | | | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| + * | | | | | | | STOP | STOP | | | | | | | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------+--------| + * | | | | | | | | | | | | | | | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------------+--------| + * | | | | | | | | | | | | | | | | + * |--------+--------+--------+--------+--------+-----------------+--------+--------+--------+--------+-----------------+--------+--------| + * | | | | | | | | | | | | | | + * '--------------------------------------------------------------------------------------------------------------------------------------' + */ + + [LAYER_RECORD] = KEYMAP( + _____, _____, _____, _____, _____, _____, DYN_REC_STOP, DYN_REC_STOP, _____, _____, _____, _____, _____, _____, _____, + _____, _____, _____, _____, _____, _____, DYN_REC_STOP, DYN_REC_STOP, _____, _____, _____, _____, _____, _____, _____, + _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, + _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, + _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ + ), + +/* QWERTY - doesn't support recording of macros, btw. Falls through to colemak for most keys, but passes through the recording layer, so heads up. + * .--------------------------------------------------------------------------------------------------------------------------------------. + * | | | | | | | M(0) | M(1) | | | | | | | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| + * | | Q | W | E | R | T | M(2) | (FN) | | Y | U | I | O | P | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------+--------| + * | SHIFT | A | S | D | F | G | | | | H | J | K | L | ; | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------------+--------| + * | CTRL | Z | X | C | V | B | | | | N | M | | | | | + * |--------+--------+--------+--------+--------+-----------------+--------+--------+--------+--------+-----------------+--------+--------| + * | | | | ALT | GUI | | | | | | | | | + * '--------------------------------------------------------------------------------------------------------------------------------------' + */ + + [LAYER_QWERTY] = KEYMAP( + _____, _____, _____, _____, _____, _____, MM_0, MM_1, _____, _____, _____, _____, _____, _____, _____, + _____, KC_Q, KC_W, KC_E, KC_R, KC_T, MM_2, GOTO_FN, _____, KC_Y, KC_U, KC_I, KC_O, KC_P, _____, + MOD_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, _____, _____, _____, KC_H, KC_J, KC_K, KC_L, KC_SCLN, _____, + MOD_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, _____, _____, _____, KC_N, KC_M, _____, _____, _____, _____, + _____, _____, _____, MOD_LALT, MOD_LGUI, _____, _____, _____, _____, _____, _____, _____, _____, _____, _____ + ), + +/* FN LAYER - change layouts and start recording a macro + * .--------------------------------------------------------------------------------------------------------------------------------------. + * | COLEMAK| QWERTY | | | | | REC 1 | REC 2 | | | | | | | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------| + * | | | | | | | | ------ | | | | | | | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------+--------| + * | | | | | | | | | | | | | | | | + * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------------+--------| + * | | | | | | | | | | | | | | | | + * |--------+--------+--------+--------+--------+-----------------+--------+--------+--------+--------+-----------------+--------+--------| + * | | | | | RESET | DM_CLEAR | | | RESET | | | | | + * '--------------------------------------------------------------------------------------------------------------------------------------' + */ + + [LAYER_FN] = KEYMAP( + GOTO_CM, GOTO_QW, KC_NO, KC_NO, KC_NO, KC_NO, DYN_REC_START1, DYN_REC_START2, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, + KC_NO, KC_NO, KC_NO, KC_NO, RESET, KC_NO, DM_CLEAR, KC_NO, KC_NO, KC_NO, RESET, KC_NO, KC_NO, KC_NO, KC_NO + ) +}; + +typedef struct { + bool is_pressed; + uint16_t timer; + uint16_t kc_tap; + uint16_t kc_hold; +} tap_hold_t; + +static tap_hold_t th_events[] = { + { .is_pressed = false, .timer = 0, .kc_tap = KC_VOLD, .kc_hold = KC_MRWD }, // TH_M0 + { .is_pressed = false, .timer = 0, .kc_tap = KC_MPLY, .kc_hold = KC_MUTE }, // TH_M1 + { .is_pressed = false, .timer = 0, .kc_tap = KC_VOLU, .kc_hold = KC_MFFD }, // TH_M2 + + { .is_pressed = false, .timer = 0, .kc_tap = KC_1, .kc_hold = KC_F1 }, // TH_F1 + { .is_pressed = false, .timer = 0, .kc_tap = KC_2, .kc_hold = KC_F2 }, // TH_F2 + { .is_pressed = false, .timer = 0, .kc_tap = KC_3, .kc_hold = KC_F3 }, // TH_F3 + { .is_pressed = false, .timer = 0, .kc_tap = KC_4, .kc_hold = KC_F4 }, // TH_F4 + { .is_pressed = false, .timer = 0, .kc_tap = KC_5, .kc_hold = KC_F5 }, // TH_F5 + { .is_pressed = false, .timer = 0, .kc_tap = KC_6, .kc_hold = KC_F6 }, // TH_F6 + { .is_pressed = false, .timer = 0, .kc_tap = KC_7, .kc_hold = KC_F7 }, // TH_F7 + { .is_pressed = false, .timer = 0, .kc_tap = KC_8, .kc_hold = KC_F8 }, // TH_F8 + { .is_pressed = false, .timer = 0, .kc_tap = KC_9, .kc_hold = KC_F9 }, // TH_F9 + { .is_pressed = false, .timer = 0, .kc_tap = KC_0, .kc_hold = KC_F10 } // TH_F10 +}; + +void taphold_tapped(uint8_t index, bool pressed) { + if (index >= TH_EVENTS_COUNT) { return; } + + tap_hold_t *th_event = &th_events[index]; + + if (pressed) { + th_event->timer = timer_read(); + th_event->is_pressed = true; + } else if (th_event->is_pressed) { + register_code(th_event->kc_tap); + unregister_code(th_event->kc_tap); + th_event->is_pressed = false; + } +} + +void matrix_scan_user() { + for (uint8_t index = 0 ; index < TH_EVENTS_COUNT ; ++index ) { + tap_hold_t *th_event = &th_events[index]; + if ( th_event->is_pressed && timer_elapsed(th_event->timer) > LONGPRESS_DELAY) { + register_code(th_event->kc_hold); + unregister_code(th_event->kc_hold); + th_event->is_pressed = false; + } + } +} + +// if the dynamic macros haven't been recorded, we send the default macro strings. +bool did_record_m1 = false; +bool did_record_m2 = false; +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + bool try_dynamic_macro = true; + if ((keycode == DYN_MACRO_PLAY1 && !did_record_m1) || (keycode == DYN_MACRO_PLAY2 && !did_record_m2)) { + try_dynamic_macro = false; + } + else if (keycode == DM_CLEAR) { + try_dynamic_macro = false; + did_record_m1 = false; + did_record_m2 = false; + } + + if (try_dynamic_macro && !process_record_dynamic_macro(keycode, record)) { + if (keycode == DYN_MACRO_PLAY1) { + did_record_m1 = true; + } + + if (keycode == DYN_MACRO_PLAY2) { + did_record_m2 = true; + } + + if (keycode == DYN_REC_START1 || keycode == DYN_REC_START2) { + layer_move(LAYER_RECORD); + } + else if (keycode == DYN_REC_STOP) { + layer_move(LAYER_COLEMAK); + } + + return false; + } + + switch (keycode) { + case DYN_MACRO_PLAY1: + SEND_STRING(SENDSTRING_MM0); + return false; + case DYN_MACRO_PLAY2: + SEND_STRING(SENDSTRING_MM1); + return false; + case MM_2: + SEND_STRING(SENDSTRING_MM2); + return false; + case TH_M0 ... TH_LAST: + taphold_tapped(keycode - TH_M0, record->event.pressed); + return false; + } + + return true; +} diff --git a/keyboards/xd75/keymaps/colinta/readme.md b/keyboards/xd75/keymaps/colinta/readme.md new file mode 100644 index 000000000..e3f59d681 --- /dev/null +++ b/keyboards/xd75/keymaps/colinta/readme.md @@ -0,0 +1,64 @@ +# colinta's keymap for XD75 + +``` +make xd75:colinta:dfu +``` + +The default layout is a Colemak keyboard with "one-shot" keys assigned to the modifier keys. + + .--------------------------------------------------------------------------------------------------------------------------------------. + | ESC | 1 | 2 | 3 | 4 | 5 | DYN_M1 | DYN_M2 | DEL | 6 | 7 | 8 | 9 | 0 | - | + |--------+-/F1----+-/F2----+-/F3----+-/F4----+-/F5----+--------+--------+--------+-/F6----+-/F7----+-/F8----+-/F9----+-/F10---+--------| + | TAB | Q | W | F | P | G | MACRO | (FN) | BKSP | J | L | U | Y | ; | = | + |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+-----------------+--------| + | SHIFT | A | R | S | T | D | [ | ] | ENTER | H | N | E | I | O | ' | + |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------------------------+--------| + | CTRL | Z | X | C | V | B | HOME | END | PG UP | K | M | , | . | / | \ | + |--------+--------+--------+--------+--------+-----------------+--------+--------+--------+--------+-----------------+--------+--------| + | VOL- | PLAY | VOL+ | ALT | GUI | SPACE | PG DN | MENU | ESC | LEFT | DOWN | UP | RIGHT | + '--/RRND----/MUTE----/FFWD-------------------------------------------------------------------------------------------------------------' + + +I've implemented my own "tap/hold" feature, identical in spirit to "Space Cadet", but generic. Tapping "1" sends a 1, but press and hold to send "F1". Or, tap "VOL-" to turn the volume down, but press and hold to rewind. + +The function layer is only to switch to Qwerty (so other people can use this keyboard - also turns off sticky keys) and to start recording keypresses. + +I implemented "stop recording" in a unique way; starting a macro recording sends the keyboard layer to one that has all the macro keys assigned to `DYN_REC_STOP`, and restores the layer to the default when recording is stopped. + +I wish Dynamic Macros supported more, because I'd like to record a third macro in the MACRO slot instead of hardcoding it. I'm using these to store some passwords. + +## Regarding "secrets.h" + +The macros I'm using are sensitive, I'm comfortable having them hardcoded onto my keyboard (no SSN or private GPG keys), but not suitable for public viewing. So I've put them in a header file that is excluded from the project, and I can include this file using a compiler flag. + +If you would *also* like to take advantage of this feature, you'll first want to make sure your "secrets" file isn't included in the repo. Open `.git/info/exclude` and add `secrets.h` to that file, below the comments. + +###### .git/info/exclude +``` +# git ls-files --others --exclude-from=.git/info/exclude +# Lines that start with '#' are comments. +# For a project mostly in C, the following would be a good set of +# exclude patterns (uncomment them if you want to use them): +# *.[oa] +# *~ +/keyboards/xd75/keymaps/colinta/secrets.h +``` + +Then you can create this file and add your macro strings to it: + +``` +$EDITOR keyboards/xd75/keymaps/colinta/secrets.h +``` + +###### secrets.h +``` +#define SENDSTRING_MM0 "abcd1234" +#define SENDSTRING_MM1 "shhhhh secret" +#define SENDSTRING_MM2 "stop saying pickle rick" +``` + +To include the feature at compile time, include the flag `IS_COLINTA` like so: + +``` +make xd75:colinta:dfu EXTRAFLAGS=-DIS_COLINTA +``` diff --git a/shell.nix b/shell.nix index 302899c52..ce17dd41e 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,5 @@ { pkgs ? import {} -, avr ? true, arm ? true }: +, avr ? true, arm ? true, teensy ? true }: with pkgs; let @@ -19,7 +19,8 @@ stdenv.mkDerivation { buildInputs = [ dfu-programmer dfu-util diffutils git ] ++ lib.optional avr [ avrbinutils avrgcc avrlibc ] - ++ lib.optional arm [ gcc-arm-embedded ]; + ++ lib.optional arm [ gcc-arm-embedded ] + ++ lib.optional teensy [ teensy-loader-cli ]; CFLAGS = lib.optional avr avr_incflags; ASFLAGS = lib.optional avr avr_incflags;