keymap.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright 2020 Geekboards ltd. (geekboards.ru / geekboards.de)
  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. #include <string.h>
  18. bool is_alt_tab_active = false;
  19. uint16_t alt_tab_timer = 0;
  20. enum custom_keycodes {
  21. ALT_TAB = USER00,
  22. };
  23. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  24. [0] = LAYOUT_ortho_2x4(
  25. LT(1, KC_MUTE), KC_VOLD, KC_VOLU, MACRO00,
  26. ALT_TAB, KC_MPRV, KC_MNXT, KC_MPLY
  27. ),
  28. [1] = LAYOUT_ortho_2x4(
  29. KC_TRNS, RGB_VAI, RGB_HUI, RGB_SPI,
  30. RGB_MOD, RGB_VAD, RGB_HUD, RGB_SPD
  31. ),
  32. [2] = LAYOUT_ortho_2x4(
  33. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  34. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
  35. ),
  36. [3] = LAYOUT_ortho_2x4(
  37. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  38. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
  39. )
  40. };
  41. //------------ SUPER ALTTAB ---------------
  42. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  43. switch (keycode) {
  44. case ALT_TAB:
  45. if (record->event.pressed) {
  46. if (!is_alt_tab_active) {
  47. is_alt_tab_active = true;
  48. register_code(KC_LALT);
  49. }
  50. alt_tab_timer = timer_read();
  51. register_code(KC_TAB);
  52. } else {
  53. unregister_code(KC_TAB);
  54. }
  55. break;
  56. }
  57. return true;
  58. }
  59. void matrix_scan_user(void) {
  60. if (is_alt_tab_active) {
  61. if (timer_elapsed(alt_tab_timer) > 1000) {
  62. unregister_code(KC_LALT);
  63. is_alt_tab_active = false;
  64. }
  65. }
  66. }
  67. void keyboard_post_init_user(void) {
  68. // set default macro after reset (alt-tab)
  69. uint8_t get[16] = {0};
  70. uint8_t zero[16] = {0};
  71. dynamic_keymap_macro_get_buffer(0,16,get);
  72. if(memcmp(get, zero, 16) == 0)
  73. {
  74. uint8_t set[] = {2, 0xe2, 2, 0xe1, 3, 0xe1, 3, 0xe2, 0};
  75. dynamic_keymap_macro_set_buffer(0, 9, set);
  76. }
  77. }