mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-24 10:23:01 -06:00
commit
6fe89acf0d
2 changed files with 23 additions and 51 deletions
|
@ -583,36 +583,6 @@ bool Controller_NPad::SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Controller_NPad::IsControllerSupported(NPadControllerType controller) {
|
|
||||||
if (controller == NPadControllerType::Handheld) {
|
|
||||||
// Handheld is not even a supported type, lets stop here
|
|
||||||
if (std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(),
|
|
||||||
NPAD_HANDHELD) == supported_npad_id_types.end()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Handheld should not be supported in docked mode
|
|
||||||
if (Settings::values.use_docked_mode) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch (controller) {
|
|
||||||
case NPadControllerType::ProController:
|
|
||||||
return style.pro_controller;
|
|
||||||
case NPadControllerType::Handheld:
|
|
||||||
return style.handheld;
|
|
||||||
case NPadControllerType::JoyDual:
|
|
||||||
return style.joycon_dual;
|
|
||||||
case NPadControllerType::JoyLeft:
|
|
||||||
return style.joycon_left;
|
|
||||||
case NPadControllerType::JoyRight:
|
|
||||||
return style.joycon_right;
|
|
||||||
case NPadControllerType::Pokeball:
|
|
||||||
return style.pokeball;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Controller_NPad::LedPattern Controller_NPad::GetLedPattern(u32 npad_id) {
|
Controller_NPad::LedPattern Controller_NPad::GetLedPattern(u32 npad_id) {
|
||||||
if (npad_id == npad_id_list.back() || npad_id == npad_id_list[npad_id_list.size() - 2]) {
|
if (npad_id == npad_id_list.back() || npad_id == npad_id_list[npad_id_list.size() - 2]) {
|
||||||
// These are controllers without led patterns
|
// These are controllers without led patterns
|
||||||
|
@ -659,25 +629,24 @@ void Controller_NPad::ClearAllConnectedControllers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::DisconnectAllConnectedControllers() {
|
void Controller_NPad::DisconnectAllConnectedControllers() {
|
||||||
std::for_each(connected_controllers.begin(), connected_controllers.end(),
|
for (ControllerHolder& controller : connected_controllers) {
|
||||||
[](ControllerHolder& controller) { controller.is_connected = false; });
|
controller.is_connected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::ConnectAllDisconnectedControllers() {
|
void Controller_NPad::ConnectAllDisconnectedControllers() {
|
||||||
std::for_each(connected_controllers.begin(), connected_controllers.end(),
|
for (ControllerHolder& controller : connected_controllers) {
|
||||||
[](ControllerHolder& controller) {
|
if (controller.type != NPadControllerType::None && !controller.is_connected) {
|
||||||
if (controller.type != NPadControllerType::None && !controller.is_connected) {
|
controller.is_connected = true;
|
||||||
controller.is_connected = false;
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller_NPad::ClearAllControllers() {
|
void Controller_NPad::ClearAllControllers() {
|
||||||
std::for_each(connected_controllers.begin(), connected_controllers.end(),
|
for (ControllerHolder& controller : connected_controllers) {
|
||||||
[](ControllerHolder& controller) {
|
controller.type = NPadControllerType::None;
|
||||||
controller.type = NPadControllerType::None;
|
controller.is_connected = false;
|
||||||
controller.is_connected = false;
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Controller_NPad::GetAndResetPressState() {
|
u32 Controller_NPad::GetAndResetPressState() {
|
||||||
|
@ -685,10 +654,10 @@ u32 Controller_NPad::GetAndResetPressState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const {
|
bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const {
|
||||||
const bool support_handheld =
|
|
||||||
std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), NPAD_HANDHELD) !=
|
|
||||||
supported_npad_id_types.end();
|
|
||||||
if (controller == NPadControllerType::Handheld) {
|
if (controller == NPadControllerType::Handheld) {
|
||||||
|
const bool support_handheld =
|
||||||
|
std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(),
|
||||||
|
NPAD_HANDHELD) != supported_npad_id_types.end();
|
||||||
// Handheld is not even a supported type, lets stop here
|
// Handheld is not even a supported type, lets stop here
|
||||||
if (!support_handheld) {
|
if (!support_handheld) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -700,6 +669,7 @@ bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::any_of(supported_npad_id_types.begin(), supported_npad_id_types.end(),
|
if (std::any_of(supported_npad_id_types.begin(), supported_npad_id_types.end(),
|
||||||
[](u32 npad_id) { return npad_id <= MAX_NPAD_ID; })) {
|
[](u32 npad_id) { return npad_id <= MAX_NPAD_ID; })) {
|
||||||
switch (controller) {
|
switch (controller) {
|
||||||
|
@ -717,6 +687,7 @@ bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -795,6 +766,7 @@ Controller_NPad::NPadControllerType Controller_NPad::DecideBestController(
|
||||||
priority_list.push_back(NPadControllerType::JoyLeft);
|
priority_list.push_back(NPadControllerType::JoyLeft);
|
||||||
priority_list.push_back(NPadControllerType::JoyRight);
|
priority_list.push_back(NPadControllerType::JoyRight);
|
||||||
priority_list.push_back(NPadControllerType::JoyDual);
|
priority_list.push_back(NPadControllerType::JoyDual);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto iter = std::find_if(priority_list.begin(), priority_list.end(),
|
const auto iter = std::find_if(priority_list.begin(), priority_list.end(),
|
||||||
|
|
|
@ -301,6 +301,11 @@ private:
|
||||||
bool is_connected;
|
bool is_connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void InitNewlyAddedControler(std::size_t controller_idx);
|
||||||
|
bool IsControllerSupported(NPadControllerType controller) const;
|
||||||
|
NPadControllerType DecideBestController(NPadControllerType priority) const;
|
||||||
|
void RequestPadStateUpdate(u32 npad_id);
|
||||||
|
|
||||||
u32 press_state{};
|
u32 press_state{};
|
||||||
|
|
||||||
NPadType style{};
|
NPadType style{};
|
||||||
|
@ -321,12 +326,7 @@ private:
|
||||||
std::array<ControllerHolder, 10> connected_controllers{};
|
std::array<ControllerHolder, 10> connected_controllers{};
|
||||||
bool can_controllers_vibrate{true};
|
bool can_controllers_vibrate{true};
|
||||||
|
|
||||||
void InitNewlyAddedControler(std::size_t controller_idx);
|
|
||||||
bool IsControllerSupported(NPadControllerType controller) const;
|
|
||||||
NPadControllerType DecideBestController(NPadControllerType priority) const;
|
|
||||||
void RequestPadStateUpdate(u32 npad_id);
|
|
||||||
std::array<ControllerPad, 10> npad_pad_states{};
|
std::array<ControllerPad, 10> npad_pad_states{};
|
||||||
bool IsControllerSupported(NPadControllerType controller);
|
|
||||||
bool is_in_lr_assignment_mode{false};
|
bool is_in_lr_assignment_mode{false};
|
||||||
Core::System& system;
|
Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue