mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 09:16:11 +00:00
Merge develop
This commit is contained in:
commit
e8ac81a558
@ -693,6 +693,33 @@ bool LedKeyboard::setStartupMode(StartupMode startupMode) {
|
|||||||
bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color) {
|
bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color) {
|
||||||
uint8_t protocolByte = 0;
|
uint8_t protocolByte = 0;
|
||||||
|
|
||||||
|
// NativeEffectPart::all is not in the device protocol, but an alias for both keys and logo, plus indicators
|
||||||
|
if (part == LedKeyboard::NativeEffectPart::all) {
|
||||||
|
switch (effect) {
|
||||||
|
case LedKeyboard::NativeEffect::color:
|
||||||
|
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;
|
||||||
|
if (! commit()) return false;
|
||||||
|
break;
|
||||||
|
case LedKeyboard::NativeEffect::breathing:
|
||||||
|
if (! setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) return false;;
|
||||||
|
if (! commit()) return false;;
|
||||||
|
break;
|
||||||
|
case LedKeyboard::NativeEffect::cycle:
|
||||||
|
case LedKeyboard::NativeEffect::hwave:
|
||||||
|
case LedKeyboard::NativeEffect::vwave:
|
||||||
|
case LedKeyboard::NativeEffect::cwave:
|
||||||
|
if (! setGroupKeys(
|
||||||
|
LedKeyboard::KeyGroup::indicators,
|
||||||
|
LedKeyboard::Color({0xff, 0xff, 0xff}))
|
||||||
|
) return false;
|
||||||
|
if (! commit()) return false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
setNativeEffect(effect, LedKeyboard::NativeEffectPart::keys, speed, color) &&
|
||||||
|
setNativeEffect(effect, LedKeyboard::NativeEffectPart::logo, speed, color));
|
||||||
|
}
|
||||||
|
|
||||||
switch (currentDevice.model) {
|
switch (currentDevice.model) {
|
||||||
case KeyboardModel::g213:
|
case KeyboardModel::g213:
|
||||||
protocolByte = 0x0c;
|
protocolByte = 0x0c;
|
||||||
@ -783,7 +810,7 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
|
|||||||
bool LedKeyboard::sendDataInternal(byte_buffer_t &data) {
|
bool LedKeyboard::sendDataInternal(byte_buffer_t &data) {
|
||||||
if (data.size() > 0) {
|
if (data.size() > 0) {
|
||||||
#if defined(hidapi)
|
#if defined(hidapi)
|
||||||
if (! open()) return false;
|
if (! open(currentDevice.vendorID, currentDevice.productID, currentDevice.serialNumber)) return false;
|
||||||
data.insert(data.begin(), 0x00);
|
data.insert(data.begin(), 0x00);
|
||||||
if (hid_write(m_hidHandle, const_cast<unsigned char*>(data.data()), data.size()) < 0) {
|
if (hid_write(m_hidHandle, const_cast<unsigned char*>(data.data()), data.size()) < 0) {
|
||||||
std::cout<<"Error: Can not write to hidraw, try with the libusb version"<<std::endl;
|
std::cout<<"Error: Can not write to hidraw, try with the libusb version"<<std::endl;
|
||||||
|
@ -357,39 +357,9 @@ namespace utils {
|
|||||||
|
|
||||||
if (! kbd.open()) return 1;
|
if (! kbd.open()) return 1;
|
||||||
|
|
||||||
int retval = 0;
|
if (! kbd.setNativeEffect(effect, effectPart, speed, color)) return 1;
|
||||||
|
|
||||||
switch (effectPart) {
|
return 0;
|
||||||
case LedKeyboard::NativeEffectPart::all:
|
|
||||||
switch (effect) {
|
|
||||||
case LedKeyboard::NativeEffect::color:
|
|
||||||
if (! kbd.setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) retval = 1;
|
|
||||||
if (! kbd.commit()) retval = 1;
|
|
||||||
break;
|
|
||||||
case LedKeyboard::NativeEffect::breathing:
|
|
||||||
if (! kbd.setGroupKeys(LedKeyboard::KeyGroup::indicators, color)) retval = 1;
|
|
||||||
if (! kbd.commit()) retval = 1;
|
|
||||||
break;
|
|
||||||
case LedKeyboard::NativeEffect::cycle:
|
|
||||||
case LedKeyboard::NativeEffect::hwave:
|
|
||||||
case LedKeyboard::NativeEffect::vwave:
|
|
||||||
case LedKeyboard::NativeEffect::cwave:
|
|
||||||
if (! kbd.setGroupKeys(
|
|
||||||
LedKeyboard::KeyGroup::indicators,
|
|
||||||
LedKeyboard::Color({0xff, 0xff, 0xff}))
|
|
||||||
) retval = 1;
|
|
||||||
if (! kbd.commit()) retval = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (! kbd.setNativeEffect(effect, LedKeyboard::NativeEffectPart::keys, speed, color)) retval = 1;
|
|
||||||
if (! kbd.setNativeEffect(effect, LedKeyboard::NativeEffectPart::logo, speed, color)) retval = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if (! kbd.setNativeEffect(effect, effectPart, speed, color)) retval = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user