qmk_firmware

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

trailmix.c (2705B)


      1 /*
      2 Copyright 2023 Alberto Pavano "ATron789" <albertopavano@gmail.com>
      3 
      4 This program is free software: you can redistribute it and/or modify
      5 it under the terms of the GNU General Public License as published by
      6 the Free Software Foundation, either version 2 of the License, or
      7 (at your option) any later version.
      8 
      9 This program is distributed in the hope that it will be useful,
     10 but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12 GNU General Public License for more details.
     13 
     14 You should have received a copy of the GNU General Public License
     15 along with this program.  If not, see <http://www.gnu.org/licenses/>.
     16 */
     17 
     18 #include "quantum.h"
     19 
     20 enum layers { _BASE, _LOWER, _RAISE, _ADJUST };
     21 
     22 #ifdef ENCODER_ENABLE
     23 bool encoder_update_kb(uint8_t index, bool clockwise) {
     24     if (!encoder_update_user(index, clockwise)) {
     25         return false;
     26     }
     27     switch (get_highest_layer(layer_state)) {
     28         case _BASE:
     29             if (index == 0) {
     30                 if (clockwise) {
     31                     tap_code(KC_VOLU);
     32                 } else {
     33                     tap_code(KC_VOLD);
     34                 }
     35             } else if (index == 1) {
     36                 if (clockwise) {
     37                     tap_code(MS_WHLD);
     38                 } else {
     39                     tap_code(MS_WHLU);
     40                 }
     41             }
     42             break;
     43         case _RAISE:
     44             if (index == 0) {
     45                 if (clockwise) {
     46                     tap_code(KC_MNXT);
     47                 } else {
     48                     tap_code(KC_MPRV);
     49                 }
     50             } else if (index == 1) {
     51                 if (clockwise) {
     52                     tap_code(MS_WHLR);
     53                 } else {
     54                     tap_code(MS_WHLL);
     55                 }
     56             }
     57             break;
     58         case _LOWER:
     59             if (index == 0) {
     60                 if (clockwise) {
     61                     tap_code(KC_PGUP);
     62                 } else {
     63                     tap_code(KC_PGDN);
     64                 }
     65             } else if (index == 1) {
     66                 if (clockwise) {
     67                     tap_code(KC_END);
     68                 } else {
     69                     tap_code(KC_HOME);
     70                 }
     71             }
     72             break;
     73         case _ADJUST:
     74             if (index == 0) {
     75                 if (clockwise) {
     76                     tap_code(MS_RGHT);
     77                 } else {
     78                     tap_code(MS_LEFT);
     79                 }
     80             } else if (index == 1) {
     81                 if (clockwise) {
     82                     tap_code(MS_DOWN);
     83                 } else {
     84                     tap_code(MS_UP);
     85                 }
     86             }
     87             break;
     88     }
     89     return true;
     90 }
     91 #endif