Merge readLeft() into UsbKeyboardTask()
This commit is contained in:
@@ -86,28 +86,10 @@ key_matrix_t keyMatrix = {
|
||||
#endif
|
||||
};
|
||||
|
||||
void readLeftKeys(uint8_t *stateVector){
|
||||
uint8_t data[] = {0};
|
||||
uint8_t success=0;
|
||||
|
||||
if (I2cWrite(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, data, sizeof(data)) == kStatus_Success) {
|
||||
if (I2cRead(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, stateVector, KEY_STATE_COUNT) == kStatus_Success) {
|
||||
success = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
bzero(stateVector, KEY_STATE_COUNT);
|
||||
}
|
||||
}
|
||||
|
||||
void UsbKeyboadTask(){
|
||||
// Producer task for USB packets. When the USB interrupt is called,
|
||||
// the newest packet is sent out immediately, thus not doing long task
|
||||
// in the interrupt handler.
|
||||
void UsbKeyboadTask()
|
||||
{
|
||||
int newLayout = 1-activeLayout;
|
||||
|
||||
static uint8_t leftKeyStates[KEY_STATE_COUNT];
|
||||
|
||||
UsbKeyboardReport[newLayout].modifiers = 0;
|
||||
UsbKeyboardReport[newLayout].reserved = 0;
|
||||
@@ -115,15 +97,16 @@ void UsbKeyboadTask(){
|
||||
KeyMatrix_Init(&keyMatrix);
|
||||
KeyMatrix_Scan(&keyMatrix);
|
||||
|
||||
uint8_t txData[] = {0};
|
||||
static uint8_t leftKeyStates[KEY_STATE_COUNT];
|
||||
bzero(leftKeyStates, KEY_STATE_COUNT);
|
||||
if (I2cWrite(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, txData, sizeof(txData)) == kStatus_Success) {
|
||||
I2cRead(I2C_MAIN_BUS_BASEADDR, I2C_ADDRESS_LEFT_KEYBOARD_HALF, leftKeyStates, KEY_STATE_COUNT);
|
||||
}
|
||||
|
||||
bzero(&UsbKeyboardReport[newLayout].scancodes, USB_KEYBOARD_MAX_KEYS);
|
||||
|
||||
readLeftKeys(leftKeyStates);
|
||||
|
||||
HandleKeyboardEvents(&UsbKeyboardReport[newLayout], &UsbMouseReport, leftKeyStates, keyMatrix.keyStates);
|
||||
|
||||
// Change to the new layout in atomic operation (int copy). Even if
|
||||
// the copy is not atomic itself, only single bit changes. So it can
|
||||
// never be a problem
|
||||
activeLayout = newLayout;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user