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

Merge pull request #18 from dkolosa/g910_spectrum

Added support for g910 spectrum
Thank you @dkolosa
This commit is contained in:
MatMoul 2016-12-02 20:55:45 +01:00 committed by GitHub
commit d7507c206f
2 changed files with 15 additions and 9 deletions

View File

@ -14,7 +14,7 @@ bool Keyboard::attach() {
int r; int r;
r = libusb_init(&ctx); r = libusb_init(&ctx);
if (r < 0) return false; if (r < 0) return false;
libusb_device **devs; libusb_device **devs;
ssize_t cnt = libusb_get_device_list(ctx, &devs); ssize_t cnt = libusb_get_device_list(ctx, &devs);
if(cnt < 0) return false; if(cnt < 0) return false;
@ -33,6 +33,11 @@ bool Keyboard::attach() {
kbdProtocol = KeyboardProtocol::spark; kbdProtocol = KeyboardProtocol::spark;
break; break;
} }
if (desc.idProduct == 0xc335) {
pid = desc.idProduct;
kbdProtocol = KeyboardProtocol::spark;
break;
}
} }
} }
libusb_free_device_list(devs, 1); libusb_free_device_list(devs, 1);
@ -41,7 +46,7 @@ bool Keyboard::attach() {
ctx = NULL; ctx = NULL;
return false; return false;
} }
dev_handle = libusb_open_device_with_vid_pid(ctx, 0x046d, pid); dev_handle = libusb_open_device_with_vid_pid(ctx, 0x046d, pid);
if (dev_handle == NULL) { if (dev_handle == NULL) {
libusb_exit(ctx); libusb_exit(ctx);
@ -677,7 +682,7 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
int keysCount = 0; int keysCount = 0;
KeyValue gkeys[25]; KeyValue gkeys[25];
int gkeysCount = 0; int gkeysCount = 0;
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[logoCount] = keyValue[i];
@ -696,13 +701,13 @@ bool Keyboard::setKeys(KeyValue keyValue[], int keyValueCount) {
gkeysCount++; gkeysCount++;
} }
} }
if (logoCount > 0) setKeysInternal(KeyAddressGroup::logo, logo, logoCount); if (logoCount > 0) setKeysInternal(KeyAddressGroup::logo, logo, logoCount);
if (indicatorsCount > 0) setKeysInternal(KeyAddressGroup::indicators, indicators, indicatorsCount); if (indicatorsCount > 0) setKeysInternal(KeyAddressGroup::indicators, indicators, indicatorsCount);
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 = 2; // Normally max 14 but dont work
for (int i = 0; i < keysCount; i = i + maxKeyValueCount) { 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); setKeysInternal(KeyAddressGroup::keys, keysBlock, keysBlockCount);
} }
} }
if (gkeysCount > 0) setKeysInternal(KeyAddressGroup::gkeys, gkeys, gkeysCount); if (gkeysCount > 0) setKeysInternal(KeyAddressGroup::gkeys, gkeys, gkeysCount);
return true; 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}=="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}=="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}=="c32b", MODE="660", GROUP="users"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c335", MODE="660", GROUP="users"