summaryrefslogtreecommitdiffstats
path: root/src/input_common/input_engine.cpp
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-12-20 20:23:31 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-01-20 01:05:20 +0100
commited5fa10e9729cf55205533f62a428e646aa5ed7c (patch)
treefe1fa3882df8a26845f937dbb0a51beb7ac7acc3 /src/input_common/input_engine.cpp
parentcore: hid: Migrate ring from emulated devices to emulated controller (diff)
downloadyuzu-ed5fa10e9729cf55205533f62a428e646aa5ed7c.tar
yuzu-ed5fa10e9729cf55205533f62a428e646aa5ed7c.tar.gz
yuzu-ed5fa10e9729cf55205533f62a428e646aa5ed7c.tar.bz2
yuzu-ed5fa10e9729cf55205533f62a428e646aa5ed7c.tar.lz
yuzu-ed5fa10e9729cf55205533f62a428e646aa5ed7c.tar.xz
yuzu-ed5fa10e9729cf55205533f62a428e646aa5ed7c.tar.zst
yuzu-ed5fa10e9729cf55205533f62a428e646aa5ed7c.zip
Diffstat (limited to 'src/input_common/input_engine.cpp')
-rw-r--r--src/input_common/input_engine.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/input_common/input_engine.cpp b/src/input_common/input_engine.cpp
index 61cfd0911..91aa96aa7 100644
--- a/src/input_common/input_engine.cpp
+++ b/src/input_common/input_engine.cpp
@@ -79,6 +79,17 @@ void InputEngine::SetBattery(const PadIdentifier& identifier, Common::Input::Bat
TriggerOnBatteryChange(identifier, value);
}
+void InputEngine::SetColor(const PadIdentifier& identifier, Common::Input::BodyColorStatus value) {
+ {
+ std::scoped_lock lock{mutex};
+ ControllerData& controller = controller_list.at(identifier);
+ if (!configuring) {
+ controller.color = value;
+ }
+ }
+ TriggerOnColorChange(identifier, value);
+}
+
void InputEngine::SetMotion(const PadIdentifier& identifier, int motion, const BasicMotion& value) {
{
std::scoped_lock lock{mutex};
@@ -176,6 +187,18 @@ Common::Input::BatteryLevel InputEngine::GetBattery(const PadIdentifier& identif
return controller.battery;
}
+Common::Input::BodyColorStatus InputEngine::GetColor(const PadIdentifier& identifier) const {
+ std::scoped_lock lock{mutex};
+ const auto controller_iter = controller_list.find(identifier);
+ if (controller_iter == controller_list.cend()) {
+ LOG_ERROR(Input, "Invalid identifier guid={}, pad={}, port={}", identifier.guid.RawString(),
+ identifier.pad, identifier.port);
+ return {};
+ }
+ const ControllerData& controller = controller_iter->second;
+ return controller.color;
+}
+
BasicMotion InputEngine::GetMotion(const PadIdentifier& identifier, int motion) const {
std::scoped_lock lock{mutex};
const auto controller_iter = controller_list.find(identifier);
@@ -328,6 +351,20 @@ void InputEngine::TriggerOnBatteryChange(const PadIdentifier& identifier,
}
}
+void InputEngine::TriggerOnColorChange(const PadIdentifier& identifier,
+ [[maybe_unused]] Common::Input::BodyColorStatus value) {
+ std::scoped_lock lock{mutex_callback};
+ for (const auto& poller_pair : callback_list) {
+ const InputIdentifier& poller = poller_pair.second;
+ if (!IsInputIdentifierEqual(poller, identifier, EngineInputType::Color, 0)) {
+ continue;
+ }
+ if (poller.callback.on_change) {
+ poller.callback.on_change();
+ }
+ }
+}
+
void InputEngine::TriggerOnMotionChange(const PadIdentifier& identifier, int motion,
const BasicMotion& value) {
std::scoped_lock lock{mutex_callback};