From 2dd260e84bf0144bc15951627de8079730c943ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Tue, 11 Oct 2016 21:56:24 +0200 Subject: [PATCH] Fix and use KeyMatrix_Scan() --- right/src/usb_interface_keyboard.c | 37 +++++++----------------------- shared/key_matrix.c | 4 ++-- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/right/src/usb_interface_keyboard.c b/right/src/usb_interface_keyboard.c index ee3b34b..4cb3fbe 100644 --- a/right/src/usb_interface_keyboard.c +++ b/right/src/usb_interface_keyboard.c @@ -70,41 +70,20 @@ static usb_status_t UsbKeyboardAction(void) UsbKeyboardReport.reserved = 0; KeyMatrix_Init(&keyMatrix); - //KeyMatrix_Scan(&keyMatrix); + KeyMatrix_Scan(&keyMatrix); - for (uint8_t scancode_idx=0; scancode_idxcolNum; col++) { GPIO_WritePinOutput(keyMatrix->cols[col].gpio, keyMatrix->cols[col].pin, 1); for (uint8_t row=0; rowrowNum; row++) { - keyMatrix->keyStates[keyId++] = GPIO_ReadPinInput(keyMatrix->rows[row].gpio, keyMatrix->rows[row].pin); + keyMatrix->keyStates[row*keyMatrix->colNum + col] = GPIO_ReadPinInput(keyMatrix->rows[row].gpio, keyMatrix->rows[row].pin); } GPIO_WritePinOutput(keyMatrix->cols[col].gpio, keyMatrix->cols[col].pin, 0); + for (volatile uint32_t i=0; i<100; i++); // Wait for the new port state to settle. This avoid bogus key state detection. } }