Qt/Input: keep LED colors when setting vibration and merge pad functions

This commit is contained in:
Megamouse 2019-05-26 09:43:04 +02:00
parent 5760aa2e57
commit fb1d8cb548
11 changed files with 43 additions and 58 deletions

View file

@ -222,7 +222,7 @@ void ds4_pad_handler::GetNextButtonPress(const std::string& padId, const std::fu
return callback(0, "", padId, preview_values);
}
void ds4_pad_handler::TestVibration(const std::string& padId, u32 largeMotor, u32 smallMotor)
void ds4_pad_handler::SetPadData(const std::string& padId, u32 largeMotor, u32 smallMotor, s32 r, s32 g, s32 b)
{
std::shared_ptr<DS4Device> device = GetDevice(padId);
if (device == nullptr || device->hidDevice == nullptr)
@ -247,41 +247,15 @@ void ds4_pad_handler::TestVibration(const std::string& padId, u32 largeMotor, u3
}
}
// Start/Stop the engines :)
SendVibrateData(device);
}
void ds4_pad_handler::SetLED(const std::string& padId, s32 r, s32 g, s32 b)
{
std::shared_ptr<DS4Device> device = GetDevice(padId);
if (device == nullptr || device->hidDevice == nullptr)
return;
int index = 0;
for (int i = 0; i < MAX_GAMEPADS; i++)
// Set new LED color
if (r >= 0 && g >= 0 && b >= 0 && r <= 255 && g <= 255 && b <= 255)
{
if (g_cfg_input.player[i]->handler == pad_handler::ds4)
{
if (g_cfg_input.player[i]->device.to_string() == padId)
{
m_pad_configs[index].load();
device->config = &m_pad_configs[index];
break;
}
index++;
}
device->config->colorR.set(r);
device->config->colorG.set(g);
device->config->colorB.set(b);
}
// disable pulse
device->led_delay_on = 0;
device->led_delay_off = 0;
// set new color
device->config->colorR.set(r);
device->config->colorG.set(g);
device->config->colorB.set(b);
// Show new color :)
// Start/Stop the engines :)
SendVibrateData(device);
}