Add pointer_delta_t and make the master and slaves handle it.
This commit is contained in:
@@ -94,7 +94,17 @@ void SlaveTxHandler(void)
|
|||||||
}
|
}
|
||||||
case SlaveCommand_RequestKeyStates:
|
case SlaveCommand_RequestKeyStates:
|
||||||
BoolBytesToBits(keyMatrix.keyStates, TxMessage.data, MODULE_KEY_COUNT);
|
BoolBytesToBits(keyMatrix.keyStates, TxMessage.data, MODULE_KEY_COUNT);
|
||||||
TxMessage.length = BOOL_BYTES_TO_BITS_COUNT(MODULE_KEY_COUNT);
|
uint8_t messageLength = BOOL_BYTES_TO_BITS_COUNT(MODULE_KEY_COUNT);
|
||||||
|
if (MODULE_POINTER_COUNT) {
|
||||||
|
pointer_delta_t *pointerDelta = (pointer_delta_t*)(TxMessage.data + messageLength);
|
||||||
|
pointerDelta->x = 0;
|
||||||
|
pointerDelta->y = 0;
|
||||||
|
if (keyMatrix.keyStates[0]) {
|
||||||
|
pointerDelta->x = 1;
|
||||||
|
}
|
||||||
|
messageLength += sizeof(pointer_delta_t);
|
||||||
|
}
|
||||||
|
TxMessage.length = messageLength;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,9 @@ void UhkModuleSlaveDriver_Init(uint8_t uhkModuleDriverId)
|
|||||||
uhk_module_i2c_addresses_t *uhkModuleI2cAddresses = moduleIdsToI2cAddresses + uhkModuleDriverId;
|
uhk_module_i2c_addresses_t *uhkModuleI2cAddresses = moduleIdsToI2cAddresses + uhkModuleDriverId;
|
||||||
uhkModuleState->firmwareI2cAddress = uhkModuleI2cAddresses->firmwareI2cAddress;
|
uhkModuleState->firmwareI2cAddress = uhkModuleI2cAddresses->firmwareI2cAddress;
|
||||||
uhkModuleState->bootloaderI2cAddress = uhkModuleI2cAddresses->bootloaderI2cAddress;
|
uhkModuleState->bootloaderI2cAddress = uhkModuleI2cAddresses->bootloaderI2cAddress;
|
||||||
|
|
||||||
|
uhkModuleState->pointerDelta.x = 0;
|
||||||
|
uhkModuleState->pointerDelta.y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId)
|
status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId)
|
||||||
@@ -237,6 +240,12 @@ status_t UhkModuleSlaveDriver_Update(uint8_t uhkModuleDriverId)
|
|||||||
for (uint8_t keyId=0; keyId < uhkModuleState->keyCount; keyId++) {
|
for (uint8_t keyId=0; keyId < uhkModuleState->keyCount; keyId++) {
|
||||||
KeyStates[slotId][keyId].current = keyStatesBuffer[keyId];
|
KeyStates[slotId][keyId].current = keyStatesBuffer[keyId];
|
||||||
}
|
}
|
||||||
|
if (uhkModuleState->pointerCount) {
|
||||||
|
uint8_t keyStatesLength = BOOL_BYTES_TO_BITS_COUNT(uhkModuleState->keyCount);
|
||||||
|
pointer_delta_t *pointerDelta = (pointer_delta_t*)(rxMessage->data + keyStatesLength);
|
||||||
|
uhkModuleState->pointerDelta.x += pointerDelta->x;
|
||||||
|
uhkModuleState->pointerDelta.y += pointerDelta->y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
status = kStatus_Uhk_IdleCycle;
|
status = kStatus_Uhk_IdleCycle;
|
||||||
*uhkModulePhase = UhkModulePhase_SetTestLed;
|
*uhkModulePhase = UhkModulePhase_SetTestLed;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "fsl_common.h"
|
#include "fsl_common.h"
|
||||||
#include "crc16.h"
|
#include "crc16.h"
|
||||||
#include "versions.h"
|
#include "versions.h"
|
||||||
|
#include "usb_interfaces/usb_interface_mouse.h"
|
||||||
|
|
||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
@@ -81,6 +82,7 @@
|
|||||||
uint8_t bootloaderI2cAddress;
|
uint8_t bootloaderI2cAddress;
|
||||||
uint8_t keyCount;
|
uint8_t keyCount;
|
||||||
uint8_t pointerCount;
|
uint8_t pointerCount;
|
||||||
|
pointer_delta_t pointerDelta;
|
||||||
} uhk_module_state_t;
|
} uhk_module_state_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -169,6 +169,16 @@ static void processMouseActions()
|
|||||||
MouseMoveState.xOut = 0;
|
MouseMoveState.xOut = 0;
|
||||||
MouseMoveState.yOut = 0;
|
MouseMoveState.yOut = 0;
|
||||||
|
|
||||||
|
for (uint8_t moduleId=0; moduleId<UHK_MODULE_MAX_COUNT; moduleId++) {
|
||||||
|
uhk_module_state_t *moduleState = UhkModuleStates + moduleId;
|
||||||
|
if (moduleState->pointerCount) {
|
||||||
|
ActiveUsbMouseReport->x += moduleState->pointerDelta.x;
|
||||||
|
ActiveUsbMouseReport->y += moduleState->pointerDelta.y;
|
||||||
|
moduleState->pointerDelta.x = 0;
|
||||||
|
moduleState->pointerDelta.y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
processMouseKineticState(&MouseScrollState);
|
processMouseKineticState(&MouseScrollState);
|
||||||
ActiveUsbMouseReport->wheelX = MouseScrollState.xOut;
|
ActiveUsbMouseReport->wheelX = MouseScrollState.xOut;
|
||||||
ActiveUsbMouseReport->wheelY = MouseScrollState.yOut;
|
ActiveUsbMouseReport->wheelY = MouseScrollState.yOut;
|
||||||
|
|||||||
@@ -48,6 +48,11 @@
|
|||||||
uint8_t data[I2C_MESSAGE_MAX_PAYLOAD_LENGTH];
|
uint8_t data[I2C_MESSAGE_MAX_PAYLOAD_LENGTH];
|
||||||
} ATTR_PACKED i2c_message_t;
|
} ATTR_PACKED i2c_message_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int16_t x;
|
||||||
|
int16_t y;
|
||||||
|
} ATTR_PACKED pointer_delta_t;
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern char SlaveSyncString[];
|
extern char SlaveSyncString[];
|
||||||
|
|||||||
Reference in New Issue
Block a user