riblee.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* Copyright 2020 Janos Daniel Reibl <janos.daniel.reibl@protonmail.com> @riblee
  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 "riblee.h"
  17. #include <string.h>
  18. // Tap Dance functions
  19. void dance_key_a (qk_tap_dance_state_t *state, void *user_data) {
  20. if (state->count == 1) {
  21. SEND_STRING("a");
  22. reset_tap_dance(state);
  23. } else if (state->count == 2) {
  24. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  25. send_unicode_string("á");
  26. } else {
  27. send_unicode_string("Á");
  28. }
  29. reset_tap_dance(state);
  30. }
  31. }
  32. void dance_key_e (qk_tap_dance_state_t *state, void *user_data) {
  33. if (state->count == 1) {
  34. SEND_STRING("e");
  35. reset_tap_dance(state);
  36. } else if (state->count == 2) {
  37. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  38. send_unicode_string("é");
  39. } else {
  40. send_unicode_string("É");
  41. }
  42. reset_tap_dance(state);
  43. }
  44. }
  45. void dance_key_i (qk_tap_dance_state_t *state, void *user_data) {
  46. if (state->count == 1) {
  47. SEND_STRING("i");
  48. reset_tap_dance(state);
  49. } else if (state->count == 2) {
  50. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  51. send_unicode_string("í");
  52. } else {
  53. send_unicode_string("Í");
  54. }
  55. reset_tap_dance(state);
  56. }
  57. }
  58. void dance_key_o (qk_tap_dance_state_t *state, void *user_data) {
  59. if (state->count == 1) {
  60. SEND_STRING("o");
  61. reset_tap_dance(state);
  62. } else if (state->count == 2) {
  63. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  64. send_unicode_string("ó");
  65. } else {
  66. send_unicode_string("Ó");
  67. }
  68. reset_tap_dance(state);
  69. } else if (state->count == 3) {
  70. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  71. send_unicode_string("ö");
  72. } else {
  73. send_unicode_string("Ö");
  74. }
  75. reset_tap_dance(state);
  76. } else if (state->count == 4) {
  77. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  78. send_unicode_string("ő");
  79. } else {
  80. send_unicode_string("Ő");
  81. }
  82. reset_tap_dance(state);
  83. }
  84. }
  85. void dance_key_u (qk_tap_dance_state_t *state, void *user_data) {
  86. if (state->count == 1) {
  87. SEND_STRING("u");
  88. reset_tap_dance(state);
  89. } else if (state->count == 2) {
  90. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  91. send_unicode_string("ú");
  92. } else {
  93. send_unicode_string("Ú");
  94. }
  95. reset_tap_dance(state);
  96. } else if (state->count == 3) {
  97. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  98. send_unicode_string("ü");
  99. } else {
  100. send_unicode_string("Ü");
  101. }
  102. reset_tap_dance(state);
  103. } else if (state->count == 4) {
  104. if (!(keyboard_report->mods & MOD_MASK_SHIFT)) {
  105. send_unicode_string("ű");
  106. } else {
  107. send_unicode_string("Ű");
  108. }
  109. reset_tap_dance(state);
  110. }
  111. }
  112. layer_state_t layer_state_set_user(layer_state_t state) {
  113. return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  114. }
  115. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  116. switch (keycode) {
  117. case QWERTY:
  118. if (record->event.pressed) {
  119. set_single_persistent_default_layer(_QWERTY);
  120. }
  121. return false;
  122. break;
  123. case COLEMAK:
  124. if (record->event.pressed) {
  125. set_single_persistent_default_layer(_COLEMAK);
  126. }
  127. return false;
  128. break;
  129. case DVORAK:
  130. if (record->event.pressed) {
  131. set_single_persistent_default_layer(_DVORAK);
  132. }
  133. return false;
  134. break;
  135. case WORKMAN:
  136. if (record->event.pressed) {
  137. set_single_persistent_default_layer(_WORKMAN);
  138. }
  139. return false;
  140. break;
  141. case HUNGARIAN:
  142. if (record->event.pressed) {
  143. set_single_persistent_default_layer(_HUNGARIAN);
  144. }
  145. return false;
  146. break;
  147. }
  148. return true;
  149. };
  150. void keyboard_pre_init_user(void) {
  151. // Set C13 pin as output
  152. setPinOutput(C13);
  153. // Turn off the LED
  154. writePinHigh(C13);
  155. }