qmk_firmware

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

rubi.c (2315B)


      1 /* Copyright 2021 gregorio
      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 "rubi.h"
     17 
     18 uint8_t oled_mode = OLED_MODE_DEFAULT;
     19 
     20 char calc_result_display[CALC_DIGITS+1] = "";
     21 char calc_operator_display = ' ';
     22 char calc_status_display[CALC_DIGITS+1] = "";
     23 uint8_t calc_display_lines = 2;
     24 
     25 const char keycode_to_ascii_lut[58] = {0, 0, 0, 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 0, 0, 0, '\t', ' ', '-', '=', '[', ']', '\\', 0, ';', '\'', '`', ',', '.', '/'};
     26 
     27 uint8_t encoder_mode = ENC_MODE_VOLUME;
     28 
     29 bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
     30     if (keycode < 58 && keycode != KC_TAB) {
     31         if (record->event.pressed) {
     32             calcInput(keycode_to_ascii_lut[(uint8_t)keycode]);
     33         }
     34         return false;
     35     }
     36     switch (keycode) {
     37         case ENC_PRESS:
     38             if (record->event.pressed) {
     39                 uint16_t mapped_code = handle_encoder_press();
     40                 if (mapped_code != 0) {
     41                     tap_code16(mapped_code);
     42                 }
     43             }
     44             return false;
     45         case CL_PLUS:
     46             if (record->event.pressed) {
     47                 calcInput('+');
     48             }
     49             return false;
     50         case CL_STAR:
     51             if (record->event.pressed) {
     52                 calcInput('*');
     53             }
     54             return false;
     55         case CL_TYPE:
     56             if (record->event.pressed) {
     57                 send_string(calc_result_display);
     58             }
     59             return false;
     60         default:
     61             break;
     62     }
     63 
     64     return process_record_user_oled(keycode, record);
     65 }