diff --git a/USBNova.ino b/USBNova.ino index 7b472e2..109eb92 100644 --- a/USBNova.ino +++ b/USBNova.ino @@ -46,18 +46,18 @@ void setup() { // ========== Setup Mode ========== // if (mode == SETUP) { - led::setColor(0, 0, 20); // Set LED to blue + led::setColor(preferences::getSetupColor()); // Set LED to blue while (true) { if (selector::changed()) { mode = selector::read() ? SETUP : ATTACK; if (mode == ATTACK) { - preferences::load(); // Reload the settings (in case the main script path changed) + preferences::load(); // Reload the settings (in case the main script path changed) - led::setColor(128, 0, 0); // Turn LED red - attack::start(); // Start keystroke injection attack - led::setColor(0, 0, 20); // Set LED to blue + led::setColor(preferences::getAttackColor()); // Turn LED red + attack::start(); // Start keystroke injection attack + led::setColor(preferences::getSetupColor()); // Set LED to blue mode = SETUP; } @@ -67,20 +67,20 @@ void setup() { } // ========== Setup Mode ========== // else if (mode == ATTACK) { - delay(1000); // Wait 1s to give the computer time to initialize the keyboard + delay(1000); // Wait 1s to give the computer time to initialize the keyboard - led::setColor(128, 0, 0); // Turn LED red - attack::start(); // Start keystroke injection attack - led::setColor(0, 30, 0); // Turn LED green + led::setColor(preferences::getAttackColor()); // Turn LED red + attack::start(); // Start keystroke injection attack + led::setColor(preferences::getIdleColor()); // Turn LED green while (true) { if (selector::changed()) { mode = selector::read() ? SETUP : ATTACK; if (mode == ATTACK) { - led::setColor(128, 0, 0); // Turn LED red - attack::start(); // Start keystroke injection attack - led::setColor(0, 30, 0); // Turn LED green + led::setColor(preferences::getAttackColor()); // Turn LED red + attack::start(); // Start keystroke injection attack + led::setColor(preferences::getIdleColor()); // Turn LED green } } delay(100); diff --git a/src/led/led.cpp b/src/led/led.cpp index 52d4e37..7616335 100644 --- a/src/led/led.cpp +++ b/src/led/led.cpp @@ -55,6 +55,10 @@ namespace led { } } + void setColor(int* color) { + setColor(color[0], color[1], color[2]); + } + void setColor(int r, int g, int b) { for (size_t i = 0; i(); - enable_led = config_doc["enable_led"].as(); - hid_vid = config_doc["hid_vid"].as(); - hid_pid = config_doc["hid_pid"].as(); - hid_rev = config_doc["hid_rev"].as(); - msc_vid = config_doc["msc_vid"].as(); - msc_pid = config_doc["msc_pid"].as(); - msc_rev = config_doc["msc_rev"].as(); + enable_msc = config_doc["enable_msc"].as(); + enable_led = config_doc["enable_led"].as(); + + hid_vid = config_doc["hid_vid"].as(); + hid_pid = config_doc["hid_pid"].as(); + hid_rev = config_doc["hid_rev"].as(); + + msc_vid = config_doc["msc_vid"].as(); + msc_pid = config_doc["msc_pid"].as(); + msc_rev = config_doc["msc_rev"].as(); + default_layout = config_doc["default_layout"].as(); default_delay = config_doc["default_delay"].as(); - main_script = config_doc["main_script"].as(); + + main_script = config_doc["main_script"].as(); + + JsonArray attack_color_array = config_doc["attack_color"].as(); + + for (size_t i = 0; i(); + } + + JsonArray setup_color_array = config_doc["setup_color"].as(); + + for (size_t i = 0; i(); + } + + + JsonArray idle_color_array = config_doc["idle_color"].as(); + + for (size_t i = 0; i(); + } } bool mscEnabled() { @@ -102,4 +129,16 @@ namespace preferences { std::string getMainScript() { return main_script; } + + int* getAttackColor() { + return attack_color; + } + + int* getSetupColor() { + return setup_color; + } + + int* getIdleColor() { + return idle_color; + } } \ No newline at end of file diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index ce0363c..72d8940 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -20,6 +20,10 @@ namespace preferences { std::string getDefaultLayout(); int getDefaultDelay(); - + std::string getMainScript(); + + int* getAttackColor(); + int* getSetupColor(); + int* getIdleColor(); } \ No newline at end of file