logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (5032B)


  1. /* MIT License
  2. Copyright (c) 2019 Mattia Dal Ben
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in all
  10. copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. SOFTWARE.
  18. */
  19. #include QMK_KEYBOARD_H
  20. #include <stdio.h>
  21. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  22. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  23. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  24. // entirely and just use numbers.
  25. enum layers {
  26. _BL,
  27. _NV,
  28. _FN
  29. };
  30. enum custom_keycodes {
  31. KC_DBL0 = SAFE_RANGE,
  32. };
  33. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  34. /* Keymap _BL: (Base Layer) Default Layer
  35. * ,-------------------.
  36. * | NV | / | * |-/FN|
  37. * |----|----|----|----|
  38. * | 7 | 8 | 9 | |
  39. * |----|----|----| + |
  40. * | 4 | 5 | 6 | |
  41. * |----|----|----|----|
  42. * | 1 | 2 | 3 | |
  43. * |----|----|----| En |
  44. * | 0 | 00 | . | |
  45. * `-------------------'
  46. */
  47. [_BL] = LAYOUT(
  48. TG(_NV), KC_PSLS, KC_PAST, LT(_FN, KC_PMNS),
  49. KC_P7, KC_P8, KC_P9,
  50. KC_P4, KC_P5, KC_P6, KC_PPLS,
  51. KC_P1, KC_P2, KC_P3,
  52. KC_P0, KC_DBL0, KC_PDOT, KC_PENT
  53. ),
  54. /* Keymap _NV: Navigation layer
  55. * ,-------------------.
  56. * |INS |HOME|PGUP| |
  57. * |----|----|----|----|
  58. * |DEL |END |PGDN| |
  59. * |----|----|----| |
  60. * | | | | |
  61. * |----|----|----|----|
  62. * | | UP | | |
  63. * |----|----|----| |
  64. * |LEFT|DOWN|RIGH| |
  65. * `-------------------'
  66. */
  67. [_NV] = LAYOUT(
  68. KC_INS, KC_HOME, KC_PGUP, TG(_NV),
  69. KC_DEL, KC_END, KC_PGDN,
  70. XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
  71. XXXXXXX, KC_UP, XXXXXXX,
  72. KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX
  73. ),
  74. /* Keymap _FN: RGB Function Layer
  75. * ,-------------------.
  76. * |RMOD|RGBP|RTOG| FN |
  77. * |----|----|----|----|
  78. * |HUD |HUI | | |
  79. * |----|----|----| |
  80. * |SAD |SAI | | |
  81. * |----|----|----|----|
  82. * |VAD |VAS | | |
  83. * |----|----|----| |
  84. * |RST | | | |
  85. * `-------------------'
  86. */
  87. [_FN] = LAYOUT(
  88. UG_NEXT, RGB_M_P, UG_TOGG, _______,
  89. UG_HUED, UG_HUEU, XXXXXXX,
  90. UG_SATD, UG_SATU, XXXXXXX, XXXXXXX,
  91. UG_VALD, UG_VALU, XXXXXXX,
  92. QK_BOOT, XXXXXXX, XXXXXXX, XXXXXXX
  93. ),
  94. };
  95. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  96. switch (keycode) {
  97. case KC_DBL0:
  98. if (record->event.pressed) {
  99. SEND_STRING("00");
  100. } else {
  101. // when keycode KC_DBL0 is released
  102. }
  103. break;
  104. }
  105. return true;
  106. };
  107. #ifdef OLED_ENABLE
  108. oled_rotation_t oled_init_user(oled_rotation_t rotation) {
  109. return OLED_ROTATION_270; // flips the display 270 degrees
  110. }
  111. bool oled_task_user(void) {
  112. // Host Keyboard Layer Status
  113. oled_write_P(PSTR("Layer"), false);
  114. switch (get_highest_layer(layer_state)) {
  115. case _BL:
  116. oled_write_ln_P(PSTR(" BAS"), false);
  117. break;
  118. case _NV:
  119. oled_write_ln_P(PSTR(" NAV"), false);
  120. break;
  121. case _FN:
  122. oled_write_ln_P(PSTR(" RGB"), false);
  123. break;
  124. default:
  125. // Or use the write_ln shortcut over adding '\n' to the end of your string
  126. oled_write_ln_P(PSTR(" UND"), false);
  127. }
  128. // Host Keyboard LED Status
  129. led_t led_state = host_keyboard_led_state();
  130. oled_write_P(PSTR("-----"), false);
  131. oled_write_P(PSTR("Stats"), false);
  132. oled_write_P(led_state.num_lock ? PSTR("num:*") : PSTR("num:."), false);
  133. oled_write_P(led_state.caps_lock ? PSTR("cap:*") : PSTR("cap:."), false);
  134. oled_write_P(led_state.scroll_lock ? PSTR("scr:*") : PSTR("scr:."), false);
  135. // Host Keyboard RGB backlight status
  136. oled_write_P(PSTR("-----"), false);
  137. oled_write_P(PSTR("Light"), false);
  138. static char led_buf[30];
  139. snprintf(led_buf, sizeof(led_buf) - 1, "RGB:%cM: %2d\nh: %2ds: %2dv: %2d\n",
  140. rgblight_is_enabled() ? '*' : '.', (uint8_t)rgblight_get_mode(),
  141. (uint8_t)(rgblight_get_hue() / RGBLIGHT_HUE_STEP),
  142. (uint8_t)(rgblight_get_sat() / RGBLIGHT_SAT_STEP),
  143. (uint8_t)(rgblight_get_val() / RGBLIGHT_VAL_STEP));
  144. oled_write(led_buf, false);
  145. return false;
  146. }
  147. #endif