qmk_firmware

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

keymap.c (8625B)


      1  /* Copyright 2021 OpenAnnePro community
      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 
     17 #include QMK_KEYBOARD_H
     18 
     19 enum anne_pro_layers {
     20     BASE,
     21     FN1,
     22     FN2,
     23 };
     24 
     25 // clang-format off
     26 // Key symbols are based on QMK. Use them to remap your keyboard
     27 /*
     28 * Layer BASE
     29 * ,-----------------------------------------------------------------------------------------.
     30 * | esc |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  0  |  -  |  =  |    Bksp   |
     31 * |-----------------------------------------------------------------------------------------+
     32 * | Tab    |  q  |  w  |  e  |  r  |  t  |  y  |  u  |  i  |  o  |  p  |  [  |  ]  |   \    |
     33 * |-----------------------------------------------------------------------------------------+
     34 * | Caps    |  a  |  s  |  d  |  f  |  g  |  h  |  j  |  k  |  l  |  ;  |  '  |    Enter    |
     35 * |-----------------------------------------------------------------------------------------+
     36 * | Shift      |  z  |  x  |  c  |  v  |  b  |  n  |  m  |  ,  |  .  |  /  |    Shift       |
     37 * |-----------------------------------------------------------------------------------------+
     38 * | Ctrl  |  L1   |  Alt  |               space             |  Alt  |  FN1  |  FN2  | Ctrl  |
     39 * \-----------------------------------------------------------------------------------------/
     40 * Layer TAP in BASE
     41 * ,-----------------------------------------------------------------------------------------.
     42 * |     |     |     |     |     |     |     |     |     |     |     |     |     |           |
     43 * |-----------------------------------------------------------------------------------------+
     44 * |        |     |     |     |     |     |     |     |     |     |     |     |     |        |
     45 * |-----------------------------------------------------------------------------------------+
     46 * |         |     |     |     |     |     |     |     |     |     |     |     |             |
     47 * |-----------------------------------------------------------------------------------------+
     48 * |            |     |     |     |     |     |     |     |     |     |     |       UP       |
     49 * |-----------------------------------------------------------------------------------------+
     50 * |       |       |       |                                 |       |  LEFT | DOWN  | RIGHT |
     51 * \-----------------------------------------------------------------------------------------/
     52 */
     53  const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     54  [BASE] = LAYOUT_60_ansi( /* Base */
     55     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,
     56     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,
     57     LT(FN1, 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,
     58     KC_LSFT,                   KC_Z,    KC_X, KC_C, KC_V, KC_B,   KC_N, KC_M, KC_COMM, KC_DOT,           KC_SLSH,          RSFT_T(KC_UP),
     59     KC_LCTL,          KC_LGUI, KC_LALT,                   KC_SPC,             KC_RALT, LT(FN1, KC_LEFT), LT(FN2, KC_DOWN), RCTL_T(KC_RGHT)
     60 ),
     61   /*
     62   * Layer FN1
     63   * ,-----------------------------------------------------------------------------------------.
     64   * |  `  |  F1 |  F2 |  F3 |  F4 |  F5 |  F6 |  F7 |  F8 |  F9 | F10 | F11 | F12 |  DELETE   |
     65   * |-----------------------------------------------------------------------------------------+
     66   * | Tab    |  q  | UP  |  e  |  r  |  t  |  y  |  u  |  i  |  o  | PS | HOME | END |   \    |
     67   * |-----------------------------------------------------------------------------------------+
     68   * | Esc     |LEFT |DOWN |RIGHT|  f  |  g  |  h  |  j  |  k  |  l  | PGUP|PGDN |    Enter    |
     69   * |-----------------------------------------------------------------------------------------+
     70   * | Shift      |V-UP |V-DWN|MUTE |  v  |  b  |  n  |  m  |  ,  |INSRT| DEL |    Shift       |
     71   * |-----------------------------------------------------------------------------------------+
     72   * | Ctrl  |  L1   |  Alt  |               space             |  Alt  |  FN1  |  FN2  | Ctrl  |
     73   * \-----------------------------------------------------------------------------------------/
     74   *
     75   */
     76  [FN1] = LAYOUT_60_ansi( /* FN1 */
     77     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_DEL,
     78     _______, _______, KC_UP,   _______, _______, _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END,  _______,
     79     _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
     80     _______,          KC_VOLU, KC_VOLD, KC_MUTE, _______, _______, _______, _______, _______, KC_INS,  KC_DEL,  _______,
     81     _______, _______, _______,                            _______,                   _______, _______, MO(FN2), _______
     82 ),
     83   /*
     84   * Layer FN2
     85   * ,-----------------------------------------------------------------------------------------.
     86   * |  ~  | BT1 | BT2 | BT3 | BT4 |  F5 |  F6 |  F7 |  F8 |LEDTG|LEDI+|LEDPV|LEDNX|    Bksp   |
     87   * |-----------------------------------------------------------------------------------------+
     88   * | Tab    |  q  | UP  |  e  |  r  |  t  |  y  |  u  |  i  |  o  | PS | HOME | END |   \    |
     89   * |-----------------------------------------------------------------------------------------+
     90   * | Esc     |LEFT |DOWN |RIGHT|  f  |  g  |  h  |  j  |  k  |  l  | PGUP|PGDN |    Enter    |
     91   * |-----------------------------------------------------------------------------------------+
     92   * | Shift      |  z  |  x  |  c  |  v  |  b  |  n  |  m  |  ,  |INSRT| DEL |    Shift       |
     93   * |-----------------------------------------------------------------------------------------+
     94   * | Ctrl  |  L1   |  Alt  |               space             |  Alt  |  FN1  |  FN2  | Ctrl  |
     95   * \-----------------------------------------------------------------------------------------/
     96   *
     97   */
     98  [FN2] = LAYOUT_60_ansi( /* FN2 */
     99     _______, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, _______, KC_AP_RGB_MOD, KC_AP_RGB_TOG, KC_AP_RGB_VAD, KC_AP_RGB_VAI, _______,
    100     _______, _______,    KC_UP,      _______,    _______,    _______, _______, _______, _______, _______, KC_PSCR, KC_HOME, KC_END,  _______,
    101     _______, KC_LEFT,    KC_DOWN,    KC_RGHT,    _______,    _______, _______, _______, _______, _______, KC_PGUP, KC_PGDN, _______,
    102     _______,             _______,    _______,    _______,    _______, _______, _______, _______, _______, KC_INS,  KC_DEL,  _______,
    103     _______, _______,    _______,                                     _______,                   _______, _______, _______, _______
    104  ),
    105 };
    106 // clang-format on
    107 
    108 void keyboard_post_init_user(void) {
    109     ap2_led_enable();
    110     ap2_led_set_profile(7);
    111 }
    112 
    113 layer_state_t layer_state_set_user(layer_state_t state) {
    114     switch (get_highest_layer(state)) {
    115         case FN1:
    116             // Set the leds to green
    117             ap2_led_set_foreground_color(0x00, 0xFF, 0x00);
    118             break;
    119         case FN2:
    120             // Set the leds to blue
    121             ap2_led_set_foreground_color(0x00, 0x00, 0xFF);
    122             break;
    123         default:
    124             // Reset back to the current profile
    125             ap2_led_reset_foreground_color();
    126             break;
    127     }
    128     return state;
    129 }
    130 
    131 // The function to handle the caps lock logic
    132 // It's called after the capslock changes state or after entering layers 1 and 2.
    133 bool led_update_user(led_t leds) {
    134     if (leds.caps_lock) {
    135         // Set the caps-lock to red
    136         const ap2_led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0xff};
    137         ap2_led_sticky_set_key(2, 0, color);
    138         /* NOTE: Instead of colouring the capslock only, you can change the whole
    139            keyboard with ap2_led_mask_set_mono */
    140     } else {
    141         // Reset the capslock if there is no layer active
    142         ap2_led_unset_sticky_key(2, 0);
    143     }
    144 
    145     return true;
    146 }