qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

keymap.c (3353B)


      1 /*
      2 Copyright 2021 Richard Snijder
      3 This program is free software: you can redistribute it and/or modify
      4 it under the terms of the GNU General Public License as published by
      5 the Free Software Foundation, either version 2 of the License, or
      6 (at your option) any later version.
      7 This program is distributed in the hope that it will be useful,
      8 but WITHOUT ANY WARRANTY; without even the implied warranty of
      9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     10 GNU General Public License for more details.
     11 You should have received a copy of the GNU General Public License
     12 along with this program.  If not, see <http://www.gnu.org/licenses/>.
     13 */
     14 
     15 #include QMK_KEYBOARD_H
     16 
     17 uint16_t copy_paste_timer;
     18 uint16_t enter_timer;
     19 
     20 //extern rgblight_config_t rgblight_config;
     21 
     22 // Define custom keycodes
     23 enum my_keycodes {
     24 	KC_CCCV = SAFE_RANGE,
     25 	KC_2ENTER
     26 };
     27 
     28 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     29         //Layer 0 - Base Layer (F13 to F24, and One Shot Layer 1,2,3,4)
     30         [0] = LAYOUT_ortho_4x4(
     31                 KC_F13, KC_F14, KC_F15, KC_F16,
     32                 KC_F17, KC_F18, KC_F19, KC_F20,
     33                 KC_F21, KC_F22, KC_F23, KC_F24,
     34                 TO(1), OSL(2), OSL(3),  LCA(KC_J)    //Transparent to let you go between layers
     35 		),
     36 
     37         [1] = LAYOUT_ortho_4x4(
     38                 LALT(KC_KP_1), LALT(KC_KP_2), LALT(KC_KP_3), LALT(KC_KP_4),
     39                 LALT(KC_KP_5), LALT(KC_KP_6), LALT(KC_KP_7), LALT(KC_KP_8),
     40                 LALT(KC_KP_9), LALT(KC_A), LALT(KC_B), LALT(KC_C),
     41                 TO(2),LALT(KC_D),LALT(KC_E),LALT(KC_F)         //Transparent to let you go between layers
     42         ),
     43 
     44         //Layer 2 - Shift + Function Key Layer
     45         [2] = LAYOUT_ortho_4x4(
     46                 LCA(KC_F1), LCA(KC_F2), LCA(KC_F3), LCA(KC_F4),
     47                 LCA(KC_F5), LCA(KC_F6), LCA(KC_F7), LCA(KC_F8),
     48                 LCA(KC_F9), LCA(KC_F10),LCA(KC_F11),LCA(KC_F12),
     49 				TO(3),         LCA(KC_D), LCA(KC_E), LCA(KC_F)         //Transparent to let you go between layers
     50         ),
     51 
     52         //Layer 3 - Control + Function Key
     53         [3] = LAYOUT_ortho_4x4(
     54                 LCA(KC_F13), LCA(KC_F14), LCA(KC_F15), LCA(KC_F16),
     55                 LCA(KC_F17), LCA(KC_F18), LCA(KC_F19), LCA(KC_F20),
     56                 LCA(KC_F21), LCA(KC_F22),LCA(KC_F23),LCA(KC_F24),
     57 				TO(0),         LCA(KC_G), LCA(KC_H), LCA(KC_I)          //Transparent to let you go between layers
     58         ),
     59 
     60 };
     61 
     62 
     63 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     64     switch (keycode) {
     65         case KC_CCCV:  // One key copy/paste
     66             if (record->event.pressed) {
     67                 copy_paste_timer = timer_read();
     68             } else {
     69                 if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) {  // Hold, copy
     70                     tap_code16(LCTL(KC_C));
     71                 } else {  // Tap, paste
     72                     tap_code16(LCTL(KC_V));
     73                 }
     74             } return true;
     75 		case KC_2ENTER:
     76 		    if (record->event.pressed) {
     77                 enter_timer = timer_read();
     78             } else {
     79                 if (timer_elapsed(enter_timer) > TAPPING_TERM) {  // Hold, shift+enter
     80                     tap_code16(LSFT(KC_ENTER));
     81                 } else {  // Tap, enter
     82                     tap_code16(KC_F24);
     83                 }
     84             } 
     85 			return true;
     86         default:
     87             return true;
     88     }
     89 }
     90 
     91