Use memcmp to compare arrays

This commit is contained in:
lemmingDev
2025-01-24 17:33:01 +09:00
committed by GitHub
parent 8afbd83cac
commit b1ea331546

View File

@@ -124,7 +124,7 @@ void loop()
bleGamepad.setHats(hatValues[0], hatValues[1], hatValues[2], hatValues[3]);
// Update previous states to current states and send report
if (currentButtonStates != previousButtonStates || currentHatStates != previousHatStates)
if ((memcmp((const void *)currentButtonStates, (const void *)previousButtonStates, sizeof(currentButtonStates)) != 0) && (memcmp((const void *)currentHatStates, (const void *)previousHatStates, sizeof(currentHatStates)) != 0))
{
for (byte currentIndex = 0; currentIndex < numOfButtons; currentIndex++)
{