qmk_firmware

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

keymap.c (4323B)


      1 /* Copyright 2021 Jay Greco
      2  *
      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  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 #include QMK_KEYBOARD_H
     17 
     18 enum layer_names {
     19   _MA,
     20   _FN
     21 };
     22 
     23 enum custom_keycodes {
     24   KC_CUST = SAFE_RANGE,
     25 };
     26 
     27 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     28   [_MA] = LAYOUT_iso(
     29              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_HOME,
     30     KC_F13,  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_DEL,
     31     KC_F14,  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_NUHS, KC_ENT,  KC_PGUP,
     32     KC_F15,  KC_LSFT, KC_NUBS, 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_PGDN,
     33     KC_F16,  KC_LCTL, KC_LGUI, KC_LALT,                            KC_SPC,                    MO(_FN), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
     34   ),
     35   [_FN] = LAYOUT_iso(
     36              QK_BOOT,   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_HOME,  KC_INS,
     37     UG_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,          _______,
     38     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     39     _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
     40     _______, _______, _______, _______,                            _______,                   _______, _______, _______, _______, _______, _______
     41   ),
     42 
     43 };
     44 
     45 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     46   // Send keystrokes to host keyboard, if connected (see readme)
     47   process_record_remote_kb(keycode, record);
     48   switch(keycode) {
     49     case KC_CUST: //custom macro
     50       if (record->event.pressed) {
     51       }
     52     break;
     53 
     54     case RM_1: //remote macro 1
     55       if (record->event.pressed) {
     56       }
     57     break;
     58 
     59     case RM_2: //remote macro 2
     60       if (record->event.pressed) {
     61       }
     62     break;
     63 
     64     case RM_3: //remote macro 3
     65       if (record->event.pressed) {
     66       }
     67     break;
     68 
     69     case RM_4: //remote macro 4
     70       if (record->event.pressed) {
     71       }
     72     break;
     73 
     74   }
     75 return true;
     76 }
     77 
     78 // RGB config, for changing RGB settings on non-VIA firmwares
     79 void change_RGB(bool clockwise) {
     80     bool shift = get_mods() & MOD_MASK_SHIFT;
     81     bool alt = get_mods() & MOD_MASK_ALT;
     82     bool ctrl = get_mods() & MOD_MASK_CTRL;
     83 
     84     if (clockwise) {
     85         if (alt) {
     86             rgblight_increase_hue();
     87         } else if (ctrl) {
     88             rgblight_increase_val();
     89         } else if (shift) {
     90             rgblight_increase_sat();
     91         } else {
     92             rgblight_step();
     93         }
     94 
     95   } else {
     96       if (alt) {
     97             rgblight_decrease_hue();
     98         } else if (ctrl) {
     99             rgblight_decrease_val();
    100         } else if (shift) {
    101             rgblight_decrease_sat();
    102         } else {
    103             rgblight_step_reverse();
    104         }
    105     }
    106 }
    107 
    108 bool encoder_update_user(uint8_t index, bool clockwise) {
    109   if (layer_state_is(1)) {
    110     //change RGB settings
    111     change_RGB(clockwise);
    112   }
    113   else {
    114     if (clockwise) {
    115       tap_code(KC_VOLU);
    116   } else {
    117       tap_code(KC_VOLD);
    118     }
    119   }
    120     return true;
    121 }
    122 
    123 void matrix_init_user(void) {
    124   // Initialize remote keyboard, if connected (see readme)
    125   matrix_init_remote_kb();
    126 }
    127 
    128 void matrix_scan_user(void) {
    129   // Scan and parse keystrokes from remote keyboard, if connected (see readme)
    130   matrix_scan_remote_kb();
    131 }