mirror of
https://github.com/MatMoul/g810-led.git
synced 2024-12-23 09:16:11 +00:00
Initial work to add G213 support
Currently supported: - G213 by region {1..5} - Standard FX calls - Startup behavior - Help and command-line app support resolves MatMoul/g810-led#69 Signed-off-by: Kevin Pearson <pearson.kevin.m@gmail.com>
This commit is contained in:
parent
1f0458ea4f
commit
793aa0d557
2
makefile
2
makefile
@ -55,6 +55,7 @@ setup:
|
|||||||
$(DESTDIR)/etc/$(PROGN)/samples \
|
$(DESTDIR)/etc/$(PROGN)/samples \
|
||||||
$(DESTDIR)/etc/udev/rules.d
|
$(DESTDIR)/etc/udev/rules.d
|
||||||
@cp bin/$(PROGN) $(DESTDIR)/usr/bin
|
@cp bin/$(PROGN) $(DESTDIR)/usr/bin
|
||||||
|
@test -s $(DESTDIR)/usr/bin/g213-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g213-led
|
||||||
@test -s $(DESTDIR)/usr/bin/g410-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g410-led
|
@test -s $(DESTDIR)/usr/bin/g410-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g410-led
|
||||||
@test -s $(DESTDIR)/usr/bin/g610-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g610-led
|
@test -s $(DESTDIR)/usr/bin/g610-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g610-led
|
||||||
@test -s $(DESTDIR)/usr/bin/g910-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g910-led
|
@test -s $(DESTDIR)/usr/bin/g910-led || ln -s /usr/bin/$(PROGN) $(DESTDIR)/usr/bin/g910-led
|
||||||
@ -99,6 +100,7 @@ uninstall:
|
|||||||
systemctl daemon-reload && \
|
systemctl daemon-reload && \
|
||||||
rm -R /etc/$(PROGN)
|
rm -R /etc/$(PROGN)
|
||||||
|
|
||||||
|
@rm /usr/bin/g213-led
|
||||||
@rm /usr/bin/g410-led
|
@rm /usr/bin/g410-led
|
||||||
@rm /usr/bin/g610-led
|
@rm /usr/bin/g610-led
|
||||||
@rm /usr/bin/g910-led
|
@rm /usr/bin/g910-led
|
||||||
|
@ -231,6 +231,8 @@ LedKeyboard::KeyboardModel LedKeyboard::getKeyboardModel() {
|
|||||||
bool LedKeyboard::commit() {
|
bool LedKeyboard::commit() {
|
||||||
byte_buffer_t data;
|
byte_buffer_t data;
|
||||||
switch (m_keyboardModel) {
|
switch (m_keyboardModel) {
|
||||||
|
case KeyboardModel::g213:
|
||||||
|
break; // Keyboard is non-transactional
|
||||||
case KeyboardModel::g410:
|
case KeyboardModel::g410:
|
||||||
case KeyboardModel::g610:
|
case KeyboardModel::g610:
|
||||||
case KeyboardModel::g810:
|
case KeyboardModel::g810:
|
||||||
@ -430,17 +432,32 @@ bool LedKeyboard::setGroupKeys(KeyGroup keyGroup, LedKeyboard::Color color) {
|
|||||||
|
|
||||||
bool LedKeyboard::setAllKeys(LedKeyboard::Color color) {
|
bool LedKeyboard::setAllKeys(LedKeyboard::Color color) {
|
||||||
KeyValueArray keyValues;
|
KeyValueArray keyValues;
|
||||||
for (uint8_t i = 0; i < keyGroupLogo.size(); i++) keyValues.push_back({keyGroupLogo[i], color});
|
|
||||||
for (uint8_t i = 0; i < keyGroupIndicators.size(); i++) keyValues.push_back({keyGroupIndicators[i], color});
|
switch (m_keyboardModel) {
|
||||||
for (uint8_t i = 0; i < keyGroupMultimedia.size(); i++) keyValues.push_back({keyGroupMultimedia[i], color});
|
case KeyboardModel::g213:
|
||||||
for (uint8_t i = 0; i < keyGroupGKeys.size(); i++) keyValues.push_back({keyGroupGKeys[i], color});
|
for (uint8_t rIndex=0x01; rIndex <= 0x05; rIndex++) {
|
||||||
for (uint8_t i = 0; i < keyGroupFKeys.size(); i++) keyValues.push_back({keyGroupFKeys[i], color});
|
if (! setRegion(rIndex,color)) return false;
|
||||||
for (uint8_t i = 0; i < keyGroupFunctions.size(); i++) keyValues.push_back({keyGroupFunctions[i], color});
|
}
|
||||||
for (uint8_t i = 0; i < keyGroupArrows.size(); i++) keyValues.push_back({keyGroupArrows[i], color});
|
return true;
|
||||||
for (uint8_t i = 0; i < keyGroupNumeric.size(); i++) keyValues.push_back({keyGroupNumeric[i], color});
|
case KeyboardModel::g410:
|
||||||
for (uint8_t i = 0; i < keyGroupModifiers.size(); i++) keyValues.push_back({keyGroupModifiers[i], color});
|
case KeyboardModel::g610:
|
||||||
for (uint8_t i = 0; i < keyGroupKeys.size(); i++) keyValues.push_back({keyGroupKeys[i], color});
|
case KeyboardModel::g810:
|
||||||
return setKeys(keyValues);
|
case KeyboardModel::g910:
|
||||||
|
for (uint8_t i = 0; i < keyGroupLogo.size(); i++) keyValues.push_back({keyGroupLogo[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupIndicators.size(); i++) keyValues.push_back({keyGroupIndicators[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupMultimedia.size(); i++) keyValues.push_back({keyGroupMultimedia[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupGKeys.size(); i++) keyValues.push_back({keyGroupGKeys[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupFKeys.size(); i++) keyValues.push_back({keyGroupFKeys[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupFunctions.size(); i++) keyValues.push_back({keyGroupFunctions[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupArrows.size(); i++) keyValues.push_back({keyGroupArrows[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupNumeric.size(); i++) keyValues.push_back({keyGroupNumeric[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupModifiers.size(); i++) keyValues.push_back({keyGroupModifiers[i], color});
|
||||||
|
for (uint8_t i = 0; i < keyGroupKeys.size(); i++) keyValues.push_back({keyGroupKeys[i], color});
|
||||||
|
return setKeys(keyValues);
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -510,10 +527,25 @@ bool LedKeyboard::setGKeysMode(uint8_t value) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LedKeyboard::setRegion(uint8_t region, LedKeyboard::Color color) {
|
||||||
|
LedKeyboard::byte_buffer_t data;
|
||||||
|
switch (m_keyboardModel) {
|
||||||
|
case KeyboardModel::g213:
|
||||||
|
data = {0x11, 0xff, 0x0c, 0x3a, region, 0x01, color.red, color.green, color.blue };
|
||||||
|
data.resize(20,0x00);
|
||||||
|
return sendDataInternal(data);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool LedKeyboard::setStartupMode(StartupMode startupMode) {
|
bool LedKeyboard::setStartupMode(StartupMode startupMode) {
|
||||||
byte_buffer_t data;
|
byte_buffer_t data;
|
||||||
switch (m_keyboardModel) {
|
switch (m_keyboardModel) {
|
||||||
|
case KeyboardModel::g213:
|
||||||
case KeyboardModel::g410:
|
case KeyboardModel::g410:
|
||||||
case KeyboardModel::g610:
|
case KeyboardModel::g610:
|
||||||
case KeyboardModel::g810:
|
case KeyboardModel::g810:
|
||||||
@ -535,6 +567,11 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui
|
|||||||
uint8_t protocolByte = 0;
|
uint8_t protocolByte = 0;
|
||||||
|
|
||||||
switch (m_keyboardModel) {
|
switch (m_keyboardModel) {
|
||||||
|
case KeyboardModel::g213:
|
||||||
|
protocolByte = 0x0c;
|
||||||
|
|
||||||
|
if (part == NativeEffectPart::logo) return false; //Does not have logo component
|
||||||
|
break;
|
||||||
case KeyboardModel::g410:
|
case KeyboardModel::g410:
|
||||||
case KeyboardModel::g610: // Unconfirmed
|
case KeyboardModel::g610: // Unconfirmed
|
||||||
case KeyboardModel::g810:
|
case KeyboardModel::g810:
|
||||||
@ -653,6 +690,8 @@ bool LedKeyboard::sendDataInternal(byte_buffer_t &data) {
|
|||||||
|
|
||||||
LedKeyboard::byte_buffer_t LedKeyboard::getKeyGroupAddress(LedKeyboard::KeyAddressGroup keyAddressGroup) {
|
LedKeyboard::byte_buffer_t LedKeyboard::getKeyGroupAddress(LedKeyboard::KeyAddressGroup keyAddressGroup) {
|
||||||
switch (m_keyboardModel) {
|
switch (m_keyboardModel) {
|
||||||
|
case KeyboardModel::g213:
|
||||||
|
return {}; // Device doesn't support per-key setting
|
||||||
case KeyboardModel::g410:
|
case KeyboardModel::g410:
|
||||||
case KeyboardModel::g610:
|
case KeyboardModel::g610:
|
||||||
case KeyboardModel::g810:
|
case KeyboardModel::g810:
|
||||||
|
@ -17,6 +17,7 @@ class LedKeyboard {
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
const std::vector<std::vector<uint16_t>> SupportedKeyboards = {
|
const std::vector<std::vector<uint16_t>> SupportedKeyboards = {
|
||||||
|
{ 0x46d, 0xc336, (u_int16_t)KeyboardModel::g213 },
|
||||||
{ 0x46d, 0xc330, (u_int16_t)KeyboardModel::g410 },
|
{ 0x46d, 0xc330, (u_int16_t)KeyboardModel::g410 },
|
||||||
{ 0x46d, 0xc333, (u_int16_t)KeyboardModel::g610 },
|
{ 0x46d, 0xc333, (u_int16_t)KeyboardModel::g610 },
|
||||||
{ 0x46d, 0xc338, (u_int16_t)KeyboardModel::g610 },
|
{ 0x46d, 0xc338, (u_int16_t)KeyboardModel::g610 },
|
||||||
@ -40,6 +41,7 @@ class LedKeyboard {
|
|||||||
|
|
||||||
enum class KeyboardModel : uint8_t {
|
enum class KeyboardModel : uint8_t {
|
||||||
unknown = 0x00,
|
unknown = 0x00,
|
||||||
|
g213,
|
||||||
g410,
|
g410,
|
||||||
g610,
|
g610,
|
||||||
g810,
|
g810,
|
||||||
@ -144,6 +146,7 @@ class LedKeyboard {
|
|||||||
bool setMNKey(uint8_t value);
|
bool setMNKey(uint8_t value);
|
||||||
bool setGKeysMode(uint8_t value);
|
bool setGKeysMode(uint8_t value);
|
||||||
|
|
||||||
|
bool setRegion(uint8_t region, Color color);
|
||||||
bool setStartupMode(StartupMode startupMode);
|
bool setStartupMode(StartupMode startupMode);
|
||||||
|
|
||||||
bool setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color);
|
bool setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color);
|
||||||
|
@ -19,6 +19,10 @@ namespace help {
|
|||||||
cout<<" -a {color}\t\t\t\tSet all keys color"<<endl;
|
cout<<" -a {color}\t\t\t\tSet all keys color"<<endl;
|
||||||
cout<<" -g {keygroup} {color}\t\t\tSet key group color"<<endl;
|
cout<<" -g {keygroup} {color}\t\t\tSet key group color"<<endl;
|
||||||
cout<<" -k {key} {color}\t\t\tSet key color"<<endl;
|
cout<<" -k {key} {color}\t\t\tSet key color"<<endl;
|
||||||
|
if (cmdName == "g213-led")
|
||||||
|
{
|
||||||
|
cout<<" -r {region} {color}\t\t\tSet the color of a region for a region-based keyboard"<<endl;
|
||||||
|
}
|
||||||
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;
|
||||||
@ -50,6 +54,10 @@ namespace help {
|
|||||||
cout<<"color formats :\t\t\t\tII (hex value for intensity)"<<endl;
|
cout<<"color formats :\t\t\t\tII (hex value for intensity)"<<endl;
|
||||||
else
|
else
|
||||||
cout<<"color formats :\t\t\t\tRRGGBB (hex value for red, green and blue)"<<endl;
|
cout<<"color formats :\t\t\t\tRRGGBB (hex value for red, green and blue)"<<endl;
|
||||||
|
if (cmdName == "g213-led")
|
||||||
|
{
|
||||||
|
cout<<"region formats :\t\t\tRN (integer value for region, 1 to 5)"<<endl;
|
||||||
|
}
|
||||||
cout<<"speed formats :\t\t\t\tSS (hex value for speed 01 to ff)"<<endl;
|
cout<<"speed formats :\t\t\t\tSS (hex value for speed 01 to ff)"<<endl;
|
||||||
cout<<""<<endl;
|
cout<<""<<endl;
|
||||||
cout<<"key values :\t\t\t\tabc... 123... and other (use --help-keys for more detail)"<<endl;
|
cout<<"key values :\t\t\t\tabc... 123... and other (use --help-keys for more detail)"<<endl;
|
||||||
|
10
src/main.cpp
10
src/main.cpp
@ -70,6 +70,15 @@ int setGKeysMode(LedKeyboard &kbd, std::string arg2) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setRegion(LedKeyboard &kbd, std::string arg2, std::string arg3) {
|
||||||
|
uint8_t region = 0;
|
||||||
|
LedKeyboard::Color color;
|
||||||
|
|
||||||
|
if (! utils::parseColor(arg3, color)) return 1;
|
||||||
|
if (! utils::parseUInt8(arg2, region)) return 1;
|
||||||
|
if (kbd.setRegion(region,color)) return 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -238,6 +247,7 @@ int main(int argc, char **argv) {
|
|||||||
else if (argc > 2 && arg == "-an") return setAllKeys(kbd, argv[2], false);
|
else if (argc > 2 && arg == "-an") return setAllKeys(kbd, argv[2], false);
|
||||||
else if (argc > 3 && arg == "-gn") return setGroupKeys(kbd, argv[2], argv[3], false);
|
else if (argc > 3 && arg == "-gn") return setGroupKeys(kbd, argv[2], argv[3], false);
|
||||||
else if (argc > 3 && arg == "-kn") return setKey(kbd, argv[2], argv[3], false);
|
else if (argc > 3 && arg == "-kn") return setKey(kbd, argv[2], argv[3], false);
|
||||||
|
else if (argc > 3 && arg == "-r") return setRegion(kbd, argv[2], argv[3]);
|
||||||
|
|
||||||
else if (argc > 2 && arg == "-gkm") return setGKeysMode(kbd, argv[2]);
|
else if (argc > 2 && arg == "-gkm") return setGKeysMode(kbd, argv[2]);
|
||||||
|
|
||||||
|
BIN
wireshark_dumps/g213-prodigy/DisableStartupEffect.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/DisableStartupEffect.pcapng
Normal file
Binary file not shown.
BIN
wireshark_dumps/g213-prodigy/EnableStartupEffect.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/EnableStartupEffect.pcapng
Normal file
Binary file not shown.
BIN
wireshark_dumps/g213-prodigy/Region1_E2-3F-5C.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/Region1_E2-3F-5C.pcapng
Normal file
Binary file not shown.
BIN
wireshark_dumps/g213-prodigy/Region2_E2-3F-5C.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/Region2_E2-3F-5C.pcapng
Normal file
Binary file not shown.
BIN
wireshark_dumps/g213-prodigy/Region3_E2-3F-5C.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/Region3_E2-3F-5C.pcapng
Normal file
Binary file not shown.
BIN
wireshark_dumps/g213-prodigy/Region4_E2-3F-5C.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/Region4_E2-3F-5C.pcapng
Normal file
Binary file not shown.
BIN
wireshark_dumps/g213-prodigy/Region5_E2-3F-5C.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/Region5_E2-3F-5C.pcapng
Normal file
Binary file not shown.
BIN
wireshark_dumps/g213-prodigy/SetFX_FixedColor_E2-3F-5C.pcapng
Normal file
BIN
wireshark_dumps/g213-prodigy/SetFX_FixedColor_E2-3F-5C.pcapng
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user