keymap.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2021 JKDLAB. <jkdlab.co@gmail.com>
  3. * Copyright 2021 Jaehee <ljh34210329@gmail.com>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License,
  8. * or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see https://www.gnu.org/licenses/.
  17. */
  18. #include QMK_KEYBOARD_H
  19. char ascii = 0;
  20. enum custom_keycodes {
  21. BIN_0 = SAFE_RANGE,
  22. BIN_1,
  23. BIN_RETURN
  24. };
  25. enum layers {
  26. _BASE = 0
  27. };
  28. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  29. [_BASE] = LAYOUT(
  30. BIN_0, BIN_1,
  31. BIN_RETURN
  32. )
  33. };
  34. bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  35. switch (keycode) {
  36. case BIN_0:
  37. if (record->event.pressed) {
  38. ascii = ascii << 1;
  39. }
  40. return true;
  41. case BIN_1:
  42. if (record->event.pressed) {
  43. ascii = ascii << 1;
  44. ++ascii;
  45. }
  46. return true;
  47. case BIN_RETURN:
  48. if (record->event.pressed) {
  49. char str[2] = { ascii & 127, '\0' };
  50. send_string(str);
  51. ascii = 0;
  52. }
  53. return true;
  54. default:
  55. return true;
  56. }
  57. return true;
  58. }