From be7d367079aea8b08ba6f04d730af6981d183a36 Mon Sep 17 00:00:00 2001 From: MatMoul Date: Sat, 11 Mar 2017 17:56:40 +0100 Subject: [PATCH] Add MKeys led control --- src/classes/Keyboard.cpp | 47 ++++++++++++++++++++++++++++++++++++++++ src/classes/Keyboard.h | 3 +++ src/helpers/help.cpp | 10 ++++++++- src/helpers/utils.cpp | 7 ++++++ src/helpers/utils.h | 1 + src/main.cpp | 22 +++++++++++++++++++ 6 files changed, 89 insertions(+), 1 deletion(-) diff --git a/src/classes/Keyboard.cpp b/src/classes/Keyboard.cpp index 1feea96..6eb2808 100644 --- a/src/classes/Keyboard.cpp +++ b/src/classes/Keyboard.cpp @@ -446,6 +446,53 @@ bool LedKeyboard::setAllKeys(LedKeyboard::Color color) { } +bool LedKeyboard::setMRKey(uint8_t value) { + LedKeyboard::byte_buffer_t data; + switch (m_keyboardModel) { + case KeyboardModel::g910: + switch (value) { + case 0x00: + case 0x01: + data = { 0x11, 0xff, 0x0a, 0x0e, value }; + data.resize(20, 0x00); + return sendDataInternal(data); + default: + break; + } + break; + default: + break; + } + return false; +} + +bool LedKeyboard::setMNKey(uint8_t value) { + LedKeyboard::byte_buffer_t data; + switch (m_keyboardModel) { + case KeyboardModel::g910: + switch (value) { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + data = { 0x11, 0xff, 0x09, 0x1e, value }; + data.resize(20, 0x00); + return sendDataInternal(data); + default: + break; + } + break; + default: + break; + } + return false; +} + + bool LedKeyboard::setStartupMode(StartupMode startupMode) { byte_buffer_t data; switch (m_keyboardModel) { diff --git a/src/classes/Keyboard.h b/src/classes/Keyboard.h index b59343f..b0d79d3 100644 --- a/src/classes/Keyboard.h +++ b/src/classes/Keyboard.h @@ -140,6 +140,9 @@ class LedKeyboard { bool setGroupKeys(KeyGroup keyGroup, Color color); bool setAllKeys(Color color); + bool setMRKey(uint8_t value); + bool setMNKey(uint8_t value); + 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 7a5c71c..1c3757f 100644 --- a/src/helpers/help.cpp +++ b/src/helpers/help.cpp @@ -8,7 +8,7 @@ using namespace std; namespace help { - string version = "0.1.0"; + string version = "0.1.1"; void usage(char *arg0) { string cmdName = utils::getCmdName(arg0); @@ -19,10 +19,18 @@ namespace help { cout<<" -a {color}\t\t\t\tSet all keys color"< 2 && arg == "-a") return setAllKeys(kbd, argv[2]); else if (argc > 3 && arg == "-g") return setGroupKeys(kbd, argv[2], argv[3]); else if (argc > 3 && arg == "-k") return setKey(kbd, argv[2], argv[3]); + else if (argc > 2 && arg == "-mr") return setMRKey(kbd, argv[2]); + else if (argc > 2 && arg == "-mn") return setMNKey(kbd, argv[2]); 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 == "-kn") return setKey(kbd, argv[2], argv[3], 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 == "-p") return loadProfile(kbd, argv[2]); else if (argc > 1 && arg == "-pp") return pipeProfile(kbd);