From 9550ab334232b73025e105a9d04f67e57aa3c02f Mon Sep 17 00:00:00 2001 From: James Young <18669334+noroadsleft@users.noreply.github.com> Date: Wed, 4 Mar 2020 16:42:09 -0800 Subject: [Keymap] Adding the 4sStylZ xd75 (#8285) * Adding the 4sStylZ xd75 * Update keyboards/xd75/keymaps/4sstylz/keycodes.h * Apply suggestions from code review --- keyboards/xd75/keymaps/4sstylz/config.h | 31 +++++ keyboards/xd75/keymaps/4sstylz/keycodes.h | 90 +++++++++++++++ keyboards/xd75/keymaps/4sstylz/keymap.c | 186 ++++++++++++++++++++++++++++++ keyboards/xd75/keymaps/4sstylz/leds.h | 46 ++++++++ keyboards/xd75/keymaps/4sstylz/readme.md | 4 + keyboards/xd75/keymaps/4sstylz/rules.mk | 30 +++++ 6 files changed, 387 insertions(+) create mode 100644 keyboards/xd75/keymaps/4sstylz/config.h create mode 100644 keyboards/xd75/keymaps/4sstylz/keycodes.h create mode 100644 keyboards/xd75/keymaps/4sstylz/keymap.c create mode 100644 keyboards/xd75/keymaps/4sstylz/leds.h create mode 100644 keyboards/xd75/keymaps/4sstylz/readme.md create mode 100644 keyboards/xd75/keymaps/4sstylz/rules.mk (limited to 'keyboards') diff --git a/keyboards/xd75/keymaps/4sstylz/config.h b/keyboards/xd75/keymaps/4sstylz/config.h new file mode 100644 index 0000000000..3049141c27 --- /dev/null +++ b/keyboards/xd75/keymaps/4sstylz/config.h @@ -0,0 +1,31 @@ +/* Copyright 2017 Benjamin Kesselring + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +// place overrides here + +/* Enable the space-cadet options */ +#define RSPC_KEYS KC_RSFT, KC_TRNS, KC_PGUP +#define RCPC_KEYS KC_RCTL, KC_TRNS, KC_PGDOWN +#define LSPO_KEYS KC_LSFT, KC_TRNS, KC_HOME +#define LCPO_KEYS KC_LCTL, KC_TRNS, KC_END + +#define COMBO_COUNT 1 +#define TAPPING_TERM 175 + +#define BACKLIGHT_BREATHING +#undef RGBLIGHT_ANIMATIONS diff --git a/keyboards/xd75/keymaps/4sstylz/keycodes.h b/keyboards/xd75/keymaps/4sstylz/keycodes.h new file mode 100644 index 0000000000..d0460856b2 --- /dev/null +++ b/keyboards/xd75/keymaps/4sstylz/keycodes.h @@ -0,0 +1,90 @@ +/* + * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + * Version 2, December 2004 + * + * Copyright (C) 2019 4sStylZ <4sstylz@protonmail.ch> + * + * Everyone is permitted to copy and distribute verbatim or modified + * copies of this license document, and changing it is allowed as long + * as the name is changed. + * + * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + * + * 0. You just DO WHAT THE FUCK YOU WANT TO. + */ +#include QMK_KEYBOARD_H + +/** + * Macro for selecting all the text in the document. + * Usual shortcut : Ctrl+A. + * + * @param keyrecord_t *record + * + * @return void + */ +void select_all(keyrecord_t *record) { + if (record->event.pressed) { + tap_code16(C(KC_A)); + } +} + +/** + * Macro for selecting the current row. + * + * @param keyrecord_t *record + * + * @return void + */ +void select_row(keyrecord_t *record) { + if (record->event.pressed) { + tap_code(KC_HOME); + tap_code16(S(KC_END)); + } +} + +/** + * Macro for selecting the current word. + * Usage : You need to have the cursor into the word or directly at the right. + * + * + * Usual shortcut : Ctrl+A. + * + * @param keyrecord_t *record + * + * @return void + */ +void select_word(keyrecord_t *record) { + if (record->event.pressed) { + register_code(KC_LCTL); + tap_code(KC_LEFT); + tap_code16(S(KC_RGHT)); + unregister_code(KC_LCTL); + } +} + +/** + * Macro for inserting two 0 with keypad. + * Be carefull to have the keypad lock enabled + * + * @param keyrecord_t *record + * + * @return void + */ +void insert_00(keyrecord_t *record) { + if (record->event.pressed) { + tap_code16(S(KC_0)); + tap_code16(S(KC_0)); + } +} + +/** + * Bépo Windows lock + * + * @param keyrecord_t *record + * + * @return void + */ +void windows_lock(void) { + tap_code16(G(KC_O)); +} diff --git a/keyboards/xd75/keymaps/4sstylz/keymap.c b/keyboards/xd75/keymaps/4sstylz/keymap.c new file mode 100644 index 0000000000..d722da9c58 --- /dev/null +++ b/keyboards/xd75/keymaps/4sstylz/keymap.c @@ -0,0 +1,186 @@ +/* Copyright 2017 Wunder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#include QMK_KEYBOARD_H +#include "keycodes.h" +#include "leds.h" + +// Implement Super-alt↯tab +// See https://docs.qmk.fm/#/feature_macros?id=super-alt↯tab +bool is_alt_tab_active = false; +uint16_t alt_tab_timer = 0; +bool is_screen_lock_triggered = false; +uint16_t screen_lock_timer = 0; + +// Defining all the custom keycodes. +enum custom_keycodes { + ALT_TAB = SAFE_RANGE, + KC_00 , + SLC_ROW, + SLC_ALL, + SLC_WRD +}; + +enum combo_events { + SCR_LCK +}; + +const uint16_t PROGMEM lock_combo[] = {KC_J, KC_K, KC_L, KC_SCLN, COMBO_END}; +combo_t key_combos[COMBO_COUNT] = {COMBO(lock_combo, SCR_LCK)}; + +// Layer shorthand +#define _QW 0 +#define _FN 1 + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +/* QWERTY + * ┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐ + * │` Esc │ 1 │ 2 │ 3 │ 4 │ 5 │ Del │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │PrtScn│ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ Tab │ Q │ W │ E │ R │ T │ Bksp │ Y │ U │ I │ O │ P │ [ │ ] │ Home │ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ FN │ A │ S │ D │ F │ G │Enter │ H │ J │ K │ L │ ; │ ' │ # │ End │ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ Shft │ Z │ X │ C │ V │ B │ALTTAB│ N │ M │ , │ . │ / │ Shft │ FN │ PgUp │ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ Ctrl │ Gui │ Alt │ Back │ Frwd │Space │ App │Space │ Left │ Up │ Down │ Right│ Alt │ Ctrl │ PgDn │ + * └──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘ + */ + + [_QW] = LAYOUT_ortho_5x15( /* QWERTY */ + KC_GESC, KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_DEL , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINUS, KC_EQUAL, KC_PSCR, + KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_BSPC, KC_Y , KC_U , KC_I , KC_O , KC_P , KC_LBRC , KC_RBRC , KC_HOME, + MO(_FN), KC_A , KC_S , KC_D , KC_F , KC_G , KC_ENT , KC_H , KC_J , KC_K , KC_L , KC_SCLN , KC_QUOT , KC_NUHS , KC_END , + KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , ALT_TAB, KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH , KC_RSFT , MO(_FN) , KC_PGUP, + KC_LCTL, KC_LGUI, KC_LALT, KC_WBAK, KC_WFWD, KC_SPC, KC_APP , KC_SPC, KC_LEFT, KC_UP , KC_DOWN, KC_RIGHT, KC_RALT , KC_RCTL , KC_PGDN + ), + +/* FUNCTION + * NB :  My OS  layout (Bépo) don't have direct access to numbers, so that's why I use « LSFT » mod for the keypad. + * You need to remove LSFT(KC) for using this layout with Qwerty. Also the use of KC_8, 7, and V are some specific Bépo + * things. + * ┌──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐ + * │Alt F4│ F1 │ F2 │ F3 │ F4 │ F5 │BL Tog│ F6 │ F7 │ F8 │ F9 │ F10 │ F11 │ F12 │ # Lk │ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ │ │SltAll│SltRow│SltRow│ Brt+ │BL Stp│ │ │ KP 7 │ KP 8 │ KP 9 │ 8 │ │ │ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ │ │ Cut │ Copy │Paste │ Brt- │BL Brt│ │ │ KP 4 │ KP 5 │ KP 6 │ 7 │ │Reset │ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ │ │ Mute │ Vol- │ Vol+ │ Play │Ld Tog│ │ │ KP 1 │ KP 2 │ KP 3 │Enter │ │ │ + * ├──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤ + * │ │ │ │ │ │ │Ld M+ │ │ │ KP 0 │KC 00 │ V │ │ │ │ + * └──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘ + */ + + [_FN] = LAYOUT_ortho_5x15( /* FUNCTION */ + LALT(KC_F4), KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , BL_TOGG, KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_NLCK, + _______ , _______, SLC_ALL , SLC_ROW , SLC_WRD , KC_BRIU, BL_STEP, _______, _______, LSFT(KC_7) , LSFT(KC_8) , LSFT(KC_9), KC_8 , _______, _______, + _______ , _______, LSFT(KC_DEL), LCTL(KC_INS), LSFT(KC_INS), KC_BRID, BL_BRTG, _______, _______, LSFT(KC_4) , LSFT(KC_5) , LSFT(KC_6), KC_7 , _______, RESET , + _______ , _______, KC_MUTE , KC_VOLD , KC_VOLU , KC_MPLY, RGB_TOG, _______, _______, LSFT(KC_1) , LSFT(KC_2) , LSFT(KC_3), KC_ENT , _______, _______, + _______ , _______, _______ , _______ , _______ , _______, RGB_MOD, _______, _______, LSFT(KC_0) , KC_00 , KC_V , _______ , _______, _______ + ) +}; + +// Processing all the key pressed. +// Alt+tab. +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + + // Depending keycodes… + switch (keycode) { // This will do most of the grunt work with the keycodes. + case ALT_TAB: + if (record->event.pressed) { + if (!is_alt_tab_active) { + is_alt_tab_active = true; + gp100_led_on(); + register_code(KC_LALT); + } + alt_tab_timer = timer_read(); + register_code(KC_TAB); + } else { + unregister_code(KC_TAB); + } + break; + case KC_00: + insert_00(record); + break; + case SLC_ALL: + select_all(record); + break; + case SLC_ROW: + select_row(record); + break; + case SLC_WRD: + select_word(record); + break; + } + return true; +} + +void process_combo_event(uint8_t combo_index, bool pressed) { + switch(combo_index) { + case SCR_LCK: + if (pressed) { + /*if (!is_screen_lock_triggered) {*/ + is_screen_lock_triggered = true; + gp103_led_on(); + windows_lock(); + /*}*/ + screen_lock_timer = timer_read(); + } + break; + } +} + +void matrix_scan_user(void) { // The very important timer. + if (is_alt_tab_active) { + if (timer_elapsed(alt_tab_timer) > 750) { + unregister_code(KC_LALT); + gp100_led_off(); + is_alt_tab_active = false; + } + } + if (is_screen_lock_triggered) { + if (timer_elapsed(screen_lock_timer) > 750) { + gp103_led_off(); + is_screen_lock_triggered = false; + } + } +} + +void led_set_user(uint8_t usb_led) { + if (IS_LAYER_ON(_FN)) { + capslock_led_on(); + } else { + capslock_led_off(); + } +} + +void keyboard_post_init_user (void) { + setDefaultDisplay(); +} + +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { + case _FN: + setFNDisplay(); + break; + + default: // for any other layers, or the default layer + setDefaultDisplay(); + break; + } + return state; +} diff --git a/keyboards/xd75/keymaps/4sstylz/leds.h b/keyboards/xd75/keymaps/4sstylz/leds.h new file mode 100644 index 0000000000..a5ad863b0a --- /dev/null +++ b/keyboards/xd75/keymaps/4sstylz/leds.h @@ -0,0 +1,46 @@ +/* + * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + * Version 2, December 2004 + * + * Copyright (C) 2019 4sStylZ <4sstylz@protonmail.ch> + * + * Everyone is permitted to copy and distribute verbatim or modified + * copies of this license document, and changing it is allowed as long + * as the name is changed. + * + * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + * + * 0. You just DO WHAT THE FUCK YOU WANT TO. + */ +#include QMK_KEYBOARD_H + +void setDefaultDisplay(void) { + _delay_ms(10); + rgblight_setrgb_at(180, 35, 0, 0); + _delay_ms(10); + rgblight_setrgb_at(200, 35, 0, 1); + _delay_ms(10); + rgblight_setrgb_at(220, 35, 0, 2); + _delay_ms(10); + rgblight_setrgb_at(220, 35, 0, 3); + _delay_ms(10); + rgblight_setrgb_at(200, 35, 0, 4); + _delay_ms(10); + rgblight_setrgb_at(180, 35, 0, 5); +} + +void setFNDisplay(void) { + _delay_ms(10); + rgblight_setrgb_at(145, 45, 0, 0); + _delay_ms(10); + rgblight_setrgb_at(160, 45, 0, 1); + _delay_ms(10); + rgblight_setrgb_at(175, 45, 0, 2); + _delay_ms(10); + rgblight_setrgb_at(190, 45, 0, 3); + _delay_ms(10); + rgblight_setrgb_at(205, 45, 0, 4); + _delay_ms(10); + rgblight_setrgb_at(220, 45, 0, 5); +} diff --git a/keyboards/xd75/keymaps/4sstylz/readme.md b/keyboards/xd75/keymaps/4sstylz/readme.md new file mode 100644 index 0000000000..31efa071fc --- /dev/null +++ b/keyboards/xd75/keymaps/4sstylz/readme.md @@ -0,0 +1,4 @@ +# Personal keymap of 4sStylZ + +* Similar to a Typematrix 2030 layout, +* 3 leds on the GP001, GP003 and Capslock led diff --git a/keyboards/xd75/keymaps/4sstylz/rules.mk b/keyboards/xd75/keymaps/4sstylz/rules.mk new file mode 100644 index 0000000000..ffb70f0a9e --- /dev/null +++ b/keyboards/xd75/keymaps/4sstylz/rules.mk @@ -0,0 +1,30 @@ +# Copyright 2013 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 . + +COMBO_ENABLE = yes # Enable combo for special function when using multiple keys at once. +BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality +RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. + +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +MIDI_ENABLE = no # MIDI support +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend -- cgit v1.2.3