From 9236c3a9d026d556ba762c5a631d1f15bc1c20a0 Mon Sep 17 00:00:00 2001 From: Adam DeHaven Date: Fri, 26 Jun 2020 06:17:31 -0400 Subject: [Keymap] Adding custom keymaps (#9426) * Adding custom keymaps * Update keyboards/kbdfans/kbd75/keymaps/adamdehaven/keymap.c --- .../kbdfans/kbd75/keymaps/adamdehaven/config.h | 3 + .../kbdfans/kbd75/keymaps/adamdehaven/keymap.c | 168 +++++++++++++++++++++ .../kbdfans/kbd75/keymaps/adamdehaven/rules.mk | 1 + 3 files changed, 172 insertions(+) create mode 100644 keyboards/kbdfans/kbd75/keymaps/adamdehaven/config.h create mode 100644 keyboards/kbdfans/kbd75/keymaps/adamdehaven/keymap.c create mode 100644 keyboards/kbdfans/kbd75/keymaps/adamdehaven/rules.mk (limited to 'keyboards/kbdfans/kbd75') diff --git a/keyboards/kbdfans/kbd75/keymaps/adamdehaven/config.h b/keyboards/kbdfans/kbd75/keymaps/adamdehaven/config.h new file mode 100644 index 0000000000..4fcd773552 --- /dev/null +++ b/keyboards/kbdfans/kbd75/keymaps/adamdehaven/config.h @@ -0,0 +1,3 @@ +#pragma once + +#define TAPPING_TERM 200 diff --git a/keyboards/kbdfans/kbd75/keymaps/adamdehaven/keymap.c b/keyboards/kbdfans/kbd75/keymaps/adamdehaven/keymap.c new file mode 100644 index 0000000000..134cf28db7 --- /dev/null +++ b/keyboards/kbdfans/kbd75/keymaps/adamdehaven/keymap.c @@ -0,0 +1,168 @@ +#include QMK_KEYBOARD_H + +// Compile from qmk_firmware folder with the following command: +// $ make kbdfans/kbd75/rev2:adamdehaven + +// Each layer gets a name for readability. The underscores don't mean anything - you can have a layer called STUFF or any other name. +// Layer names don't all need to be of the same length, and you can also skip them entirely and just use numbers. +#define _QWERTY 0 +#define _FN1 1 + +extern rgblight_config_t rgblight_config; +static bool RGB_user_wants_enabled; +uint16_t RGB_current_mode; +uint16_t RGB_current_hue; +uint16_t RGB_current_sat; +uint16_t RGB_current_val; + +// Setup RGB +void keyboard_post_init_user(void) { + RGB_user_wants_enabled = rgblight_config.enable; + RGB_current_mode = rgblight_config.mode; + RGB_current_hue = rgblight_config.hue; + RGB_current_sat = rgblight_config.sat; + RGB_current_val = rgblight_config.val; +}; + +// Restore user settings +void restore_user_rgb_settings(void) { + // First, enable RGB + if (RGB_user_wants_enabled && !rgblight_config.enable) { + rgblight_enable(); + } else if (!RGB_user_wants_enabled && rgblight_config.enable) { + rgblight_disable(); + } + + // Restore settings + rgblight_sethsv(RGB_current_hue, RGB_current_sat, RGB_current_val); // Restore underglow RGB color + rgblight_mode(RGB_current_mode); // Restore RGB mode +}; + +// Tap Dance Definitions +enum tapdance { + TD_PGUP = 0, + TD_PGDN +}; + +qk_tap_dance_action_t tap_dance_actions[] = { + // Tap once for PageUp, twice for Home + [TD_PGUP] = ACTION_TAP_DANCE_DOUBLE(KC_PGUP, KC_HOME), + // Tap once for PageDown, twice for End + [TD_PGDN] = ACTION_TAP_DANCE_DOUBLE(KC_PGDOWN, KC_END) +}; + +// Fire on keypress +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case RGB_TOG: + if (!record->event.pressed) { + // on keyup + RGB_user_wants_enabled = rgblight_config.enable; + } + break; + case RGB_MOD: + if (!record->event.pressed) { + // on keyup + RGB_current_mode = rgblight_config.mode; + } + break; + case RGB_HUI: + case RGB_HUD: + if (!record->event.pressed) { + // on keyup + RGB_current_hue = rgblight_config.hue; + } + break; + case RGB_SAI: + case RGB_SAD: + if (!record->event.pressed) { + // on keyup + RGB_current_sat = rgblight_config.sat; + } + break; + case RGB_VAI: + case RGB_VAD: + if (!record->event.pressed) { + // on keyup + RGB_current_val = rgblight_config.val; + } + break; + } + return true; +}; + + +/* + * You can use _______ in place for KC_TRNS (transparent) + * Or you can use XXXXXXX for KC_NO (NOOP) + */ +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + /* 0: _QWERTY + * ┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐ + * │ 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_PSCR │KC_INSERT│ KC_DEL │ + * ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┴─────────┼─────────┤ + * │ KC_GRV │ 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_HOME │ + * ├─────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬──────────────┼─────────┤ + * │ 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_END │ + * ├──────────────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴──────────────┼─────────┤ + * │ 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 │ TD_PGUP │ + * ├────────────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────────────┬─────────┼─────────┤ + * │ KC_LSFT (2) │ KC_Z │ KC_X │ KC_C │ KC_V │ KC_B │ KC_N │ KC_M │ KC_COMM │ KC_DOT │ KC_SLSH │ KC_RSFT │ KC_UP │ TD_PGDN │ + * ├───────────┬─────────┴─┬───────┴───┬─────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┬─┴───────┬┴────────┬─┴───────┬─────────┼─────────┼─────────┤ + * │ KC_LCTL │ KC_LGUI │ KC_LALT │ KC_SPC │ KC_RALT │MO(_FN1) │ KC_RCTL │ KC_LEFT │ KC_DOWN │ KC_RGHT │ + * └───────────┴───────────┴───────────┴───────────────────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘ + */ + [_QWERTY] = LAYOUT( + 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_PSCR, KC_INSERT, KC_DEL, + KC_GRV, 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_DEL, KC_BSPC, KC_HOME, + 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_END, + 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, TD(TD_PGUP), + 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, TD(TD_PGDN), + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_SPC, KC_SPC, KC_RALT, MO(_FN1), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* 1: _FN1 + * ┌─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐ + * │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ KC_MUTE │ + * ├─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┴─────────┼─────────┤ + * │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ + * ├─────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬──────────────┼─────────┤ + * │ _______ │ RGB_TOG │ RGB_MOD │ RGB_HUI │ RGB_HUD │ RGB_SAI │ RGB_SAD │ RGB_VAI │ RGB_VAD │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ + * ├──────────────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴─┬───────┴──────────────┼─────────┤ + * │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ KC_VOLU │ + * ├────────────────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────┬────┴────────────┬─────────┼─────────┤ + * │ _______ (2) │ _______ │ _______ │ BL_DEC │ BL_TOGG │ BL_INC │ BL_STEP │ _______ │ _______ │ _______ │ _______ │ _______ │ KC_MPLY │ KC_VOLD │ + * ├───────────┬─────────┴─┬───────┴───┬─────┴─────────┴─────────┴─────────┴─────────┴─────────┴───────┬─┴───────┬─┴───────┬─┴───────┬─────────┼─────────┼─────────┤ + * │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ _______ │ KC_MPRV │ KC_MPLY │ KC_MNXT │ + * └───────────┴───────────┴───────────┴───────────────────────────────────────────────────────────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘ + */ + [_FN1] = LAYOUT( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLU, + _______, _______, _______, _______, BL_DEC, BL_TOGG, BL_INC, BL_STEP, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLD, + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT + ) +}; + +void toggle_rgb_caps_lock(bool isActive) { + if (isActive) { + if (!rgblight_config.enable) { + rgblight_enable(); + } + + // Set underglow color if CAPS_LOCK enabled + rgblight_sethsv(HSV_RED); + // Set to breathe + rgblight_mode(5); + } else { + restore_user_rgb_settings(); + } +}; + +bool led_update_user(led_t led_state) { + toggle_rgb_caps_lock(led_state.caps_lock); + return true; +}; diff --git a/keyboards/kbdfans/kbd75/keymaps/adamdehaven/rules.mk b/keyboards/kbdfans/kbd75/keymaps/adamdehaven/rules.mk new file mode 100644 index 0000000000..e5ddcae8d9 --- /dev/null +++ b/keyboards/kbdfans/kbd75/keymaps/adamdehaven/rules.mk @@ -0,0 +1 @@ +TAP_DANCE_ENABLE = yes -- cgit v1.2.3