qmk_firmware

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

keymap.c (3393B)


      1 /* Copyright 2020 KemoNine
      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 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     19 /* Keymap (Base Layer) Default Layer
     20    * |----------------------------|
     21    * | 1 | 2  | 3  | 4 |          |
     22    * | 5 | 6  | 7  | 8 |          |
     23    * | 9 | 10 | 11 |              |
     24    * |----------------------------|
     25    */
     26 [0] = LAYOUT(
     27   MS_BTN4, MS_BTN2, MS_UP,   MS_BTN1,
     28   MS_BTN5, MS_LEFT, MS_DOWN, MS_RGHT,
     29   MS_ACL0, MS_ACL1, MS_ACL2
     30   )
     31 };
     32 
     33 // Standard encoder functionality
     34 bool encoder_update_user(uint8_t index, bool clockwise) {
     35     // Process encoder rotational movements
     36     if (index == 0) { /* First encoder */
     37         if (clockwise) {
     38             tap_code(KC_AUDIO_VOL_DOWN);
     39         } else {
     40             tap_code(KC_AUDIO_VOL_UP);
     41         }
     42     } else if (index == 1) { /* Second encoder */
     43         if (clockwise) {
     44             tap_code(MS_WHLU);
     45         } else {
     46             tap_code(MS_WHLD);
     47         }
     48     }
     49     return true;
     50 }
     51 
     52 // Encoder press / tilt event handling
     53 // the core lynepad implementation will update the below variables on each matrix scan
     54 // Update the various codes below for customizing the tilt / push config
     55 
     56 extern int16_t enc1Center;
     57 extern int16_t enc1CenterPrev;
     58 extern int16_t enc2Center;
     59 extern int16_t enc2CenterPrev;
     60 extern int16_t enc2Up;
     61 extern int16_t enc2UpPrev;
     62 extern int16_t enc2Down;
     63 extern int16_t enc2DownPrev;
     64 extern int16_t enc2Left;
     65 extern int16_t enc2LeftPrev;
     66 extern int16_t enc2Right;
     67 extern int16_t enc2RightPrev;
     68 
     69 void matrix_scan_user(void) {
     70     if (enc1Center != enc1CenterPrev) {
     71         if (enc1Center < ENC_TILT_THRESHOLD) {
     72         }
     73         else {
     74             reset_keyboard();
     75         }
     76     }
     77     if (enc2Center != enc2CenterPrev) {
     78         if (enc2Center < ENC_TILT_THRESHOLD) {
     79             register_code16(MS_BTN3);
     80         }
     81         else {
     82             unregister_code16(MS_BTN3);
     83         }
     84         /*
     85          * Encoder sets ALL values when center is pressed so bail out at this point
     86          * to avoid the rest of the encoder buttons registering events
     87          */
     88         return;
     89     }
     90     if (enc2Up != enc2UpPrev) {
     91         if (enc2Up < ENC_TILT_THRESHOLD) {
     92         }
     93         else {
     94             rgblight_increase_val_noeeprom();
     95         }
     96     }
     97     if (enc2Down != enc2DownPrev) {
     98         if (enc2Down < ENC_TILT_THRESHOLD) {
     99         }
    100         else {
    101             rgblight_decrease_val_noeeprom();
    102         }
    103     }
    104     if (enc2Left != enc2LeftPrev) {
    105         if (enc2Left < ENC_TILT_THRESHOLD) {
    106         }
    107         else {
    108             rgblight_toggle_noeeprom();
    109         }
    110     }
    111     if (enc2Right != enc2RightPrev) {
    112         if (enc2Right < ENC_TILT_THRESHOLD) {
    113         }
    114         else {
    115             rgblight_step_noeeprom();
    116         }
    117     }
    118 }