]> git.friedersdorff.com Git - max/tmk_keyboard.git/blobdiff - converter/usb_usb/matrix.c
Merge commit '71381457fa1311dfa0b58ba882a96db740640871'
[max/tmk_keyboard.git] / converter / usb_usb / matrix.c
index 1cfecde203fb10cdbf238b7bfb5a171ea6cb4e7d..184933acf3e17f32ea3f6ef0f10a6095ee6a329f 100644 (file)
@@ -18,7 +18,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <stdint.h>
 #include <stdbool.h>
 #include "usb_hid.h"
-#include "usb_keycodes.h"
+#include "keycode.h"
 #include "util.h"
 #include "print.h"
 #include "debug.h"
@@ -31,20 +31,20 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  7 6 5 4 3 2 1 0
  * +---------------+
- * |   ROW   | COL |
+ * |  ROW  |  COL  |
  * +---------------+
  *
- * Matrix space(32 * 8):
- *      01234567
- *   0 +--------+
- *   : |        |
- *   : |        |
- *  31 +--------+
+ * Matrix space(16 * 16):
+ *   r\c0123456789ABCDEF
+ *   0 +----------------+
+ *   : |                |
+ *   : |                |
+ *  16 +----------------+
  */
-#define ROW_MASK 0xF8
-#define COL_MASK 0x07
-#define CODE(row, col)  (((row) << 3) | (col))
-#define ROW(code)       (((code) & ROW_MASK) >> 3)
+#define ROW_MASK 0xF0
+#define COL_MASK 0x0F
+#define CODE(row, col)  (((row) << 4) | (col))
+#define ROW(code)       (((code) & ROW_MASK) >> 4)
 #define COL(code)       ((code) & COL_MASK)
 #define ROW_BITS(code)  (1 << COL(code))
 
@@ -81,7 +81,7 @@ bool matrix_is_on(uint8_t row, uint8_t col) {
             return true;
         }
     }
-    for (uint8_t i = 0; i < REPORT_KEYS; i++) {
+    for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
         if (usb_hid_keyboard_report.keys[i] == code) {
             return true;
         }
@@ -89,14 +89,14 @@ bool matrix_is_on(uint8_t row, uint8_t col) {
     return false;
 }
 
-uint8_t matrix_get_row(uint8_t row) {
-    uint8_t row_bits = 0;
+matrix_row_t matrix_get_row(uint8_t row) {
+    uint16_t row_bits = 0;
 
     if (IS_MOD(CODE(row, 0)) && usb_hid_keyboard_report.mods) {
         row_bits |= usb_hid_keyboard_report.mods;
     }
 
-    for (uint8_t i = 0; i < REPORT_KEYS; i++) {
+    for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
         if (IS_ANY(usb_hid_keyboard_report.keys[i])) {
             if (row == ROW(usb_hid_keyboard_report.keys[i])) {
                 row_bits |= ROW_BITS(usb_hid_keyboard_report.keys[i]);
@@ -110,7 +110,7 @@ uint8_t matrix_key_count(void) {
     uint8_t count = 0;
 
     count += bitpop(usb_hid_keyboard_report.mods);
-    for (uint8_t i = 0; i < REPORT_KEYS; i++) {
+    for (uint8_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
         if (IS_ANY(usb_hid_keyboard_report.keys[i])) {
             count++;
         }