keymap.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. Copyright 2021-2022 Alin M Elena <alinm.elena@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include QMK_KEYBOARD_H
  15. #include "keymap_danish.h"
  16. // clang-format off
  17. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  18. [_QW] = LAYOUT_ortho_5x13(
  19. KC_ESC, DK_1 , DK_2 , DK_3 , DK_4 , DK_5 , DK_6 , DK_7 , DK_8 , DK_9 , DK_0 , DK_PLUS, KC_BSPC ,
  20. KC_TAB, DK_Q , DK_W , DK_E , DK_R , DK_T , DK_Y , DK_U , DK_I , DK_O , DK_P , DK_ARNG, DK_DIAE ,
  21. DK_QUOT, DK_A , DK_S , DK_D , DK_F , DK_G , DK_H , DK_J , DK_K , DK_L , DK_AE , DK_OSTR, KC_ENT ,
  22. SC_LSPO, DK_LABK, DK_Z , DK_X , DK_C , DK_V , DK_B , DK_N , DK_M , DK_COMM, DK_DOT , KC_UP , DK_MINS ,
  23. KC_LCTL, KC_LGUI, TT(_LWR), KC_LALT, TT(_RSE), KC_SPC, KC_SPC, KC_SPC, KC_RALT, SC_RSPC, KC_LEFT, KC_DOWN, KC_RGHT),
  24. [_LWR] = LAYOUT_ortho_5x13(
  25. DK_HALF, KC_MUTE, KC_VOLU, KC_VOLD, KC_MPRV, KC_MPLY, KC_MNXT, G(KC_P), KC_SLEP, KC_WAKE, KC_PSCR, KC_DEL , DK_ACUT ,
  26. KC_BTN3, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  27. KC_BTN2, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  28. _______, KC_BTN1, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_U, _______ ,
  29. _______, KC_BTN4, _______, _______, _______, _______, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R),
  30. [_RSE] = LAYOUT_ortho_5x13(
  31. KC_ESC , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 ,
  32. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  33. KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ ,
  34. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_WH_U, _______ ,
  35. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_R),
  36. [_ADJ] = LAYOUT_ortho_5x13(
  37. RGB_MOD,RGB_RMOD, A(KC_F2), _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_T, RGB_M_SW ,
  38. RGB_HUI, RGB_HUD, RGB_M_P , _______, QK_BOOT, _______, _______, _______, _______, _______, _______, _______, RGB_M_SN ,
  39. RGB_SAI, RGB_SAD, RGB_M_B , _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_K ,
  40. RGB_VAI, RGB_VAD, RGB_M_R , _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_X ,
  41. RGB_TOG, _______, _______ , _______, _______, _______, _______, _______, _______, _______, _______, RGB_M_TW, RGB_M_G),
  42. };
  43. // clang-format on
  44. bool led_update_user(led_t led_state) {
  45. // Disable the default LED update code, so that lock LEDs could be reused to show layer status.
  46. return false;
  47. }
  48. void matrix_scan_user(void) {
  49. toggle_leds();
  50. }
  51. bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  52. switch (keycode) {
  53. case (TT(_LWR)):
  54. if (!record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
  55. // This runs before the TT() handler toggles the layer state, so the current layer state is the opposite of the final one after toggle.
  56. set_led_toggle(_LWR, !layer_state_is(_LWR));
  57. }
  58. return true;
  59. break;
  60. case (TT(_RSE)):
  61. if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) {
  62. set_led_toggle(_RSE, !layer_state_is(_RSE));
  63. }
  64. return true;
  65. break;
  66. default:
  67. return true;
  68. }
  69. }
  70. layer_state_t layer_state_set_user(layer_state_t state) {
  71. #ifdef RGBLIGHT_ENABLE
  72. set_rgb_layers(state);
  73. #endif
  74. return update_tri_layer_state(state, _LWR, _RSE, _ADJ);
  75. }
  76. #ifdef RGBLIGHT_ENABLE
  77. layer_state_t default_layer_state_set_user(layer_state_t state) {
  78. set_default_rgb_layers(state);
  79. return state;
  80. }
  81. #endif
  82. void keyboard_post_init_user(void) {
  83. #ifdef RGBLIGHT_ENABLE
  84. // Enable the LED layers
  85. rgblight_layers = my_rgb();
  86. #endif
  87. #ifdef OLED_ENABLE
  88. init_timer();
  89. #endif
  90. }