Skip to content

Commit 11c2937

Browse files
Banz99Andrea
authored andcommitted
Add the option to choose your own polling rate for DS4
1 parent 2bec6c2 commit 11c2937

4 files changed

Lines changed: 21 additions & 0 deletions

File tree

mc_mitm/default.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
[misc]
1919
; Disable the LED lightbar on Sony Dualshock 4 and Dualsense controllers [default false]
2020
;disable_sony_leds=false
21+
; Specifies an integer divisor for the full 1000hz polling rate mode (accepted value range: 0-16) [default 8, which gives a 125hz result]
22+
;dualshock_pollingrate_divisor=8
2123
; Map the dpad of the controller to the left stick and viceversa [default false]
2224
;swap_dpad_lstick=false
2325
; A series of stick axis reversal settings [default false]

mc_mitm/source/controllers/dualshock4_controller.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ namespace ams::controller {
4646
R_TRY(EmulatedSwitchController::Initialize());
4747
R_TRY(this->PushRumbleLedState());
4848

49+
mitm::ControllerProfileConfig config;
50+
mitm::GetCustomIniConfig(&this->Address(), &config);
51+
m_report_rate = (Dualshock4ReportRate)config.misc.dualshock_pollingrate_divisor;
4952
return ams::ResultSuccess();
5053
}
5154

mc_mitm/source/mcmitm_config.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace ams::mitm {
4444
},
4545
.misc = {
4646
.disable_sony_leds = false,
47+
.dualshock_pollingrate_divisor = 8,
4748
.swap_dpad_lstick = false,
4849
.invert_lstick_xaxis = false,
4950
.invert_lstick_yaxis = false,
@@ -86,6 +87,18 @@ namespace ams::mitm {
8687
*out = temp;
8788
}
8889

90+
void ParseInt(const char *value, int32_t *out) {
91+
*out = atoi(value);
92+
}
93+
94+
void ParsePollingRate(const char *value, int32_t *out){
95+
int32_t temp=8;
96+
ParseInt(value, &temp);
97+
if(temp >= 0 && temp <= 16)
98+
*out = temp;
99+
else *out = 8;
100+
}
101+
89102
void ParseDeadzone(const char *value, float *out){
90103
float temp=0.0f;
91104
ParseFloat(value, &temp);
@@ -219,6 +232,8 @@ namespace ams::mitm {
219232
else if (strcasecmp(section, "misc") == 0) {
220233
if (strcasecmp(name, "disable_sony_leds") == 0)
221234
ParseBoolean(value, &config->misc.disable_sony_leds);
235+
else if (strcasecmp(name, "dualshock_pollingrate_divisor") == 0)
236+
ParsePollingRate(value, &config->misc.dualshock_pollingrate_divisor);
222237
else if (strcasecmp(name, "swap_dpad_lstick") == 0)
223238
ParseBoolean(value, &config->misc.swap_dpad_lstick);
224239
else if (strcasecmp(name, "invert_lstick_xaxis") == 0)

mc_mitm/source/mcmitm_config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ namespace ams::mitm {
4444

4545
struct {
4646
bool disable_sony_leds;
47+
int32_t dualshock_pollingrate_divisor;
4748
bool swap_dpad_lstick;
4849
bool invert_lstick_xaxis;
4950
bool invert_lstick_yaxis;

0 commit comments

Comments
 (0)