qmk_firmware

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

keymap.c (1907B)


      1   /* Copyright 2020 swiftrax
      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 
     20 [0] = LAYOUT(
     21   TO(1), //windows
     22   KC_MSTP, KC_MPLY,
     23   KC_MPRV, KC_MNXT),
     24 
     25 [1] = LAYOUT( //macOS
     26   TO(2),
     27   KC_MSTP, KC_MPLY,
     28   KC_MRWD, KC_MFFD),
     29 
     30 [2] = LAYOUT(
     31   TO(0),
     32   KC_HOME, KC_PGUP,
     33   KC_END,  KC_PGDN),
     34 };
     35 
     36 bool encoder_update_user(uint8_t index, bool clockwise) {
     37   if(IS_LAYER_ON(2)){
     38     if (clockwise)
     39       tap_code(KC_LEFT);
     40     else
     41       tap_code(KC_RGHT);
     42   }
     43   else{
     44     if(clockwise)
     45       tap_code(KC_VOLU);
     46     else
     47       tap_code(KC_VOLD);
     48   }
     49     return true;
     50 }
     51 
     52 void matrix_init_user(void) {
     53   // set top LED to output and off (active low)
     54   gpio_set_pin_output(D5);
     55   gpio_write_pin_high(D5);
     56   // set middle LED to output and off (active low)
     57   gpio_set_pin_output(D4);
     58   gpio_write_pin_high(D4);
     59   // set bottom LED to output and off (active low)
     60   gpio_set_pin_output(D3);
     61   gpio_write_pin_high(D3);
     62 }
     63 
     64 // write to above indicators in a binary fashion based on current layer
     65 layer_state_t layer_state_set_user(layer_state_t state) {
     66     gpio_write_pin(D5, get_highest_layer(state));
     67     gpio_write_pin(D4, !layer_state_cmp(state, 1));
     68     gpio_write_pin(D3, !layer_state_cmp(state, 2));
     69     return state;
     70 }