You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.6 KiB

  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. uint8_t oled_mode = OLED_MODE_DEFAULT;
  18. char calc_result_display[CALC_DIGITS+1] = "";
  19. char calc_operator_display = ' ';
  20. char calc_status_display[CALC_DIGITS+1] = "";
  21. uint8_t calc_display_lines = 2;
  22. 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, ';', '\'', '`', ',', '.', '/'};
  23. uint8_t encoder_mode = ENC_MODE_VOLUME;
  24. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  25. if (keycode < 58 && keycode != KC_TAB) {
  26. if (record->event.pressed) {
  27. calcInput(keycode_to_ascii_lut[(uint8_t)keycode]);
  28. }
  29. return false;
  30. }
  31. switch (keycode) {
  32. case ENC_PRESS:
  33. if (record->event.pressed) {
  34. uint16_t mapped_code = handle_encoder_press();
  35. if (mapped_code != 0) {
  36. tap_code16(mapped_code);
  37. }
  38. }
  39. return false;
  40. case CL_PLUS:
  41. if (record->event.pressed) {
  42. calcInput('+');
  43. }
  44. return false;
  45. case CL_STAR:
  46. if (record->event.pressed) {
  47. calcInput('*');
  48. }
  49. return false;
  50. case CL_TYPE:
  51. if (record->event.pressed) {
  52. send_string(calc_result_display);
  53. }
  54. return false;
  55. default:
  56. break;
  57. }
  58. return process_record_user_oled(keycode, record);
  59. }
  60. bool led_update_kb(led_t led_state) {
  61. bool res = led_update_user(led_state);
  62. if (res) {
  63. writePin(C6, led_state.num_lock);
  64. }
  65. return true;
  66. }
  67. bool encoder_update_kb(uint8_t index, bool clockwise) {
  68. if (!encoder_update_user(index, clockwise)) { return false; }
  69. return true;
  70. }