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

add support for g815 on-board-mode

This commit is contained in:
cornernote 2020-01-14 08:40:45 +10:30
parent a3cbef418d
commit a5acdf4113
7 changed files with 63 additions and 9 deletions

View File

@ -755,9 +755,6 @@ bool LedKeyboard::setStartupMode(StartupMode startupMode) {
case KeyboardModel::gpro: case KeyboardModel::gpro:
data = { 0x11, 0xff, 0x0d, 0x5a, 0x00, 0x01 }; data = { 0x11, 0xff, 0x0d, 0x5a, 0x00, 0x01 };
break; break;
case KeyboardModel::g815:
data = { 0x11, 0xff, 0x11, 0x1b, 0x02 };
break;
case KeyboardModel::g910: case KeyboardModel::g910:
data = { 0x11, 0xff, 0x10, 0x5e, 0x00, 0x01 }; data = { 0x11, 0xff, 0x10, 0x5e, 0x00, 0x01 };
break; break;
@ -769,6 +766,30 @@ bool LedKeyboard::setStartupMode(StartupMode startupMode) {
return sendDataInternal(data); return sendDataInternal(data);
} }
bool LedKeyboard::setOnBoardMode(OnBoardMode onBoardMode) {
byte_buffer_t data;
switch (currentDevice.model) {
case KeyboardModel::g815:
switch (onBoardMode) {
case LedKeyboard::OnBoardMode::board:
data = { 0x11, 0xff, 0x11, 0x1a, 0x01 };
data.resize(20, 0x00);
return sendDataInternal(data);
case LedKeyboard::OnBoardMode::software:
data = { 0x11, 0xff, 0x11, 0x1b, 0x02 };
data.resize(20, 0x00);
return sendDataInternal(data);
default:
break;
}
break;
default:
return false;
}
data.push_back((unsigned char)onBoardMode);
data.resize(20, 0x00);
return sendDataInternal(data);
}
bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part,
std::chrono::duration<uint16_t, std::milli> period, Color color, std::chrono::duration<uint16_t, std::milli> period, Color color,

View File

