From c941052edb2f9dce8cde0cf07f9bdbe3ee320a0a Mon Sep 17 00:00:00 2001 From: MatMoul Date: Tue, 29 Nov 2016 21:34:31 +0100 Subject: [PATCH] Add multiple logo support --- src/classes/Keyboard.cpp | 52 +++++++++++++--------------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 85f7549..6a01cc3 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -589,42 +589,22 @@ bool Keyboard::setKeysInternal(KeyAddressGroup addressGroup, KeyValue keyValues[ unsigned char *data; int data_size; int maxKeyValueCount = 0; - if (addressGroup == KeyAddressGroup::logo) { - data_size = 20; - data = new unsigned char[data_size]; - populateAddressGroupInternal(addressGroup, data); - maxKeyValueCount = (data_size - 8) / 4; - for(int i = 0; i < maxKeyValueCount; i++) { - if (i < keyValueCount) { - data[8 + i * 4 + 0] = keyValues[i].key.id; - data[8 + i * 4 + 1] = keyValues[i].colors.red; - data[8 + i * 4 + 2] = keyValues[i].colors.green; - data[8 + i * 4 + 3] = keyValues[i].colors.blue; - } else { - data[8 + i * 4 + 0] = 0x00; - data[8 + i * 4 + 1] = 0x00; - data[8 + i * 4 + 2] = 0x00; - data[8 + i * 4 + 3] = 0x00; - } - } - } else { - data_size = 64; - data = new unsigned char[data_size]; - populateAddressGroupInternal(addressGroup, data); - maxKeyValueCount = (data_size - 8) / 4; - if (keyValueCount > maxKeyValueCount) keyValueCount = maxKeyValueCount; - for(int i = 0; i < maxKeyValueCount; i++) { - if (i < keyValueCount) { - data[8 + i * 4 + 0] = keyValues[i].key.id; - data[8 + i * 4 + 1] = keyValues[i].colors.red; - data[8 + i * 4 + 2] = keyValues[i].colors.green; - data[8 + i * 4 + 3] = keyValues[i].colors.blue; - } else { - data[8 + i * 4 + 0] = 0x00; - data[8 + i * 4 + 1] = 0x00; - data[8 + i * 4 + 2] = 0x00; - data[8 + i * 4 + 3] = 0x00; - } + if (addressGroup == KeyAddressGroup::logo) data_size = 20; + else data_size = 64; + data = new unsigned char[data_size]; + populateAddressGroupInternal(addressGroup, data); + maxKeyValueCount = (data_size - 8) / 4; + for(int i = 0; i < maxKeyValueCount; i++) { + if (i < keyValueCount) { + data[8 + i * 4 + 0] = keyValues[i].key.id; + data[8 + i * 4 + 1] = keyValues[i].colors.red; + data[8 + i * 4 + 2] = keyValues[i].colors.green; + data[8 + i * 4 + 3] = keyValues[i].colors.blue; + } else { + data[8 + i * 4 + 0] = 0x00; + data[8 + i * 4 + 1] = 0x00; + data[8 + i * 4 + 2] = 0x00; + data[8 + i * 4 + 3] = 0x00; } } retval = sendDataInternal(data, data_size);