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

Added support for g910 spectrum

This commit is contained in:
Daniel Kolosa 2016-12-01 20:07:13 -05:00
parent 985c4bfe69
commit bcccdae449
2 changed files with 15 additions and 9 deletions

View File

@ -14,7 +14,7 @@ bool Keyboard::attach() {
int r;
r = libusb_init(&ctx);
if (r < 0) return false;
libusb_device **devs;
ssize_t cnt = libusb_get_device_list(ctx, &devs);
if(cnt < 0) return false;
@ -33,6 +33,11 @@ bool Keyboard::attach() {
kbdProtocol = KeyboardProtocol::spark;
break;
}
if (desc.idProduct == 0xc335) {
pid = desc.idProduct;
kbdProtocol = KeyboardProtocol::spark;
break;
}
}
}
libusb_free_device_list(devs, 1);
@ -41,7 +46,7 @@ bool Keyboard::attach() {
ctx = NULL;
return false;
}
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x046d, pid);
if (dev_handle == NULL) {
libusb_exit(ctx);
@ -677,7 +682,7 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
int keysCount = 0;
KeyValue gkeys[25];
int gkeysCount = 0;
for (int i = 0; i < keyValueCount; i++) {
if(keyValue[i].key.addressGroup == KeyAddressGroup::logo) {
logo[logoCount] = keyValue[i];
@ -696,13 +701,13 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
gkeysCount++;
}
}
if (logoCount > 0) setKeysInternal(KeyAddressGroup::logo, logo, logoCount);
if (indicatorsCount > 0) setKeysInternal(KeyAddressGroup::indicators, indicators, indicatorsCount);
if (multimediaCount > 0) setKeysInternal(KeyAddressGroup::multimedia, multimedia, multimediaCount);
if (keysCount > 0) {
int maxKeyValueCount = 2; // Normally max 14 but dont work
for (int i = 0; i < keysCount; i = i + maxKeyValueCount) {
@ -715,9 +720,9 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
setKeysInternal(KeyAddressGroup::keys, keysBlock, keysBlockCount);
}
}
if (gkeysCount > 0) setKeysInternal(KeyAddressGroup::gkeys, gkeys, gkeysCount);
return true;
}

View File

@ -3,3 +3,4 @@ ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c3
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c330", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c333", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c32b", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c335", MODE="660", GROUP="users"