qmk_firmware

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

keymap.c (3914B)


      1 /* Copyright 2019 niltea
      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 #ifdef OLED_ENABLE
     18   #include <string.h>
     19   #include "lib/oled_helper.h"
     20 #endif
     21 
     22 // Defines the keycodes used by our macros in process_record_user
     23 enum custom_keycodes {
     24     KEY_01 = SAFE_RANGE,
     25     KEY_02,
     26     KEY_03,
     27     KEY_04,
     28     KEY_05,
     29     KEY_06,
     30     KEY_07,
     31     KEY_08,
     32     KEY_09,
     33     KEY_10,
     34     KEY_11,
     35     KEY_12,
     36     KEY_13,
     37     KEY_14
     38 };
     39 
     40 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     41     [0] = LAYOUT(
     42         KEY_01, KEY_02, KEY_03, KEY_04, KEY_05,
     43         KEY_06, KEY_07, KEY_08, KEY_09, KEY_10,
     44                 KEY_11, KEY_12, KEY_13, KEY_14
     45     ),
     46 };
     47 
     48 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     49     switch (keycode) {
     50         case KEY_01:
     51             if (record->event.pressed) {
     52                 SEND_STRING("R1C1");
     53             }
     54             break;
     55         case KEY_02:
     56             if (record->event.pressed) {
     57                 SEND_STRING("R1C2");
     58             }
     59             break;
     60         case KEY_03:
     61             if (record->event.pressed) {
     62                 SEND_STRING("R1C3");
     63             }
     64             break;
     65         case KEY_04:
     66             if (record->event.pressed) {
     67                 SEND_STRING("R1C4");
     68             }
     69             break;
     70         case KEY_05:
     71             if (record->event.pressed) {
     72                 SEND_STRING("ENCODER-UPPER:Button");
     73             }
     74             break;
     75 
     76         case KEY_06:
     77             if (record->event.pressed) {
     78                 SEND_STRING("R2C1");
     79             }
     80             break;
     81         case KEY_07:
     82             if (record->event.pressed) {
     83                 SEND_STRING("R2C2");
     84             }
     85             break;
     86         case KEY_08:
     87             if (record->event.pressed) {
     88                 SEND_STRING("R2C3");
     89             }
     90             break;
     91 
     92         case KEY_09:
     93             if (record->event.pressed) {
     94                 SEND_STRING("R2C4");
     95             }
     96             break;
     97         case KEY_10:
     98             if (record->event.pressed) {
     99                 SEND_STRING("ENCODER-LOWER:Button");
    100             }
    101             break;
    102         case KEY_11:
    103             if (record->event.pressed) {
    104                 SEND_STRING("R3C1");
    105             }
    106             break;
    107         case KEY_12:
    108             if (record->event.pressed) {
    109                 SEND_STRING("R3C2");
    110             }
    111             break;
    112         case KEY_13:
    113             if (record->event.pressed) {
    114                 SEND_STRING("R3C3");
    115             }
    116             break;
    117         case KEY_14:
    118             if (record->event.pressed) {
    119                 SEND_STRING("R3C4");
    120             }
    121             break;
    122     }
    123     return true;
    124 }
    125 
    126 bool encoder_update_user(uint8_t index, bool clockwise) {
    127   if (index == 0) { /* the upper encoder */
    128     if (clockwise) {
    129       SEND_STRING("ENCODER-UPPER:CW");
    130     } else {
    131       SEND_STRING("ENCODER-UPPER:CCW");
    132     }
    133   } else if (index == 1) { /* the lower encoder */
    134     if (clockwise) {
    135       SEND_STRING("ENCODER-LOWER:CW");
    136     } else {
    137       SEND_STRING("ENCODER-LOWER:CCW");
    138     }
    139   }
    140     return true;
    141 }
    142 
    143 // OLED Display
    144 #ifdef OLED_ENABLE
    145 bool oled_task_user(void) {
    146   render_row(0, "TEST");
    147   render_row(1, "test");
    148   render_row(2, "TEST");
    149   render_row(3, "test");
    150     return false;
    151 }
    152 #endif // #ifdef OLED_ENABLE