1
0
mirror of https://github.com/MatMoul/g810-led.git synced 2024-12-23 09:16:11 +00:00

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.
This commit is contained in:
MohamadSaada 2016-12-03 21:48:21 +00:00 committed by GitHub
parent 5695d8e44f
commit 80afb5dfaf

View File

@ -709,14 +709,16 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
if (multimediaCount > 0) setKeysInternal(KeyAddressGroup::multimedia, multimedia, multimediaCount); if (multimediaCount > 0) setKeysInternal(KeyAddressGroup::multimedia, multimedia, multimediaCount);
if (keysCount > 0) { if (keysCount > 0) {
int maxKeyValueCount = 2; // Normally max 14 but dont work int maxKeyValueCount = 14;
for (int i = 0; i < keysCount; i = i + maxKeyValueCount) { for (int i = 0; i < keysCount; i = i + maxKeyValueCount) {
KeyValue keysBlock[maxKeyValueCount]; KeyValue keysBlock[maxKeyValueCount];
int keysBlockCount = 0; int keysBlockCount = 0;
for (int j = 0; j < maxKeyValueCount; j++) { for (int j = 0; j < maxKeyValueCount; j++) {
if((i + j) < keysCount ) {
keysBlock[j] = keys[i + j]; keysBlock[j] = keys[i + j];
keysBlockCount++; keysBlockCount++;
} }
}
setKeysInternal(KeyAddressGroup::keys, keysBlock, keysBlockCount); setKeysInternal(KeyAddressGroup::keys, keysBlock, keysBlockCount);
} }
} }