keymap.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* Copyright 2019 Chuck Lauer Vose <vosechu@gmail.com>
  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. // // Debugging
  18. // #include <print.h>
  19. #define BASE TO(_BASE)
  20. #define PANIC TO(_PANIC)
  21. #define FLIGHT TO(_FLIGHT)
  22. #define RCS TO(_RCS)
  23. enum my_layers {
  24. _BASE = 0,
  25. _PANIC,
  26. _FLIGHT,
  27. _RCS
  28. };
  29. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  30. [_BASE] = LAYOUT(
  31. KC_MUTE, PANIC , XXXXXXX,
  32. FLIGHT , XXXXXXX, RCS ,
  33. XXXXXXX, XXXXXXX, XXXXXXX
  34. ),
  35. [_PANIC] = LAYOUT(
  36. QK_BOOT, BASE , XXXXXXX,
  37. _______, XXXXXXX, _______,
  38. KC_F2 , KC_F5 , KC_F9
  39. ),
  40. [_FLIGHT] = LAYOUT(
  41. XXXXXXX, _______, KC_M ,
  42. BASE , KC_W , _______,
  43. KC_A , KC_S , KC_D
  44. ),
  45. [_RCS] = LAYOUT(
  46. XXXXXXX, _______, XXXXXXX,
  47. _______, KC_I , BASE ,
  48. KC_J , KC_K , KC_L
  49. )
  50. };
  51. bool base_mode = false;
  52. bool panic_mode = false;
  53. bool flight_mode = false;
  54. bool rcs_mode = false;
  55. layer_state_t layer_state_set_user(layer_state_t state) {
  56. base_mode = false;
  57. panic_mode = false;
  58. flight_mode = false;
  59. rcs_mode = false;
  60. switch (get_highest_layer(state)) {
  61. case _PANIC:
  62. panic_mode = true; // For use in encoder evaluation
  63. rgblight_sethsv_noeeprom(HSV_RED);
  64. break;
  65. case _FLIGHT:
  66. flight_mode = true; // For use in encoder evaluation
  67. rgblight_sethsv_noeeprom(HSV_CYAN);
  68. break;
  69. case _RCS:
  70. rcs_mode = true; // For use in encoder evaluation
  71. rgblight_sethsv_noeeprom(HSV_BLUE);
  72. break;
  73. default: // for any other layers, or the default layer
  74. base_mode = true;
  75. rgblight_sethsv_noeeprom(HSV_SPRINGGREEN);
  76. break;
  77. }
  78. return state;
  79. }
  80. void keyboard_post_init_user(void) {
  81. // Call the post init code.
  82. rgblight_enable_noeeprom(); // enables Rgb, without saving settings
  83. rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 1); // sets mode to Slow breathing without saving
  84. rgblight_sethsv_noeeprom(HSV_SPRINGGREEN);
  85. }
  86. // bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  87. // switch (keycode) {
  88. // uprintf("Keycode: %s\n", keycode);
  89. // if (record->event.pressed) {
  90. // print("pressed");
  91. // // Do something when pressed
  92. // } else {
  93. // print("unpressed");
  94. // // Do something else when release
  95. // }
  96. // }
  97. // return true;
  98. // }
  99. bool encoder_update_user(uint8_t index, bool clockwise) {
  100. if(base_mode == true) {
  101. if (index == 0) {
  102. if (clockwise) {
  103. // Volume up
  104. tap_code(KC_VOLU);
  105. } else {
  106. // Volume down
  107. tap_code(KC_VOLD);
  108. }
  109. }
  110. else if (index == 1) {
  111. if (clockwise) {
  112. // Time warp faster
  113. tap_code(KC_DOT);
  114. } else {
  115. // Time warp slower
  116. tap_code(KC_COMM);
  117. }
  118. }
  119. }
  120. if(rcs_mode == true) {
  121. if (index == 0) {
  122. if (clockwise) {
  123. // RCS Forward
  124. tap_code(KC_H);
  125. } else {
  126. // RCS Backward
  127. tap_code(KC_N);
  128. }
  129. }
  130. else if (index == 1) {
  131. if (clockwise) {
  132. // RCS Rotate Left
  133. tap_code(KC_Q);
  134. } else {
  135. // RCS Rotate Right
  136. tap_code(KC_E);
  137. }
  138. }
  139. }
  140. if(flight_mode == true) {
  141. if (index == 0) {
  142. if (clockwise) {
  143. // Throttle up
  144. tap_code(KC_LSFT);
  145. } else {
  146. // Throttle down
  147. tap_code(KC_LCTL);
  148. }
  149. }
  150. else if (index == 1) {
  151. if (clockwise) {
  152. // Trim left
  153. tap_code16(LALT(KC_A));
  154. } else {
  155. // Trim right
  156. tap_code16(LALT(KC_D));
  157. }
  158. }
  159. }
  160. return true;
  161. }