From 80afb5dfaffa5601c70d1104cfa26f5bb38c36f9 Mon Sep 17 00:00:00 2001 From: MohamadSaada Date: Sat, 3 Dec 2016 21:48:21 +0000 Subject: [PATCH] Update Keyboard.cpp 14 isn't working because in the last iteration you might have some empty slots in the array, this way it will prevent that and work perfectly. I am using it in my program and have checked it in wireshark. I modified your program fully to suit my g910 keyboard. --- src/classes/Keyboard.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index bf7d76a..09c33ab 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -709,13 +709,15 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) { if (multimediaCount > 0) setKeysInternal(KeyAddressGroup::multimedia, multimedia, multimediaCount); if (keysCount > 0) { - int maxKeyValueCount = 2; // Normally max 14 but dont work + int maxKeyValueCount = 14; for (int i = 0; i < keysCount; i = i + maxKeyValueCount) { KeyValue keysBlock[maxKeyValueCount]; int keysBlockCount = 0; for (int j = 0; j < maxKeyValueCount; j++) { - keysBlock[j] = keys[i + j]; - keysBlockCount++; + if((i + j) < keysCount ) { + keysBlock[j] = keys[i + j]; + keysBlockCount++; + } } setKeysInternal(KeyAddressGroup::keys, keysBlock, keysBlockCount); }