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

Rename keyboard protocol version

This commit is contained in:
MatMoul 2016-12-06 22:54:04 +01:00
parent bc3280f851
commit a4a0b83542
2 changed files with 10 additions and 10 deletions

View File

@ -28,14 +28,14 @@ bool Keyboard::attach() {
if (desc.idProduct == 0xc337) { pid = desc.idProduct; break; } // G810 spectrum if (desc.idProduct == 0xc337) { pid = desc.idProduct; break; } // G810 spectrum
if (desc.idProduct == 0xc330) { pid = desc.idProduct; break; } // G410 spectrum if (desc.idProduct == 0xc330) { pid = desc.idProduct; break; } // G410 spectrum
if (desc.idProduct == 0xc333) { pid = desc.idProduct; break; } // G610 spectrum if (desc.idProduct == 0xc333) { pid = desc.idProduct; break; } // G610 spectrum
if (desc.idProduct == 0xc32b) { // G910 spark if (desc.idProduct == 0xc32b) { // G910 spark
pid = desc.idProduct; pid = desc.idProduct;
kbdProtocol = KeyboardProtocol::spark; kbdProtocol = KeyboardProtocol::g910;
break; break;
} }
if (desc.idProduct == 0xc335) { if (desc.idProduct == 0xc335) { // G910 spectrum
pid = desc.idProduct; pid = desc.idProduct;
kbdProtocol = KeyboardProtocol::spark; kbdProtocol = KeyboardProtocol::g910;
break; break;
} }
} }
@ -85,13 +85,13 @@ bool Keyboard::commit() {
bool retval = false; bool retval = false;
unsigned char *data = new unsigned char[20]; unsigned char *data = new unsigned char[20];
switch (kbdProtocol) { switch (kbdProtocol) {
case KeyboardProtocol::spectrum: case KeyboardProtocol::generic:
data[0] = 0x11; data[0] = 0x11;
data[1] = 0xff; data[1] = 0xff;
data[2] = 0x0c; data[2] = 0x0c;
data[3] = 0x5a; data[3] = 0x5a;
break; break;
case KeyboardProtocol::spark: case KeyboardProtocol::g910:
data[0] = 0x11; data[0] = 0x11;
data[1] = 0xff; data[1] = 0xff;
data[2] = 0x0f; data[2] = 0x0f;
@ -488,7 +488,7 @@ bool Keyboard::sendDataInternal(unsigned char *data, int data_size) {
bool Keyboard::populateAddressGroupInternal(KeyAddressGroup addressGroup, unsigned char *data) { bool Keyboard::populateAddressGroupInternal(KeyAddressGroup addressGroup, unsigned char *data) {
switch (kbdProtocol) { switch (kbdProtocol) {
case KeyboardProtocol::spectrum: case KeyboardProtocol::generic:
switch (addressGroup) { switch (addressGroup) {
case KeyAddressGroup::logo: case KeyAddressGroup::logo:
data[0] = 0x11; // Base address data[0] = 0x11; // Base address
@ -535,7 +535,7 @@ bool Keyboard::populateAddressGroupInternal(KeyAddressGroup addressGroup, unsign
break; break;
} }
break; break;
case KeyboardProtocol::spark: // gkeys and mkeys seem not changeable case KeyboardProtocol::g910: // gkeys and mkeys seem not changeable
switch (addressGroup) { switch (addressGroup) {
case KeyAddressGroup::logo: case KeyAddressGroup::logo:
data[0] = 0x11; // Base address data[0] = 0x11; // Base address

View File

@ -8,7 +8,7 @@ class Keyboard {
public: public:
enum class KeyboardProtocol { spectrum, spark }; enum class KeyboardProtocol { generic, g910 };
enum class PowerOnEffect { rainbow, color }; enum class PowerOnEffect { rainbow, color };
enum class KeyAddressGroup { logo, indicators, multimedia, keys, gkeys }; enum class KeyAddressGroup { logo, indicators, multimedia, keys, gkeys };
enum class Key { // 127 items enum class Key { // 127 items
@ -57,7 +57,7 @@ class Keyboard {
bool m_isAttached = false; bool m_isAttached = false;
bool m_isKernellDetached = false; bool m_isKernellDetached = false;
KeyboardProtocol kbdProtocol = KeyboardProtocol::spectrum; KeyboardProtocol kbdProtocol = KeyboardProtocol::generic;
libusb_device **devs; libusb_device **devs;
libusb_device_handle *dev_handle; libusb_device_handle *dev_handle;
libusb_context *ctx = NULL; libusb_context *ctx = NULL;