mc.mitm: make dualsense vibration strength user configurable

This commit is contained in:
ndeadly 2022-09-14 19:37:09 +02:00
parent c5093b292c
commit abd05ef5f5
4 changed files with 16 additions and 2 deletions

View file

@ -17,3 +17,5 @@
;disable_dualsense_lightbar=false
; Disable the white player indicator LEDs at the bottom of the Dualsense touchpad [default false]
;disable_dualsense_player_leds=false
; Reduce dualsense vibration intensity by 12.5% per increment. Valid range [0-7] [default 4(50%)]
;dualsense_vibration_intensity=4

View file

@ -265,6 +265,8 @@ namespace ams::controller {
}
Result DualsenseController::PushRumbleLedState() {
auto config = mitm::GetGlobalConfig();
std::scoped_lock lk(m_output_mutex);
DualsenseReportData report = {};
@ -274,7 +276,7 @@ namespace ams::controller {
report.output0x31.data[2] = 0x54;
report.output0x31.data[3] = m_rumble_state.amp_motor_right;
report.output0x31.data[4] = m_rumble_state.amp_motor_left;
report.output0x31.data[37] = 0x03;
report.output0x31.data[37] = config->misc.dualsense_vibration_intensity;
report.output0x31.data[39] = 0x02 | 0x01;
report.output0x31.data[42] = 0x02;
report.output0x31.data[43] = 0x02;

View file

@ -32,7 +32,8 @@ namespace ams::mitm {
.misc = {
.disable_dualshock4_lightbar = false,
.disable_dualsense_lightbar = false,
.disable_dualsense_player_leds = false
.disable_dualsense_player_leds = false,
.dualsense_vibration_intensity = 4
}
};
@ -43,6 +44,12 @@ namespace ams::mitm {
*out = false;
}
void ParseInt(const char *value, int *out, int min=INT_MIN, int max=INT_MAX) {
int tmp = atoi(value);
if ((tmp >= min) && (tmp <= max))
*out = tmp;
}
void ParseBluetoothAddress(const char *value, bluetooth::Address *out) {
// Check length of address string is correct
if (std::strlen(value) != 3*sizeof(bluetooth::Address) - 1) return;
@ -85,6 +92,8 @@ namespace ams::mitm {
ParseBoolean(value, &config->misc.disable_dualsense_lightbar);
else if (strcasecmp(name, "disable_dualsense_player_leds") == 0)
ParseBoolean(value, &config->misc.disable_dualsense_player_leds);
else if (strcasecmp(name, "dualsense_vibration_intensity") == 0)
ParseInt(value, &config->misc.dualsense_vibration_intensity, 0, 7);
}
else {
return 0;

View file

@ -32,6 +32,7 @@ namespace ams::mitm {
bool disable_dualshock4_lightbar;
bool disable_dualsense_lightbar;
bool disable_dualsense_player_leds;
int dualsense_vibration_intensity;
} misc;
};