qmk_firmware

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

keymap.c (2039B)


      1 /* Copyright 2019 Danny Nguyen <danny@keeb.io>
      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 encoder_names {
     19   _LEFT,
     20   _RIGHT,
     21   _MIDDLE,
     22 };
     23 
     24 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     25     /*
     26         | Knob 1: Vol Dn/Up |      | Knob 2: Page Dn/Up |
     27         | Press: Mute       | Home | Press: Play/Pause  |
     28         | Hold: Layer 2     | Up   | RGB Mode           |
     29         | Left              | Down | Right              |
     30      */
     31     [0] = LAYOUT(
     32         KC_MUTE, KC_HOME, KC_MPLY,
     33         MO(1)  , KC_UP  , RM_NEXT,
     34         KC_LEFT, KC_DOWN, KC_RGHT
     35     ),
     36     /*
     37         | QK_BOOT          | N/A  | Media Stop |
     38         | Held: Layer 2  | Home | RGB Mode   |
     39         | Media Previous | End  | Media Next |
     40      */
     41     [1] = LAYOUT(
     42         QK_BOOT  , BL_STEP, KC_STOP,
     43         _______, KC_HOME, RM_NEXT,
     44         KC_MPRV, KC_END , KC_MNXT
     45     ),
     46 };
     47 
     48 bool encoder_update_user(uint8_t index, bool clockwise) {
     49     if (index == _LEFT) {
     50         if (clockwise) {
     51             tap_code(KC_VOLU);
     52         } else {
     53             tap_code(KC_VOLD);
     54         }
     55     }
     56     else if (index == _MIDDLE) {
     57         if (clockwise) {
     58             tap_code(KC_DOWN);
     59         } else {
     60             tap_code(KC_UP);
     61         }
     62     }
     63     else if (index == _RIGHT) {
     64         if (clockwise) {
     65             tap_code(KC_PGDN);
     66         } else {
     67             tap_code(KC_PGUP);
     68         }
     69     }
     70     return false;
     71 }