Kiibohd Controller
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
このリポジトリはアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュや、課題・プルリクエストのオープンはできません。

matrix.h 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /* Copyright (C) 2011 by Jacob Alexander
  2. *
  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. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. #ifndef __MATRIX_H
  22. #define __MATRIX_H
  23. // ----- Quick Map (don't change) -----
  24. #define pinA0 0
  25. #define pinA1 1
  26. #define pinA2 2
  27. #define pinA3 3
  28. #define pinA4 4
  29. #define pinA5 5
  30. #define pinA6 6
  31. #define pinA7 7
  32. #define pinB0 10
  33. #define pinB1 11
  34. #define pinB2 12
  35. #define pinB3 13
  36. #define pinB4 14
  37. #define pinB5 15
  38. #define pinB6 16
  39. #define pinB7 17
  40. #define pinC0 20
  41. #define pinC1 21
  42. #define pinC2 22
  43. #define pinC3 23
  44. #define pinC4 24
  45. #define pinC5 25
  46. #define pinC6 26
  47. #define pinC7 27
  48. #define pinD0 30
  49. #define pinD1 31
  50. #define pinD2 32
  51. #define pinD3 33
  52. #define pinD4 34
  53. #define pinD5 35
  54. #define pinD6 36
  55. #define pinD7 37
  56. #define pinE0 40
  57. #define pinE1 41
  58. #define pinE2 42
  59. #define pinE3 43
  60. #define pinE4 44
  61. #define pinE5 45
  62. #define pinE6 46
  63. #define pinE7 47
  64. #define pinF0 50
  65. #define pinF1 51
  66. #define pinF2 52
  67. #define pinF3 53
  68. #define pinF4 54
  69. #define pinF5 55
  70. #define pinF6 56
  71. #define pinF7 57
  72. #define pinNULL 128
  73. // ----- Scan Mode (usually dual-scan) -----
  74. // Ordered by increasing memory/CPU usage
  75. #define scanRow 0 // Needed for powered switches (Hall-Effect)
  76. #define scanCol 1 // Opposite of scanRow
  77. #define scanRow_powrCol 2 // NKRO supported (simple detection)
  78. #define scanCol_powrRow 3 // Opposite of scanRow_powrCol
  79. #define scanDual 4 // Typical ~2KRO matrix
  80. // ----- Scan Mode Setting -----
  81. #define scanMode scanCol
  82. // ----- Key Settings -----
  83. #define keyboardSize 16 // # of keys
  84. // ----- Matrix Configuration -----
  85. static uint8_t matrix_pinout[][] = {
  86. // Just layout the matrix by rows and columns
  87. // Usually you'll want to set the scanMode above to scanDual or scanCol_powrRow/scanRow_powrCol
  88. // The mode allows for optimization in the kind of scanning algorithms that are done
  89. //
  90. // The key numbers are used to translate into the keymap table (array) (and always start from 1, not 0).
  91. // See the keymap.h file for the various preconfigured arrays.
  92. // Scan Mode | Col 1 | Col 2 | Col 3 | Col 4 | Col 4 | ...
  93. // -------------------------------------------------------
  94. // Row 1 | Key 1 Key 7 Key32 ...
  95. // Row 2 | Key 3 Key92 ...
  96. // Row 3 | Key23 ...
  97. // Row 4 | ...
  98. // Row 5 |
  99. // ... |
  100. { scanMode, pinF4, pinA6, pinA1, pinA3, pinF5, pinA5, pinA2, pinF0, pinF6, pinA7, pinA0, pinF1, pinF3, pinF7, pinA4, pinF2 },
  101. { pinNULL, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
  102. // Example Rows
  103. //{ pinE0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
  104. //{ pinE1, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, },
  105. };
  106. // ----- Variables -----
  107. // NOTE: Highest Bit: Valid keypress (0x80 is valid keypress)
  108. // Other Bits: Pressed state sample counter
  109. uint8_t keyboardDetectArray[keyboardSize + 1];
  110. // ----- Functions -----
  111. #endif // __MATRIX_H