logo

qmk_firmware

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

sofle.c (4039B)


  1. // Copyright 2023 QMK
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "quantum.h"
  4. #ifdef SWAP_HANDS_ENABLE
  5. __attribute__ ((weak))
  6. const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] =
  7. // The LAYOUT macro could work for this, but it was harder to figure out the
  8. // identity using it.
  9. // This is the identity layout.
  10. /*
  11. {
  12. { {0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0} },
  13. { {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1} },
  14. { {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2} },
  15. { {0, 3}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3} },
  16. { {0, 4}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4} },
  17. { {0, 5}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {5, 5} },
  18. { {0, 6}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6} },
  19. { {0, 7}, {1, 7}, {2, 7}, {3, 7}, {4, 7}, {5, 7} },
  20. { {0, 8}, {1, 8}, {2, 8}, {3, 8}, {4, 8}, {5, 8} },
  21. { {0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 9}, {5, 9} },
  22. };
  23. */
  24. // This is the mirror, q <-> p, w <-> o, etc...
  25. {
  26. { {0, 5}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {5, 5} },
  27. { {0, 6}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6} },
  28. { {0, 7}, {1, 7}, {2, 7}, {3, 7}, {4, 7}, {5, 7} },
  29. { {0, 8}, {1, 8}, {2, 8}, {3, 8}, {4, 8}, {5, 8} },
  30. { {0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 9}, {5, 9} },
  31. { {0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0} },
  32. { {0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1} },
  33. { {0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2} },
  34. { {0, 3}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3} },
  35. { {0, 4}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4} },
  36. };
  37. # ifdef ENCODER_MAP_ENABLE
  38. const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = {1, 0};
  39. # endif
  40. #endif
  41. #ifdef OLED_ENABLE
  42. oled_rotation_t oled_init_kb(oled_rotation_t rotation) {
  43. if (is_keyboard_master()) {
  44. return OLED_ROTATION_270;
  45. }
  46. return rotation;
  47. }
  48. static void render_logo(void) {
  49. static const char PROGMEM qmk_logo[] = {
  50. 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x91,0x92,0x93,0x94,
  51. 0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,
  52. 0xc0,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,0xd1,0xd2,0xd3,0xd4,0
  53. };
  54. oled_write_P(qmk_logo, false);
  55. }
  56. void print_status_narrow(void) {
  57. oled_write_P(PSTR("\n\n"), false);
  58. switch (get_highest_layer(layer_state)) {
  59. case 0:
  60. oled_write_ln_P(PSTR("Qwrt"), false);
  61. break;
  62. case 1:
  63. oled_write_ln_P(PSTR("Clmk"), false);
  64. break;
  65. default:
  66. oled_write_P(PSTR("Mod\n"), false);
  67. break;
  68. }
  69. oled_write_P(PSTR("\n\n"), false);
  70. oled_write_ln_P(PSTR("LAYER"), false);
  71. switch (get_highest_layer(layer_state)) {
  72. case 0:
  73. case 1:
  74. oled_write_P(PSTR("Base\n"), false);
  75. break;
  76. case 2:
  77. oled_write_P(PSTR("Lower"), false);
  78. break;
  79. case 3:
  80. oled_write_P(PSTR("Raise"), false);
  81. break;
  82. case 4:
  83. oled_write_P(PSTR("Adjust"), false);
  84. break;
  85. default:
  86. oled_write_ln_P(PSTR("Undef"), false);
  87. }
  88. oled_write_P(PSTR("\n\n"), false);
  89. led_t led_usb_state = host_keyboard_led_state();
  90. oled_write_ln_P(PSTR("CPSLK"), led_usb_state.caps_lock);
  91. }
  92. bool oled_task_kb(void) {
  93. if (!oled_task_user()) {
  94. return false;
  95. }
  96. if (is_keyboard_master()) {
  97. print_status_narrow();
  98. } else {
  99. render_logo();
  100. }
  101. return true;
  102. }
  103. #endif
  104. #ifdef ENCODER_ENABLE
  105. bool encoder_update_kb(uint8_t index, bool clockwise) {
  106. if (!encoder_update_user(index, clockwise)) {
  107. return false;
  108. }
  109. if (index == 0) {
  110. if (clockwise) {
  111. tap_code(KC_VOLU);
  112. } else {
  113. tap_code(KC_VOLD);
  114. }
  115. } else if (index == 1) {
  116. if (clockwise) {
  117. tap_code(KC_PGDN);
  118. } else {
  119. tap_code(KC_PGUP);
  120. }
  121. }
  122. return true;
  123. }
  124. #endif