core: hid: Allow to reconnect all players on button input
This commit is contained in:
@@ -631,14 +631,11 @@ void EmulatedController::SetButton(const Common::Input::CallbackStatus& callback
|
|||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
|
|
||||||
|
// Reconnect controller if input is detected
|
||||||
if (!is_connected) {
|
if (!is_connected) {
|
||||||
if (npad_id_type == NpadIdType::Player1 && npad_type != NpadStyleIndex::Handheld) {
|
TryReconnectController(index);
|
||||||
Connect();
|
|
||||||
}
|
|
||||||
if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) {
|
|
||||||
Connect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerOnChange(ControllerTriggerType::Button, true);
|
TriggerOnChange(ControllerTriggerType::Button, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -990,6 +987,33 @@ bool EmulatedController::IsControllerSupported(bool use_temporary_value) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void EmulatedController::TryReconnectController(std::size_t button_index) {
|
||||||
|
if (button_index >= button_params.size()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto engine = button_params[button_index].Get("engine", "");
|
||||||
|
bool reconnect_controller = false;
|
||||||
|
|
||||||
|
// TAS is not allowed to turn on controllers
|
||||||
|
if (engine == "tas") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Only connect the controller if button config is custom
|
||||||
|
if (engine != "keyboard") {
|
||||||
|
reconnect_controller = true;
|
||||||
|
}
|
||||||
|
if (npad_id_type == NpadIdType::Player1 && npad_type != NpadStyleIndex::Handheld) {
|
||||||
|
reconnect_controller = true;
|
||||||
|
}
|
||||||
|
if (npad_id_type == NpadIdType::Handheld && npad_type == NpadStyleIndex::Handheld) {
|
||||||
|
reconnect_controller = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reconnect_controller) {
|
||||||
|
Connect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EmulatedController::Connect(bool use_temporary_value) {
|
void EmulatedController::Connect(bool use_temporary_value) {
|
||||||
if (!IsControllerSupported(use_temporary_value)) {
|
if (!IsControllerSupported(use_temporary_value)) {
|
||||||
|
|||||||
@@ -166,6 +166,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void SetSupportedNpadStyleTag(NpadStyleTag supported_styles);
|
void SetSupportedNpadStyleTag(NpadStyleTag supported_styles);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tries to turn on the controller if a button is pressed
|
||||||
|
* @param button_index index to verify if controller should be connected
|
||||||
|
*/
|
||||||
|
void TryReconnectController(std::size_t button_index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the connected status to true
|
* Sets the connected status to true
|
||||||
* @param use_temporary_value If true tmp_npad_type will be used
|
* @param use_temporary_value If true tmp_npad_type will be used
|
||||||
|
|||||||
Reference in New Issue
Block a user