Skip to content

Commit d835ee2

Browse files
committed
Replace the option to disable Sony controllers LEDs with a specific setting for brightness level
1 parent 4a256d3 commit d835ee2

File tree

5 files changed

+38
-26
lines changed

5 files changed

+38
-26
lines changed

mc_mitm/default.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
[misc]
1919
; Remaps the controller buttons to behave similarly to how they do on western consoles (i.e A to confirm on Xbox controllers, X on Playstation ones)
2020
;use_western_layout=false
21-
; Disable the LED lightbar on Sony Dualshock 4 and Dualsense controllers [default false]
22-
;disable_sony_leds=false
21+
; Specify the LED lightbar brightness on Sony controllers (range 0(off)-63(max)) [default 8]
22+
;sony_led_brightness=8
2323
; Map the dpad of the controller to the left stick and viceversa [default false]
2424
;swap_dpad_lstick=false
2525
; A series of stick axis reversal settings [default false]

mc_mitm/source/controllers/dualsense_controller.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ namespace ams::controller {
3939

4040
const RGBColour player_led_colours[] = {
4141
// Same colours used by PS4
42-
{0x00, 0x00, 0x40}, // blue
43-
{0x40, 0x00, 0x00}, // red
44-
{0x00, 0x40, 0x00}, // green
45-
{0x20, 0x00, 0x20}, // pink
42+
{0x00, 0x00, 0x04}, // blue
43+
{0x04, 0x00, 0x00}, // red
44+
{0x00, 0x04, 0x00}, // green
45+
{0x02, 0x00, 0x02}, // pink
4646
// New colours for controllers 5-8
47-
{0x00, 0x20, 0x20}, // cyan
48-
{0x30, 0x10, 0x00}, // orange
49-
{0x20, 0x20, 0x00}, // yellow
50-
{0x10, 0x00, 0x30} // purple
47+
{0x00, 0x02, 0x02}, // cyan
48+
{0x03, 0x01, 0x00}, // orange
49+
{0x02, 0x02, 0x00}, // yellow
50+
{0x01, 0x00, 0x03} // purple
5151
};
5252

5353
}
@@ -82,7 +82,9 @@ namespace ams::controller {
8282
Result DualsenseController::SetLightbarColour(RGBColour colour) {
8383
mitm::ControllerProfileConfig config;
8484
mitm::GetCustomIniConfig(&this->Address(), &config);
85-
m_led_colour = config.misc.disable_sony_leds ? led_disable : colour;
85+
m_led_colour.r = colour.r * config.misc.sony_led_brightness;
86+
m_led_colour.g = colour.g * config.misc.sony_led_brightness;
87+
m_led_colour.b = colour.b * config.misc.sony_led_brightness;
8688
return this->PushRumbleLedState();
8789
}
8890

mc_mitm/source/controllers/dualshock4_controller.cpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ namespace ams::controller {
2929

3030
const RGBColour player_led_colours[] = {
3131
// Same colours used by PS4
32-
{0x00, 0x00, 0x40}, // blue
33-
{0x40, 0x00, 0x00}, // red
34-
{0x00, 0x40, 0x00}, // green
35-
{0x20, 0x00, 0x20}, // pink
32+
{0x00, 0x00, 0x04}, // blue
33+
{0x04, 0x00, 0x00}, // red
34+
{0x00, 0x04, 0x00}, // green
35+
{0x02, 0x00, 0x02}, // pink
3636
// New colours for controllers 5-8
37-
{0x00, 0x20, 0x20}, // cyan
38-
{0x30, 0x10, 0x00}, // orange
39-
{0x20, 0x20, 0x00}, // yellow
40-
{0x10, 0x00, 0x30} // purple
37+
{0x00, 0x02, 0x02}, // cyan
38+
{0x03, 0x01, 0x00}, // orange
39+
{0x02, 0x02, 0x00}, // yellow
40+
{0x01, 0x00, 0x03} // purple
4141
};
4242

4343
}
@@ -74,7 +74,9 @@ namespace ams::controller {
7474
Result Dualshock4Controller::SetLightbarColour(RGBColour colour) {
7575
mitm::ControllerProfileConfig config;
7676
mitm::GetCustomIniConfig(&this->Address(), &config);
77-
m_led_colour = config.misc.disable_sony_leds ? led_disable : colour;
77+
m_led_colour.r = colour.r * config.misc.sony_led_brightness;
78+
m_led_colour.g = colour.g * config.misc.sony_led_brightness;
79+
m_led_colour.b = colour.b * config.misc.sony_led_brightness;
7880
return this->PushRumbleLedState();
7981
}
8082

mc_mitm/source/mcmitm_config.cpp

+13-5
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ namespace ams::mitm {
4343
.right_grip = {0x46, 0x46, 0x46}
4444
},
4545
.misc = {
46-
.use_western_layout=false,
47-
.disable_sony_leds = false,
46+
.use_western_layout = false,
47+
.sony_led_brightness = 8,
4848
.dualshock_pollingrate_divisor = 8,
4949
.swap_dpad_lstick = false,
5050
.invert_lstick_xaxis = false,
@@ -96,7 +96,15 @@ namespace ams::mitm {
9696
int32_t temp=8;
9797
ParseInt(value, &temp);
9898
if(temp >= 0 && temp <= 16)
99-
*out = temp;
99+
*out = temp;
100+
else *out = 8;
101+
}
102+
103+
void ParseBrightness(const char *value, int32_t *out){
104+
int32_t temp=8;
105+
ParseInt(value, &temp);
106+
if(temp >= 0 && temp <= 63)
107+
*out = temp;
100108
else *out = 8;
101109
}
102110

@@ -233,8 +241,8 @@ namespace ams::mitm {
233241
else if (strcasecmp(section, "misc") == 0) {
234242
if (strcasecmp(name, "use_western_layout") == 0)
235243
ParseBoolean(value, &config->misc.use_western_layout);
236-
else if (strcasecmp(name, "disable_sony_leds") == 0)
237-
ParseBoolean(value, &config->misc.disable_sony_leds);
244+
else if (strcasecmp(name, "sony_led_brightness") == 0)
245+
ParseBrightness(value, &config->misc.sony_led_brightness);
238246
else if (strcasecmp(name, "dualshock_pollingrate_divisor") == 0)
239247
ParsePollingRate(value, &config->misc.dualshock_pollingrate_divisor);
240248
else if (strcasecmp(name, "swap_dpad_lstick") == 0)

mc_mitm/source/mcmitm_config.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace ams::mitm {
4444

4545
struct {
4646
bool use_western_layout;
47-
bool disable_sony_leds;
47+
int32_t sony_led_brightness;
4848
int32_t dualshock_pollingrate_divisor;
4949
bool swap_dpad_lstick;
5050
bool invert_lstick_xaxis;

0 commit comments

Comments
 (0)