You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

119 lines
5.0 KiB

  1. /* Copyright 2021 3araht
  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 "bandominedoni.h"
  17. #ifdef RGB_MATRIX_ENABLE
  18. led_config_t g_led_config = {
  19. {
  20. { 75, 46, 45, 44, 43, 42, NO_LED },
  21. { 47, 48, 49, 50, 51, 52, 53 },
  22. { 60, 59, 58, 57, 56, 55, 54 },
  23. { 61, 62, 63, 64, 65, 66, 67 },
  24. { 74, 73, 72, 71, 70, 69, 68 },
  25. { NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED, NO_LED },
  26. { 7, 6, 4, 3, 2, 1, 5},
  27. { 8, 9, 10, 11, 12, 13, 0 },
  28. { 19, 18, 17, 16, 15, 14, 41 },
  29. { 20, 21, 22, 23, 24, 25, 40 },
  30. { 30, 29, 28, 27, 26, 39, 38 },
  31. { 31, 32, 33, 34, 35, 36, 37 }
  32. }, {
  33. { 145, 6 }, { 157, 5 }, { 153, 14 }, { 149, 22 }, { 145, 32 }, { 136, 35 }, { 139, 48 }, { 134, 61 },
  34. { 142, 60 }, { 148, 43 }, { 154, 29 }, { 158, 20 }, { 163, 12 }, { 168, 4 },
  35. { 178, 5 }, { 173, 12 }, { 168, 20 }, { 163, 28 }, { 157, 40 }, { 151, 55 },
  36. { 160, 52 }, { 166, 39 }, { 172, 28 }, { 177, 20 }, { 182, 13 }, { 188, 7 },
  37. { 192, 17 }, { 186, 23 }, { 181, 30 }, { 175, 39 }, { 169, 50 },
  38. { 178, 51 }, { 184, 41 }, { 190, 33 }, { 196, 27 },
  39. { 199, 37 }, { 193, 45 }, { 187, 53 },
  40. { 196, 56 }, { 202, 49 },
  41. { 205, 61 },
  42. { 202, 4 },
  43. { 84, 18 }, { 73, 13 }, { 62, 10 }, { 51, 8 }, { 39, 11 }, { 24, 22 },
  44. { 34, 19 }, { 45, 16 }, { 56, 16 }, { 66, 18 }, { 77, 22 }, { 87, 28 },
  45. { 92, 40 }, { 81, 32 }, { 71, 27 }, { 61, 24 }, { 51, 24 }, { 41, 24 }, { 30, 28 },
  46. { 24, 42 }, { 34, 37 }, { 44, 35 }, { 54, 34 }, { 64, 36 }, { 74, 38 }, { 84, 44 },
  47. { 87, 54 }, { 77, 49 }, { 67, 47 }, { 57, 45 }, { 47, 45 }, { 37, 48 }, { 27, 52 }, { 19, 56 },
  48. }, {
  49. 4, 4, 4, 4, 4, 4, 4, 4,
  50. 4, 4, 4, 4, 4, 4,
  51. 4, 4, 4, 4, 4, 4,
  52. 4, 4, 4, 4, 4, 4,
  53. 4, 4, 4, 4, 4,
  54. 4, 4, 4, 4,
  55. 4, 4, 4,
  56. 4, 4,
  57. 4,
  58. 4,
  59. 4, 4, 4, 4, 4, 4,
  60. 4, 4, 4, 4, 4, 4,
  61. 4, 4, 4, 4, 4, 4, 4,
  62. 4, 4, 4, 4, 4, 4, 4,
  63. 4, 4, 4, 4, 4, 4, 4, 4
  64. }
  65. };
  66. #endif
  67. #if defined(SPLIT_HAND_MATRIX_GRID)
  68. static uint8_t peek_matrix_intersection(pin_t out_pin, pin_t in_pin) {
  69. setPinInputHigh(in_pin);
  70. setPinOutput(out_pin);
  71. writePinLow(out_pin);
  72. // It's almost unnecessary, but wait until it's down to low, just in case.
  73. wait_us(1);
  74. uint8_t pin_state = readPin(in_pin);
  75. // Set out_pin to a setting that is less susceptible to noise.
  76. setPinInputHigh(out_pin);
  77. matrix_io_delay(); // Wait for the pull-up to go HIGH.
  78. return pin_state;
  79. }
  80. #endif
  81. // Overriding is_keyboard_left() in qmk_firmware/quantum/split_common/split_util.c to limit the handedness check only once.
  82. // reason: bandoMIneDonI has no space on right hand side to use "SPLIT_HAND_MATRIX_GRID".
  83. // However, It enables to decide the handedness by the HW by adding one condition: "not to press any keys (especially r30) dusing startup."
  84. bool is_keyboard_left(void) {
  85. static enum { UNKNOWN, LEFT, RIGHT } hand_side = UNKNOWN;
  86. // only check once, as this is called often
  87. if (hand_side == UNKNOWN) {
  88. #if defined(SPLIT_HAND_PIN)
  89. // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
  90. setPinInput(SPLIT_HAND_PIN);
  91. hand_side = readPin(SPLIT_HAND_PIN) ? LEFT : RIGHT;
  92. return (hand_side == LEFT);
  93. #elif defined(SPLIT_HAND_MATRIX_GRID)
  94. # ifdef SPLIT_HAND_MATRIX_GRID_LOW_IS_LEFT
  95. hand_side = peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID) ? RIGHT : LEFT;
  96. return (hand_side == LEFT);
  97. # else
  98. hand_side = peek_matrix_intersection(SPLIT_HAND_MATRIX_GRID) ? LEFT : RIGHT;
  99. return (hand_side == LEFT);
  100. # endif
  101. #elif defined(EE_HANDS)
  102. hand_side = eeconfig_read_handedness() ? LEFT : RIGHT;
  103. return (hand_side == LEFT);
  104. #elif defined(MASTER_RIGHT)
  105. hand_side = !is_keyboard_master() ? LEFT : RIGHT;
  106. return (hand_side == LEFT);
  107. #endif
  108. hand_side = is_keyboard_master() ? LEFT : RIGHT;
  109. return (hand_side == LEFT);
  110. } else {
  111. return (hand_side == LEFT);
  112. }
  113. }