@ -78,6 +78,10 @@ class LedKeyboard {
wave = 0x01, wave = 0x01,
color color
}; };
enum class OnBoardMode : uint8_t {
board = 0x01,
software
};
enum class NativeEffectGroup : uint8_t { enum class NativeEffectGroup : uint8_t {
off, off,
color, color,
@ -201,6 +205,7 @@ class LedKeyboard {
bool setRegion(uint8_t region, Color color); bool setRegion(uint8_t region, Color color);
bool setStartupMode(StartupMode startupMode); bool setStartupMode(StartupMode startupMode);
bool setOnBoardMode(OnBoardMode onBoardMode);
bool setNativeEffect(NativeEffect effect, NativeEffectPart part, bool setNativeEffect(NativeEffect effect, NativeEffectPart part,
std::chrono::duration<uint16_t, std::milli> period, Color color, std::chrono::duration<uint16_t, std::milli> period, Color color,

View File

@ -90,6 +90,10 @@ namespace help {
cout<<" --startup-mode {startup mode}\t\tSet startup mode"<<endl; cout<<" --startup-mode {startup mode}\t\tSet startup mode"<<endl;
cout<<endl; cout<<endl;
} }
if((features | KeyboardFeatures::onboardmode) == features) {
cout<<" --on-board-mode {on board mode}\t\tSet on-board mode"<<endl;
cout<<endl;
}
cout<<" --list-keyboards \t\t\tList connected keyboards"<<endl; cout<<" --list-keyboards \t\t\tList connected keyboards"<<endl;
cout<<" --print-device\t\t\tPrint device information for the keyboard"<<endl; cout<<" --print-device\t\t\tPrint device information for the keyboard"<<endl;
cout<<endl; cout<<endl;
@ -120,6 +124,7 @@ namespace help {
if((features | KeyboardFeatures::setgroup) == features) if((features | KeyboardFeatures::setgroup) == features)
cout<<" group values :\t\t\tlogo, indicators, fkeys, ... (use --help-keys for more detail)"<<endl; cout<<" group values :\t\t\tlogo, indicators, fkeys, ... (use --help-keys for more detail)"<<endl;
cout<<" startup mode :\t\t\twave, color"<<endl; cout<<" startup mode :\t\t\twave, color"<<endl;
cout<<" on-board mode :\t\t\tboard, software"<<endl;
cout<<endl; cout<<endl;
} }
@ -324,6 +329,9 @@ namespace help {
if((features | KeyboardFeatures::poweronfx) == features) if((features | KeyboardFeatures::poweronfx) == features)
cout<<cmdName<<" --startup-mode color # Set keyboard power on effect"<<endl; cout<<cmdName<<" --startup-mode color # Set keyboard power on effect"<<endl;
cout<<endl; cout<<endl;
if((features | KeyboardFeatures::onboardmode) == features)
cout<<cmdName<<" --on-board-mode color # Set keyboard power on effect"<<endl;
cout<<endl;
if((features | KeyboardFeatures::commit) == features) { if((features | KeyboardFeatures::commit) == features) {
cout<<"Samples with no commit :"<<endl; cout<<"Samples with no commit :"<<endl;
if((features | KeyboardFeatures::setall) == features) if((features | KeyboardFeatures::setall) == features)

View File

@ -39,10 +39,11 @@ namespace help {
poweronfx = 8192, poweronfx = 8192,
// "user-stored lighting" can be recalled with backlight+7 on the G Pro // "user-stored lighting" can be recalled with backlight+7 on the G Pro
userstoredlighting = 16384, userstoredlighting = 16384,
onboardmode = 32768,
// fx features // fx features
all = rgb | intensity | commit | logo1 | logo2 | numpad | multimedia | gkeys | all = rgb | intensity | commit | logo1 | logo2 | numpad | multimedia | gkeys |
setall | setgroup | setkey | setregion | setindicators | poweronfx | userstoredlighting, setall | setgroup | setkey | setregion | setindicators | poweronfx | userstoredlighting | onboardmode,
g213 = rgb | logo1 | numpad | multimedia | setall | setregion | setindicators | poweronfx | userstoredlighting, g213 = rgb | logo1 | numpad | multimedia | setall | setregion | setindicators | poweronfx | userstoredlighting,
g410 = rgb | commit | setall | setgroup | setkey | poweronfx | userstoredlighting, g410 = rgb | commit | setall | setgroup | setkey | poweronfx | userstoredlighting,
@ -50,7 +51,7 @@ namespace help {
g513 = rgb | commit | numpad | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting, g513 = rgb | commit | numpad | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting,
g610 = intensity | commit | logo1 | numpad | multimedia | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting, g610 = intensity | commit | logo1 | numpad | multimedia | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting,
g810 = rgb | commit | logo1 | numpad | multimedia | setall | setgroup | setkey | setindicators | poweronfx, g810 = rgb | commit | logo1 | numpad | multimedia | setall | setgroup | setkey | setindicators | poweronfx,
g815 = rgb | commit | logo1 | numpad | multimedia | gkeys | setall | setgroup | setkey | setindicators | poweronfx, g815 = rgb | commit | logo1 | numpad | multimedia | gkeys | setall | setgroup | setkey | setindicators | onboardmode,
g910 = rgb | commit | logo1 | logo2 | numpad | multimedia | gkeys | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting, g910 = rgb | commit | logo1 | logo2 | numpad | multimedia | gkeys | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting,
gpro = rgb | commit | logo1 | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting gpro = rgb | commit | logo1 | setall | setgroup | setkey | setindicators | poweronfx | userstoredlighting
}; };

View File

@ -37,6 +37,13 @@ namespace utils {
return true; return true;
} }
bool parseOnBoardMode(std::string val, LedKeyboard::OnBoardMode &onBoardMode) {
if (val == "software") onBoardMode = LedKeyboard::OnBoardMode ::software;
else if (val == "board") onBoardMode = LedKeyboard::OnBoardMode::board;
else return false;
return true;
}
bool parseNativeEffect(std::string val, LedKeyboard::NativeEffect &nativeEffect) { bool parseNativeEffect(std::string val, LedKeyboard::NativeEffect &nativeEffect) {
if (val == "color") nativeEffect = LedKeyboard::NativeEffect::color; if (val == "color") nativeEffect = LedKeyboard::NativeEffect::color;
else if (val == "cycle") nativeEffect = LedKeyboard::NativeEffect::cycle; else if (val == "cycle") nativeEffect = LedKeyboard::NativeEffect::cycle;

View File

@ -26,6 +26,7 @@ namespace utils {
std::string getCmdName(std::string cmd); std::string getCmdName(std::string cmd);
bool parseStartupMode(std::string val, LedKeyboard::StartupMode &startupMode); bool parseStartupMode(std::string val, LedKeyboard::StartupMode &startupMode);
bool parseOnBoardMode(std::string val, LedKeyboard::OnBoardMode &onBoardMode);
bool parseNativeEffect(std::string val, LedKeyboard::NativeEffect &nativeEffect); bool parseNativeEffect(std::string val, LedKeyboard::NativeEffect &nativeEffect);
bool parseNativeEffectPart(std::string val, LedKeyboard::NativeEffectPart &nativeEffectPart); bool parseNativeEffectPart(std::string val, LedKeyboard::NativeEffectPart &nativeEffectPart);
bool parseKey(std::string val, LedKeyboard::Key &key); bool parseKey(std::string val, LedKeyboard::Key &key);

View File

@ -171,6 +171,14 @@ int setStartupMode(LedKeyboard &kbd, std::string arg2) {
return 1; return 1;
} }
int setOnBoardMode(LedKeyboard &kbd, std::string arg2) {
LedKeyboard::OnBoardMode onBoardMode;
if (! utils::parseOnBoardMode(arg2, onBoardMode)) return 1;
if (! kbd.open()) return 1;
if (kbd.setOnBoardMode(onBoardMode)) return 0;
return 1;
}
int parseProfile(LedKeyboard &kbd, std::istream &stream) { int parseProfile(LedKeyboard &kbd, std::istream &stream) {
std::string line; std::string line;
@ -219,6 +227,8 @@ int parseProfile(LedKeyboard &kbd, std::istream &stream) {
if (setGKeysMode(kbd, args[1]) == 1) retval = 1; if (setGKeysMode(kbd, args[1]) == 1) retval = 1;
} else if (args[0] == "sm" && args.size() > 1) { } else if (args[0] == "sm" && args.size() > 1) {
if (setStartupMode(kbd, args[1]) == 1) retval = 1; if (setStartupMode(kbd, args[1]) == 1) retval = 1;
} else if (args[0] == "obm" && args.size() > 1) {
if (setOnBoardMode(kbd, args[1]) == 1) retval = 1;
} else if (args[0] == "fx" && args.size() > 4) { } else if (args[0] == "fx" && args.size() > 4) {
if (setFX(kbd, args[1], args[2], args[3], args[4]) == 1) retval = 1; if (setFX(kbd, args[1], args[2], args[3], args[4]) == 1) retval = 1;
} else if (args[0] == "fx" && args.size() > 3) { } else if (args[0] == "fx" && args.size() > 3) {
@ -336,6 +346,7 @@ int main(int argc, char **argv) {
else if (argc > (argIndex + 3) && arg == "-fx-store") else if (argc > (argIndex + 3) && arg == "-fx-store")
return storeFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3]); return storeFX(kbd, argv[argIndex + 1], argv[argIndex + 2], argv[argIndex + 3]);
else if (argc > (argIndex + 1) && arg == "--startup-mode") return setStartupMode(kbd, argv[argIndex + 1]); else if (argc > (argIndex + 1) && arg == "--startup-mode") return setStartupMode(kbd, argv[argIndex + 1]);
else if (argc > (argIndex + 1) && arg == "--on-board-mode") return setOnBoardMode(kbd, argv[argIndex + 1]);
else { help::usage(argv[0]); return 1; } else { help::usage(argv[0]); return 1; }
} }