mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 09:16:11 +00:00
Correct Bug for speed cpu
This commit is contained in:
parent
631f2b3c95
commit
b1162ada16
@ -3,6 +3,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <unistd.h>
|
||||||
#include "/usr/include/libusb-1.0/libusb.h"
|
#include "/usr/include/libusb-1.0/libusb.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -387,6 +388,7 @@ bool Keyboard::sendDataInternal(unsigned char *data, int data_size) {
|
|||||||
int r;
|
int r;
|
||||||
if (data_size > 20) r = libusb_control_transfer(dev_handle, 0x21, 0x09, 0x0212, 1, data, data_size, 2000);
|
if (data_size > 20) r = libusb_control_transfer(dev_handle, 0x21, 0x09, 0x0212, 1, data, data_size, 2000);
|
||||||
else r = libusb_control_transfer(dev_handle, 0x21, 0x09, 0x0211, 1, data, data_size, 2000);
|
else r = libusb_control_transfer(dev_handle, 0x21, 0x09, 0x0211, 1, data, data_size, 2000);
|
||||||
|
usleep(1000);
|
||||||
if (r < 0) return false;
|
if (r < 0) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -544,8 +546,8 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
|
|||||||
|
|
||||||
for (int i = 0; i < keyValueCount; i++) {
|
for (int i = 0; i < keyValueCount; i++) {
|
||||||
if(keyValue[i].key.addressGroup == KeyAddressGroup::logo) {
|
if(keyValue[i].key.addressGroup == KeyAddressGroup::logo) {
|
||||||
logo[logoCount] = keyValue[i];
|
logo[0] = keyValue[i];
|
||||||
logoCount++;
|
logoCount = 1;
|
||||||
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::indicators) {
|
} else if(keyValue[i].key.addressGroup == KeyAddressGroup::indicators) {
|
||||||
indicators[indicatorsCount] = keyValue[i];
|
indicators[indicatorsCount] = keyValue[i];
|
||||||
indicatorsCount++;
|
indicatorsCount++;
|
||||||
@ -560,22 +562,12 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
|
|||||||
|
|
||||||
if (logoCount > 0) setKey(logo[logoCount - 1]);
|
if (logoCount > 0) setKey(logo[logoCount - 1]);
|
||||||
|
|
||||||
if (indicatorsCount > 0) {
|
if (indicatorsCount > 0) setKeysInternal(KeyAddressGroup::indicators, indicators, indicatorsCount);
|
||||||
for (int i = 0; i < indicatorsCount; i++) {
|
|
||||||
setKeysInternal(KeyAddressGroup::indicators, indicators, indicatorsCount);
|
|
||||||
commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (multimediaCount > 0) {
|
if (multimediaCount > 0) setKeysInternal(KeyAddressGroup::multimedia, multimedia, multimediaCount);
|
||||||
for (int i = 0; i < multimediaCount; i++) {
|
|
||||||
setKeysInternal(KeyAddressGroup::multimedia, multimedia, multimediaCount);
|
|
||||||
commit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (keysCount > 0) {
|
if (keysCount > 0) {
|
||||||
int maxKeyValueCount = 1; // Normally max 16 but dont work
|
int maxKeyValueCount = 12; // Normally max 16 but dont work
|
||||||
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;
|
||||||
@ -584,7 +576,6 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
|
|||||||
keysBlockCount++;
|
keysBlockCount++;
|
||||||
}
|
}
|
||||||
setKeysInternal(KeyAddressGroup::keys, keysBlock, keysBlockCount);
|
setKeysInternal(KeyAddressGroup::keys, keysBlock, keysBlockCount);
|
||||||
commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user