diff --git a/ControllerUSB/include/Controllers/Dualshock4Controller.h b/ControllerUSB/include/Controllers/Dualshock4Controller.h index 791787b..693f23e 100644 --- a/ControllerUSB/include/Controllers/Dualshock4Controller.h +++ b/ControllerUSB/include/Controllers/Dualshock4Controller.h @@ -168,6 +168,6 @@ public: Result SendInitBytes(); Result SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude); - static void LoadConfig(const ControllerConfig *config); + static void LoadConfig(const ControllerConfig *config, RGBAColor ledValue); virtual ControllerConfig *GetConfig() override; }; \ No newline at end of file diff --git a/ControllerUSB/source/Controllers/Dualshock4Controller.cpp b/ControllerUSB/source/Controllers/Dualshock4Controller.cpp index 75592e1..a333236 100644 --- a/ControllerUSB/source/Controllers/Dualshock4Controller.cpp +++ b/ControllerUSB/source/Controllers/Dualshock4Controller.cpp @@ -2,6 +2,7 @@ #include static ControllerConfig _dualshock4ControllerConfig{}; +static RGBAColor _ledValue{0x00, 0x00, 0x40}; Dualshock4Controller::Dualshock4Controller(std::unique_ptr &&interface) : IController(std::move(interface)) @@ -15,10 +16,10 @@ Dualshock4Controller::~Dualshock4Controller() Result Dualshock4Controller::SendInitBytes() { - constexpr uint8_t init_bytes[32] = { + const uint8_t init_bytes[32] = { 0x05, 0x07, 0x00, 0x00, - 0x00, 0x00, //initial strong and weak rumble - 0x00, 0x00, 0x40, //LED color + 0x00, 0x00, //initial strong and weak rumble + _ledValue.r, _ledValue.g, _ledValue.b, //LED color 0x00, 0x00}; return m_outPipe->Write(init_bytes, sizeof(init_bytes)); @@ -227,9 +228,10 @@ Result Dualshock4Controller::SetRumble(uint8_t strong_magnitude, uint8_t weak_ma return 9; } -void Dualshock4Controller::LoadConfig(const ControllerConfig *config) +void Dualshock4Controller::LoadConfig(const ControllerConfig *config, RGBAColor ledValue) { _dualshock4ControllerConfig = *config; + _ledValue = ledValue; } ControllerConfig *Dualshock4Controller::GetConfig() diff --git a/config/sys-con/config_dualshock4.ini b/config/sys-con/config_dualshock4.ini index aa7d521..58d68b8 100644 --- a/config/sys-con/config_dualshock4.ini +++ b/config/sys-con/config_dualshock4.ini @@ -3,6 +3,8 @@ left_stick_deadzone = 10 ; from 0 to 100 right_stick_deadzone = 10 ; from 0 to 100 trigger_deadzone = 0 ; from 0 to 100 +color_led = 0,0,64 ; from 0 to 255 + color_body = 77,77,77 color_buttons = 0,0,0 diff --git a/source/configFile.cpp b/source/configFile.cpp index 47e5542..ad0cf3f 100644 --- a/source/configFile.cpp +++ b/source/configFile.cpp @@ -73,6 +73,7 @@ static RGBAColor _DecodeColorValue(const char *value) static ControllerConfig temp_config; static GlobalConfig global_config; +static RGBAColor temp_color; static char firmwarePath[100]; static int _ParseConfigLine(void *dummy, const char *section, const char *name, const char *value) @@ -152,6 +153,11 @@ static int _ParseConfigLine(void *dummy, const char *section, const char *name, temp_config.rightGripColor = _DecodeColorValue(value); return 1; } + else if (strcmp(name + 6, "led") == 0) + { + temp_color = _DecodeColorValue(value); + return 1; + } } } @@ -208,7 +214,7 @@ void LoadAllConfigs() WriteToLog("Failed to read from dualshock 3 config!"); if (R_SUCCEEDED(_ReadFromConfig(CONFIG_PATH DUALSHOCK4CONFIG))) - Dualshock4Controller::LoadConfig(&temp_config); + Dualshock4Controller::LoadConfig(&temp_config, temp_color); else WriteToLog("Failed to read from dualshock 4 config!"); }