mirror of
https://github.com/cathery/sys-con.git
synced 2025-01-26 18:35:20 +00:00
Allow changing DS4 LED (#88)
This commit is contained in:
parent
60776a8cce
commit
d1ccd23813
@ -168,6 +168,6 @@ public:
|
|||||||
Result SendInitBytes();
|
Result SendInitBytes();
|
||||||
Result SetRumble(uint8_t strong_magnitude, uint8_t weak_magnitude);
|
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;
|
virtual ControllerConfig *GetConfig() override;
|
||||||
};
|
};
|
@ -2,6 +2,7 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
static ControllerConfig _dualshock4ControllerConfig{};
|
static ControllerConfig _dualshock4ControllerConfig{};
|
||||||
|
static RGBAColor _ledValue{0x00, 0x00, 0x40};
|
||||||
|
|
||||||
Dualshock4Controller::Dualshock4Controller(std::unique_ptr<IUSBDevice> &&interface)
|
Dualshock4Controller::Dualshock4Controller(std::unique_ptr<IUSBDevice> &&interface)
|
||||||
: IController(std::move(interface))
|
: IController(std::move(interface))
|
||||||
@ -15,10 +16,10 @@ Dualshock4Controller::~Dualshock4Controller()
|
|||||||
|
|
||||||
Result Dualshock4Controller::SendInitBytes()
|
Result Dualshock4Controller::SendInitBytes()
|
||||||
{
|
{
|
||||||
constexpr uint8_t init_bytes[32] = {
|
const uint8_t init_bytes[32] = {
|
||||||
0x05, 0x07, 0x00, 0x00,
|
0x05, 0x07, 0x00, 0x00,
|
||||||
0x00, 0x00, //initial strong and weak rumble
|
0x00, 0x00, //initial strong and weak rumble
|
||||||
0x00, 0x00, 0x40, //LED color
|
_ledValue.r, _ledValue.g, _ledValue.b, //LED color
|
||||||
0x00, 0x00};
|
0x00, 0x00};
|
||||||
|
|
||||||
return m_outPipe->Write(init_bytes, sizeof(init_bytes));
|
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;
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dualshock4Controller::LoadConfig(const ControllerConfig *config)
|
void Dualshock4Controller::LoadConfig(const ControllerConfig *config, RGBAColor ledValue)
|
||||||
{
|
{
|
||||||
_dualshock4ControllerConfig = *config;
|
_dualshock4ControllerConfig = *config;
|
||||||
|
_ledValue = ledValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerConfig *Dualshock4Controller::GetConfig()
|
ControllerConfig *Dualshock4Controller::GetConfig()
|
||||||
|
@ -3,6 +3,8 @@ left_stick_deadzone = 10 ; from 0 to 100
|
|||||||
right_stick_deadzone = 10 ; from 0 to 100
|
right_stick_deadzone = 10 ; from 0 to 100
|
||||||
trigger_deadzone = 0 ; 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_body = 77,77,77
|
||||||
color_buttons = 0,0,0
|
color_buttons = 0,0,0
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@ static RGBAColor _DecodeColorValue(const char *value)
|
|||||||
|
|
||||||
static ControllerConfig temp_config;
|
static ControllerConfig temp_config;
|
||||||
static GlobalConfig global_config;
|
static GlobalConfig global_config;
|
||||||
|
static RGBAColor temp_color;
|
||||||
static char firmwarePath[100];
|
static char firmwarePath[100];
|
||||||
|
|
||||||
static int _ParseConfigLine(void *dummy, const char *section, const char *name, const char *value)
|
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);
|
temp_config.rightGripColor = _DecodeColorValue(value);
|
||||||
return 1;
|
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!");
|
WriteToLog("Failed to read from dualshock 3 config!");
|
||||||
|
|
||||||
if (R_SUCCEEDED(_ReadFromConfig(CONFIG_PATH DUALSHOCK4CONFIG)))
|
if (R_SUCCEEDED(_ReadFromConfig(CONFIG_PATH DUALSHOCK4CONFIG)))
|
||||||
Dualshock4Controller::LoadConfig(&temp_config);
|
Dualshock4Controller::LoadConfig(&temp_config, temp_color);
|
||||||
else
|
else
|
||||||
WriteToLog("Failed to read from dualshock 4 config!");
|
WriteToLog("Failed to read from dualshock 4 config!");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user