mc.mitm: implement additional dualshock3 led pattern mode

This commit is contained in:
ndeadly 2023-05-10 22:20:36 +02:00
parent badbbbd61e
commit 939c2e868d
4 changed files with 20 additions and 14 deletions

View file

@ -140,7 +140,7 @@ These settings can be used to spoof your switch bluetooth to appear as another d
- `[misc]`
These are miscellaneous controller-specific settings etc.
- `dualshock3_led_mode` Set Dualshock 3 player LED behaviour. Valid modes [0-1] where 0=Switch pattern, 1=PS3 pattern
- `dualshock3_led_mode` Set Dualshock 3 player LED behaviour. Valid modes [0-1] where 0=Switch pattern, 1=PS3 pattern, 2=Hybrid (Switch pattern reversed to line up with numeric labels on the controller)
- `dualshock4_polling_rate` Set polling rate for Sony Dualshock 4 controllers. Valid range [0-16] where 0=max, 16=min. Refer [here](https://github.com/ndeadly/MissionControl/blob/4a0326308d1ff39353b045f5efb1a99c4a504c28/mc_mitm/source/controllers/dualshock4_controller.hpp#L21) for corresponding frequency values.
- `dualshock4_lightbar_brightness` Set LED lightbar brightness for Sony Dualshock 4 controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% in 12.5% increments.
- `dualsense_lightbar_brightness` Set LED lightbar brightness for Sony Dualsense controllers. Valid range [0-9] where 0=off, 1=min, 2-9=12.5-100% in 12.5% increments.

View file

@ -11,7 +11,7 @@
;host_address=04:20:69:04:20:69
[misc]
; Set Dualshock 3 player LED behaviour. Valid modes [0-1] where 0=Switch pattern, 1=PS3 pattern [default 0]
; Set Dualshock 3 player LED behaviour. Valid modes [0-2] where 0=Switch pattern, 1=PS3 pattern, 2=Hybrid (Switch pattern reversed to line up with numeric labels on the controller) [default 0]
;dualshock3_led_mode=0
; Set polling rate for Sony Dualshock 4 controllers. Valid range [0-16] where 0=max, 16=min [default 8 (125Hz)]
; Refer to https://github.com/ndeadly/MissionControl/blob/4a0326308d1ff39353b045f5efb1a99c4a504c28/mc_mitm/source/controllers/dualshock4_controller.hpp#L21

View file

@ -29,8 +29,9 @@ namespace ams::controller {
constexpr u16 ds3_product_id = 0x0268;
enum Dualshock3LedMode {
Dualshock3LedMode_Switch,
Dualshock3LedMode_Ps3
Dualshock3LedMode_Switch = 0,
Dualshock3LedMode_Ps3 = 1,
Dualshock3LedMode_Hybrid = 2,
};
const u8 enable_payload[] = { 0xf4, 0x42, 0x03, 0x00, 0x00 };
@ -207,15 +208,20 @@ namespace ams::controller {
R_TRY(LedsMaskToPlayerNumber(led_mask, &player_index));
auto config = mitm::GetGlobalConfig();
if (config->misc.dualshock3_led_mode == Dualshock3LedMode_Ps3) {
if (player_index < 4) {
m_led_mask = 1 << player_index;
} else {
m_led_mask = ~(1 << player_index) & 0x0f;
}
} else {
m_led_mask = player_led_patterns[player_index];
}
switch(config->misc.dualshock3_led_mode) {
case Dualshock3LedMode_Switch:
m_led_mask = player_led_patterns[player_index];
break;
case Dualshock3LedMode_Ps3:
m_led_mask = player_index < 4 ? 1 << player_index : ~(1 << player_index) & 0x0f;
break;
case Dualshock3LedMode_Hybrid:
m_led_mask = led_mask;
break;
default:
break;
};
R_RETURN(this->PushRumbleLedState());
}

View file

@ -93,7 +93,7 @@ namespace ams::mitm {
}
} else if (strcasecmp(section, "misc") == 0) {
if (strcasecmp(name, "dualshock3_led_mode") == 0) {
ParseInt(value, &config->misc.dualshock3_led_mode, 0, 1);
ParseInt(value, &config->misc.dualshock3_led_mode, 0, 2);
} else if (strcasecmp(name, "dualshock4_polling_rate") == 0) {
ParseInt(value, &config->misc.dualshock4_polling_rate, 0, 16);
} else if (strcasecmp(name, "dualshock4_lightbar_brightness") == 0) {