Add pointer_delta_t and make the master and slaves handle it.

This commit is contained in:
László Monda
2019-06-11 21:58:40 +02:00
parent a57fedec70
commit a857780e42
5 changed files with 37 additions and 1 deletions

View File

@@ -66,6 +66,9 @@ void UhkModuleSlaveDriver_Init(uint8_t uhkModuleDriverId)
uhk_module_i2c_addresses_t *uhkModuleI2cAddresses = moduleIdsToI2cAddresses + uhkModuleDriverId;
uhkModuleState->firmwareI2cAddress = uhkModuleI2cAddresses->firmwareI2cAddress;
uhkModuleState->bootloaderI2cAddress = uhkModuleI2cAddresses->bootloaderI2cAddress;
uhkModuleState->pointerDelta.x = 0;
uhkModuleState->pointerDelta.y = 0;
}
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++) {
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;
*uhkModulePhase = UhkModulePhase_SetTestLed;

View File

@@ -6,6 +6,7 @@
#include "fsl_common.h"
#include "crc16.h"
#include "versions.h"
#include "usb_interfaces/usb_interface_mouse.h"
// Macros:
@@ -81,6 +82,7 @@
uint8_t bootloaderI2cAddress;
uint8_t keyCount;
uint8_t pointerCount;
pointer_delta_t pointerDelta;
} uhk_module_state_t;
typedef struct {

View File

@@ -169,6 +169,16 @@ static void processMouseActions()
MouseMoveState.xOut = 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);
ActiveUsbMouseReport->wheelX = MouseScrollState.xOut;
ActiveUsbMouseReport->wheelY = MouseScrollState.yOut;