summaryrefslogtreecommitdiff
path: root/src/core/hid
diff options
context:
space:
mode:
authorGravatar german772021-10-21 13:56:52 -0500
committerGravatar Narr the Reg2021-11-24 20:30:25 -0600
commitb5e72de753ae4de5c5fae7087abb00dc4242451d (patch)
treeac1f2b56814bbaaa1a5432c4e1d79c12dd16296d /src/core/hid
parentservice/hid: Use ring buffer for gestures (diff)
downloadyuzu-b5e72de753ae4de5c5fae7087abb00dc4242451d.tar.gz
yuzu-b5e72de753ae4de5c5fae7087abb00dc4242451d.tar.xz
yuzu-b5e72de753ae4de5c5fae7087abb00dc4242451d.zip
kraken: Address comments from review
review fixes
Diffstat (limited to 'src/core/hid')
-rw-r--r--src/core/hid/emulated_console.cpp2
-rw-r--r--src/core/hid/emulated_controller.cpp12
-rw-r--r--src/core/hid/emulated_controller.h1
-rw-r--r--src/core/hid/hid_core.cpp4
-rw-r--r--src/core/hid/hid_core.h3
5 files changed, 14 insertions, 8 deletions
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp
index e82cf5990..540fd107b 100644
--- a/src/core/hid/emulated_console.cpp
+++ b/src/core/hid/emulated_console.cpp
@@ -2,8 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included 3// Refer to the license.txt file included
4 4
5#include <fmt/format.h>
6
7#include "core/hid/emulated_console.h" 5#include "core/hid/emulated_console.h"
8#include "core/hid/input_converter.h" 6#include "core/hid/input_converter.h"
9 7
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index 1ff3022c5..d59758e99 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -2,8 +2,6 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included 3// Refer to the license.txt file included
4 4
5#include <fmt/format.h>
6
7#include "core/hid/emulated_controller.h" 5#include "core/hid/emulated_controller.h"
8#include "core/hid/input_converter.h" 6#include "core/hid/input_converter.h"
9 7
@@ -635,6 +633,9 @@ void EmulatedController::SetBattery(Input::CallbackStatus callback, std::size_t
635} 633}
636 634
637bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue vibration) { 635bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue vibration) {
636 if (device_index >= output_devices.size()) {
637 return false;
638 }
638 if (!output_devices[device_index]) { 639 if (!output_devices[device_index]) {
639 return false; 640 return false;
640 } 641 }
@@ -659,6 +660,9 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v
659} 660}
660 661
661bool EmulatedController::TestVibration(std::size_t device_index) { 662bool EmulatedController::TestVibration(std::size_t device_index) {
663 if (device_index >= output_devices.size()) {
664 return false;
665 }
662 if (!output_devices[device_index]) { 666 if (!output_devices[device_index]) {
663 return false; 667 return false;
664 } 668 }
@@ -733,7 +737,9 @@ bool EmulatedController::IsConnected(bool temporary) const {
733} 737}
734 738
735bool EmulatedController::IsVibrationEnabled() const { 739bool EmulatedController::IsVibrationEnabled() const {
736 return is_vibration_enabled; 740 const auto player_index = NpadIdTypeToIndex(npad_id_type);
741 const auto& player = Settings::values.players.GetValue()[player_index];
742 return player.vibration_enabled;
737} 743}
738 744
739NpadIdType EmulatedController::GetNpadIdType() const { 745NpadIdType EmulatedController::GetNpadIdType() const {
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index f3ee70726..50f21ccd9 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -337,7 +337,6 @@ private:
337 bool is_connected{false}; 337 bool is_connected{false};
338 bool temporary_is_connected{false}; 338 bool temporary_is_connected{false};
339 bool is_configuring{false}; 339 bool is_configuring{false};
340 bool is_vibration_enabled{true};
341 f32 motion_sensitivity{0.01f}; 340 f32 motion_sensitivity{0.01f};
342 341
343 ButtonParams button_params; 342 ButtonParams button_params;
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp
index bd17081bd..cc1b3c295 100644
--- a/src/core/hid/hid_core.cpp
+++ b/src/core/hid/hid_core.cpp
@@ -113,7 +113,7 @@ NpadStyleTag HIDCore::GetSupportedStyleTag() const {
113 113
114s8 HIDCore::GetPlayerCount() const { 114s8 HIDCore::GetPlayerCount() const {
115 s8 active_players = 0; 115 s8 active_players = 0;
116 for (std::size_t player_index = 0; player_index < 8; player_index++) { 116 for (std::size_t player_index = 0; player_index < available_controllers -2; player_index++) {
117 const auto* controller = GetEmulatedControllerByIndex(player_index); 117 const auto* controller = GetEmulatedControllerByIndex(player_index);
118 if (controller->IsConnected()) { 118 if (controller->IsConnected()) {
119 active_players++; 119 active_players++;
@@ -123,7 +123,7 @@ s8 HIDCore::GetPlayerCount() const {
123} 123}
124 124
125NpadIdType HIDCore::GetFirstNpadId() const { 125NpadIdType HIDCore::GetFirstNpadId() const {
126 for (std::size_t player_index = 0; player_index < 10; player_index++) { 126 for (std::size_t player_index = 0; player_index < available_controllers; player_index++) {
127 const auto* controller = GetEmulatedControllerByIndex(player_index); 127 const auto* controller = GetEmulatedControllerByIndex(player_index);
128 if (controller->IsConnected()) { 128 if (controller->IsConnected()) {
129 return controller->GetNpadIdType(); 129 return controller->GetNpadIdType();
diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h
index 196466a72..a4a66a3a4 100644
--- a/src/core/hid/hid_core.h
+++ b/src/core/hid/hid_core.h
@@ -47,6 +47,9 @@ public:
47 /// Removes all callbacks from input common 47 /// Removes all callbacks from input common
48 void UnloadInputDevices(); 48 void UnloadInputDevices();
49 49
50 /// Number of emulated controllers
51 const std::size_t available_controllers{10};
52
50private: 53private:
51 std::unique_ptr<EmulatedController> player_1; 54 std::unique_ptr<EmulatedController> player_1;
52 std::unique_ptr<EmulatedController> player_2; 55 std::unique_ptr<EmulatedController> player_2;