diff --git a/makefile b/makefile index 3b420a6..bef2777 100644 --- a/makefile +++ b/makefile @@ -55,6 +55,7 @@ setup: $(DESTDIR)/etc/$(PROGN)/samples \ $(DESTDIR)/etc/udev/rules.d @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/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 @@ -99,6 +100,7 @@ uninstall: systemctl daemon-reload && \ rm -R /etc/$(PROGN) + @rm /usr/bin/g213-led @rm /usr/bin/g410-led @rm /usr/bin/g610-led @rm /usr/bin/g910-led diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 37a7fd8..7d02fff 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -231,6 +231,8 @@ LedKeyboard::KeyboardModel LedKeyboard::getKeyboardModel() { bool LedKeyboard::commit() { byte_buffer_t data; switch (m_keyboardModel) { + case KeyboardModel::g213: + break; // Keyboard is non-transactional case KeyboardModel::g410: case KeyboardModel::g610: case KeyboardModel::g810: @@ -430,17 +432,32 @@ bool LedKeyboard::setGroupKeys(KeyGroup keyGroup, LedKeyboard::Color color) { bool LedKeyboard::setAllKeys(LedKeyboard::Color color) { 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}); - 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); + + switch (m_keyboardModel) { + case KeyboardModel::g213: + for (uint8_t rIndex=0x01; rIndex <= 0x05; rIndex++) { + if (! setRegion(rIndex,color)) return false; + } + return true; + case KeyboardModel::g410: + case KeyboardModel::g610: + case KeyboardModel::g810: + 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; } +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) { byte_buffer_t data; switch (m_keyboardModel) { + case KeyboardModel::g213: case KeyboardModel::g410: case KeyboardModel::g610: case KeyboardModel::g810: @@ -535,6 +567,11 @@ bool LedKeyboard::setNativeEffect(NativeEffect effect, NativeEffectPart part, ui uint8_t protocolByte = 0; 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::g610: // Unconfirmed case KeyboardModel::g810: @@ -653,6 +690,8 @@ bool LedKeyboard::sendDataInternal(byte_buffer_t &data) { LedKeyboard::byte_buffer_t LedKeyboard::getKeyGroupAddress(LedKeyboard::KeyAddressGroup keyAddressGroup) { switch (m_keyboardModel) { + case KeyboardModel::g213: + return {}; // Device doesn't support per-key setting case KeyboardModel::g410: case KeyboardModel::g610: case KeyboardModel::g810: diff --git a/src/classes/Keyboard.h b/src/classes/Keyboard.h index fdf7bbf..d99adda 100644 --- a/src/classes/Keyboard.h +++ b/src/classes/Keyboard.h @@ -17,6 +17,7 @@ class LedKeyboard { private: const std::vector> SupportedKeyboards = { + { 0x46d, 0xc336, (u_int16_t)KeyboardModel::g213 }, { 0x46d, 0xc330, (u_int16_t)KeyboardModel::g410 }, { 0x46d, 0xc333, (u_int16_t)KeyboardModel::g610 }, { 0x46d, 0xc338, (u_int16_t)KeyboardModel::g610 }, @@ -40,6 +41,7 @@ class LedKeyboard { enum class KeyboardModel : uint8_t { unknown = 0x00, + g213, g410, g610, g810, @@ -144,6 +146,7 @@ class LedKeyboard { bool setMNKey(uint8_t value); bool setGKeysMode(uint8_t value); + bool setRegion(uint8_t region, Color color); bool setStartupMode(StartupMode startupMode); bool setNativeEffect(NativeEffect effect, NativeEffectPart part, uint8_t speed, Color color); diff --git a/src/helpers/help.cpp b/src/helpers/help.cpp index cbcd74e..dffbd2f 100644 --- a/src/helpers/help.cpp +++ b/src/helpers/help.cpp @@ -19,6 +19,10 @@ namespace help { cout<<" -a {color}\t\t\t\tSet all keys color"< 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 == "-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]); diff --git a/wireshark_dumps/g213-prodigy/DisableStartupEffect.pcapng b/wireshark_dumps/g213-prodigy/DisableStartupEffect.pcapng new file mode 100644 index 0000000..6631133 Binary files /dev/null and b/wireshark_dumps/g213-prodigy/DisableStartupEffect.pcapng differ diff --git a/wireshark_dumps/g213-prodigy/EnableStartupEffect.pcapng b/wireshark_dumps/g213-prodigy/EnableStartupEffect.pcapng new file mode 100644 index 0000000..c243215 Binary files /dev/null and b/wireshark_dumps/g213-prodigy/EnableStartupEffect.pcapng differ diff --git a/wireshark_dumps/g213-prodigy/Region1_E2-3F-5C.pcapng b/wireshark_dumps/g213-prodigy/Region1_E2-3F-5C.pcapng new file mode 100644 index 0000000..591665d Binary files /dev/null and b/wireshark_dumps/g213-prodigy/Region1_E2-3F-5C.pcapng differ diff --git a/wireshark_dumps/g213-prodigy/Region2_E2-3F-5C.pcapng b/wireshark_dumps/g213-prodigy/Region2_E2-3F-5C.pcapng new file mode 100644 index 0000000..e89b8ac Binary files /dev/null and b/wireshark_dumps/g213-prodigy/Region2_E2-3F-5C.pcapng differ diff --git a/wireshark_dumps/g213-prodigy/Region3_E2-3F-5C.pcapng b/wireshark_dumps/g213-prodigy/Region3_E2-3F-5C.pcapng new file mode 100644 index 0000000..52b69f8 Binary files /dev/null and b/wireshark_dumps/g213-prodigy/Region3_E2-3F-5C.pcapng differ diff --git a/wireshark_dumps/g213-prodigy/Region4_E2-3F-5C.pcapng b/wireshark_dumps/g213-prodigy/Region4_E2-3F-5C.pcapng new file mode 100644 index 0000000..7a3ab7c Binary files /dev/null and b/wireshark_dumps/g213-prodigy/Region4_E2-3F-5C.pcapng differ diff --git a/wireshark_dumps/g213-prodigy/Region5_E2-3F-5C.pcapng b/wireshark_dumps/g213-prodigy/Region5_E2-3F-5C.pcapng new file mode 100644 index 0000000..d736fee Binary files /dev/null and b/wireshark_dumps/g213-prodigy/Region5_E2-3F-5C.pcapng differ diff --git a/wireshark_dumps/g213-prodigy/SetFX_FixedColor_E2-3F-5C.pcapng b/wireshark_dumps/g213-prodigy/SetFX_FixedColor_E2-3F-5C.pcapng new file mode 100644 index 0000000..f239f7b Binary files /dev/null and b/wireshark_dumps/g213-prodigy/SetFX_FixedColor_E2-3F-5C.pcapng differ