input_common: Create virtual amiibo driver
This commit is contained in:
parent
dbb9d601df
commit
e8d71712e7
6 changed files with 244 additions and 0 deletions
|
@ -102,6 +102,17 @@ void InputEngine::SetCamera(const PadIdentifier& identifier,
|
|||
TriggerOnCameraChange(identifier, value);
|
||||
}
|
||||
|
||||
void InputEngine::SetNfc(const PadIdentifier& identifier, const Common::Input::NfcStatus& value) {
|
||||
{
|
||||
std::scoped_lock lock{mutex};
|
||||
ControllerData& controller = controller_list.at(identifier);
|
||||
if (!configuring) {
|
||||
controller.nfc = value;
|
||||
}
|
||||
}
|
||||
TriggerOnNfcChange(identifier, value);
|
||||
}
|
||||
|
||||
bool InputEngine::GetButton(const PadIdentifier& identifier, int button) const {
|
||||
std::scoped_lock lock{mutex};
|
||||
const auto controller_iter = controller_list.find(identifier);
|
||||
|
@ -189,6 +200,18 @@ Common::Input::CameraStatus InputEngine::GetCamera(const PadIdentifier& identifi
|
|||
return controller.camera;
|
||||
}
|
||||
|
||||
Common::Input::NfcStatus InputEngine::GetNfc(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.nfc;
|
||||
}
|
||||
|
||||
void InputEngine::ResetButtonState() {
|
||||
for (const auto& controller : controller_list) {
|
||||
for (const auto& button : controller.second.buttons) {
|
||||
|
@ -355,6 +378,20 @@ void InputEngine::TriggerOnCameraChange(const PadIdentifier& identifier,
|
|||
}
|
||||
}
|
||||
|
||||
void InputEngine::TriggerOnNfcChange(const PadIdentifier& identifier,
|
||||
[[maybe_unused]] const Common::Input::NfcStatus& 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::Nfc, 0)) {
|
||||
continue;
|
||||
}
|
||||
if (poller.callback.on_change) {
|
||||
poller.callback.on_change();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool InputEngine::IsInputIdentifierEqual(const InputIdentifier& input_identifier,
|
||||
const PadIdentifier& identifier, EngineInputType type,
|
||||
int index) const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue