summaryrefslogtreecommitdiff
path: root/src/core/hid/emulated_controller.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
-rw-r--r--src/core/hid/emulated_controller.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 94bd656fe..2af3f06fc 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -542,6 +542,7 @@ void EmulatedController::UnloadInput() {
542} 542}
543 543
544void EmulatedController::EnableConfiguration() { 544void EmulatedController::EnableConfiguration() {
545 std::scoped_lock lock{connect_mutex, npad_mutex};
545 is_configuring = true; 546 is_configuring = true;
546 tmp_is_connected = is_connected; 547 tmp_is_connected = is_connected;
547 tmp_npad_type = npad_type; 548 tmp_npad_type = npad_type;
@@ -1556,7 +1557,7 @@ void EmulatedController::Connect(bool use_temporary_value) {
1556 1557
1557 auto trigger_guard = 1558 auto trigger_guard =
1558 SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Connected, !is_configuring); }); 1559 SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Connected, !is_configuring); });
1559 std::scoped_lock lock{mutex}; 1560 std::scoped_lock lock{connect_mutex, mutex};
1560 if (is_configuring) { 1561 if (is_configuring) {
1561 tmp_is_connected = true; 1562 tmp_is_connected = true;
1562 return; 1563 return;
@@ -1572,7 +1573,7 @@ void EmulatedController::Connect(bool use_temporary_value) {
1572void EmulatedController::Disconnect() { 1573void EmulatedController::Disconnect() {
1573 auto trigger_guard = 1574 auto trigger_guard =
1574 SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Disconnected, !is_configuring); }); 1575 SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Disconnected, !is_configuring); });
1575 std::scoped_lock lock{mutex}; 1576 std::scoped_lock lock{connect_mutex, mutex};
1576 if (is_configuring) { 1577 if (is_configuring) {
1577 tmp_is_connected = false; 1578 tmp_is_connected = false;
1578 return; 1579 return;
@@ -1586,7 +1587,7 @@ void EmulatedController::Disconnect() {
1586} 1587}
1587 1588
1588bool EmulatedController::IsConnected(bool get_temporary_value) const { 1589bool EmulatedController::IsConnected(bool get_temporary_value) const {
1589 std::scoped_lock lock{mutex}; 1590 std::scoped_lock lock{connect_mutex};
1590 if (get_temporary_value && is_configuring) { 1591 if (get_temporary_value && is_configuring) {
1591 return tmp_is_connected; 1592 return tmp_is_connected;
1592 } 1593 }
@@ -1599,7 +1600,7 @@ NpadIdType EmulatedController::GetNpadIdType() const {
1599} 1600}
1600 1601
1601NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) const { 1602NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) const {
1602 std::scoped_lock lock{mutex}; 1603 std::scoped_lock lock{npad_mutex};
1603 if (get_temporary_value && is_configuring) { 1604 if (get_temporary_value && is_configuring) {
1604 return tmp_npad_type; 1605 return tmp_npad_type;
1605 } 1606 }
@@ -1609,7 +1610,7 @@ NpadStyleIndex EmulatedController::GetNpadStyleIndex(bool get_temporary_value) c
1609void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) { 1610void EmulatedController::SetNpadStyleIndex(NpadStyleIndex npad_type_) {
1610 auto trigger_guard = 1611 auto trigger_guard =
1611 SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Type, !is_configuring); }); 1612 SCOPE_GUARD({ TriggerOnChange(ControllerTriggerType::Type, !is_configuring); });
1612 std::scoped_lock lock{mutex}; 1613 std::scoped_lock lock{mutex, npad_mutex};
1613 1614
1614 if (is_configuring) { 1615 if (is_configuring) {
1615 if (tmp_npad_type == npad_type_) { 1616 if (tmp_npad_type == npad_type_) {