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

Add GKeys mapping mode suport

This commit is contained in:
MatMoul 2017-03-11 21:14:50 +01:00
parent 664f1346c7
commit 8931db5685
4 changed files with 36 additions and 0 deletions

View File

@ -490,6 +490,26 @@ bool LedKeyboard::setMNKey(uint8_t value) {
return false; return false;
} }
bool LedKeyboard::setGKeysMode(uint8_t value) {
LedKeyboard::byte_buffer_t data;
switch (m_keyboardModel) {
case KeyboardModel::g910:
switch (value) {
case 0x00:
case 0x01:
data = { 0x11, 0xff, 0x08, 0x2e, value };
data.resize(20, 0x00);
return sendDataInternal(data);
default:
break;
}
break;
default:
break;
}
return false;
}
bool LedKeyboard::setStartupMode(StartupMode startupMode) { bool LedKeyboard::setStartupMode(StartupMode startupMode) {
byte_buffer_t data; byte_buffer_t data;

View File

@ -142,6 +142,7 @@ class LedKeyboard {
bool setMRKey(uint8_t value); bool setMRKey(uint8_t value);
bool setMNKey(uint8_t value); bool setMNKey(uint8_t value);
bool setGKeysMode(uint8_t value);
bool setStartupMode(StartupMode startupMode); bool setStartupMode(StartupMode startupMode);

View File

@ -22,6 +22,8 @@ namespace help {
if (cmdName == "g910-led") { if (cmdName == "g910-led") {
cout<<" -mr {value}\t\t\t\tSet MR key (0-1)"<<endl; cout<<" -mr {value}\t\t\t\tSet MR key (0-1)"<<endl;
cout<<" -mn {value}\t\t\t\tSet MN key (0-7) (M1=1, M2=2, M3=4) (M1+M2=3, M1+M3=5, ...)"<<endl; cout<<" -mn {value}\t\t\t\tSet MN key (0-7) (M1=1, M2=2, M3=4) (M1+M2=3, M1+M3=5, ...)"<<endl;
cout<<endl;
cout<<" -gkm {value}\t\t\t\tSet GKeys mode (0=Mapped to FKeys, 1=Independent)"<<endl;
} }
cout<<endl; cout<<endl;
cout<<" -an {color}\t\t\t\tSet all keys color without commit"<<endl; cout<<" -an {color}\t\t\t\tSet all keys color without commit"<<endl;

View File

@ -64,6 +64,15 @@ int setMNKey(LedKeyboard &kbd, std::string arg2, bool commit = true) {
return 0; return 0;
} }
int setGKeysMode(LedKeyboard &kbd, std::string arg2, bool commit = true) {
uint8_t value;
if (! utils::parseUInt8(arg2, value)) return 1;
if (! kbd.open()) return 1;
if (! kbd.setGKeysMode(value)) return 1;
//if (commit) if(! kbd.commit()) return 1;
return 0;
}
int setFX(LedKeyboard &kbd, std::string arg2, std::string arg3, std::string arg4, std::string arg5 = "") { int setFX(LedKeyboard &kbd, std::string arg2, std::string arg3, std::string arg4, std::string arg5 = "") {
LedKeyboard::NativeEffect effect; LedKeyboard::NativeEffect effect;
@ -178,6 +187,8 @@ int parseProfile(LedKeyboard &kbd, std::istream &stream) {
if (setMRKey(kbd, args[1], false) == 1) retval = 1; if (setMRKey(kbd, args[1], false) == 1) retval = 1;
} else if (args[0] == "mn" && args.size() > 1) { } else if (args[0] == "mn" && args.size() > 1) {
if (setMNKey(kbd, args[1], false) == 1) retval = 1; if (setMNKey(kbd, args[1], false) == 1) retval = 1;
} else if (args[0] == "gkm" && args.size() > 1) {
if (setGKeysMode(kbd, args[1], false) == 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) {
@ -233,6 +244,8 @@ int main(int argc, char **argv) {
else if (argc > 2 && arg == "-mrn") return setMRKey(kbd, argv[2], false); else if (argc > 2 && arg == "-mrn") return setMRKey(kbd, argv[2], false);
else if (argc > 2 && arg == "-mnn") return setMNKey(kbd, argv[2], false); else if (argc > 2 && arg == "-mnn") return setMNKey(kbd, argv[2], false);
else if (argc > 2 && arg == "-gkm") return setGKeysMode(kbd, argv[2]);
else if (argc > 2 && arg == "-p") return loadProfile(kbd, argv[2]); else if (argc > 2 && arg == "-p") return loadProfile(kbd, argv[2]);
else if (argc > 1 && arg == "-pp") return pipeProfile(kbd); else if (argc > 1 && arg == "-pp") return pipeProfile(kbd);