summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/virtual_amiibo.cpp15
-rw-r--r--src/input_common/drivers/virtual_amiibo.h3
-rw-r--r--src/input_common/helpers/touch_from_buttons.cpp9
-rw-r--r--src/input_common/input_engine.h2
-rw-r--r--src/input_common/input_poller.cpp18
5 files changed, 29 insertions, 18 deletions
diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp
index 0cd5129da..564a188e5 100644
--- a/src/input_common/drivers/virtual_amiibo.cpp
+++ b/src/input_common/drivers/virtual_amiibo.cpp
@@ -60,6 +60,8 @@ Common::Input::NfcState VirtualAmiibo::WriteNfcData(
return Common::Input::NfcState::WriteFailed;
}
+ amiibo_data = data;
+
return Common::Input::NfcState::Success;
}
@@ -91,6 +93,15 @@ VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(const std::string& filename) {
return Info::Success;
}
+VirtualAmiibo::Info VirtualAmiibo::ReloadAmiibo() {
+ if (state == State::AmiiboIsOpen) {
+ SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, amiibo_data});
+ return Info::Success;
+ }
+
+ return LoadAmiibo(file_path);
+}
+
VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() {
state = polling_mode == Common::Input::PollingMode::NFC ? State::WaitingForAmiibo
: State::Initialized;
@@ -98,4 +109,8 @@ VirtualAmiibo::Info VirtualAmiibo::CloseAmiibo() {
return Info::Success;
}
+std::string VirtualAmiibo::GetLastFilePath() const {
+ return file_path;
+}
+
} // namespace InputCommon
diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h
index 9eac07544..9baeb3997 100644
--- a/src/input_common/drivers/virtual_amiibo.h
+++ b/src/input_common/drivers/virtual_amiibo.h
@@ -47,8 +47,11 @@ public:
State GetCurrentState() const;
Info LoadAmiibo(const std::string& amiibo_file);
+ Info ReloadAmiibo();
Info CloseAmiibo();
+ std::string GetLastFilePath() const;
+
private:
static constexpr std::size_t amiibo_size = 0x21C;
static constexpr std::size_t amiibo_size_without_password = amiibo_size - 0x8;
diff --git a/src/input_common/helpers/touch_from_buttons.cpp b/src/input_common/helpers/touch_from_buttons.cpp
index da4a3dca5..003a38da5 100644
--- a/src/input_common/helpers/touch_from_buttons.cpp
+++ b/src/input_common/helpers/touch_from_buttons.cpp
@@ -10,8 +10,8 @@ namespace InputCommon {
class TouchFromButtonDevice final : public Common::Input::InputDevice {
public:
using Button = std::unique_ptr<Common::Input::InputDevice>;
- TouchFromButtonDevice(Button button_, int touch_id_, float x_, float y_)
- : button(std::move(button_)), touch_id(touch_id_), x(x_), y(y_) {
+ TouchFromButtonDevice(Button button_, float x_, float y_)
+ : button(std::move(button_)), x(x_), y(y_) {
last_button_value = false;
button->SetCallback({
.on_change =
@@ -34,7 +34,6 @@ public:
.pressed = button_status,
.x = {},
.y = {},
- .id = touch_id,
};
status.x.properties = properties;
status.y.properties = properties;
@@ -62,7 +61,6 @@ public:
private:
Button button;
bool last_button_value;
- const int touch_id;
const float x;
const float y;
const Common::Input::AnalogProperties properties{0.0f, 1.0f, 0.5f, 0.0f, false};
@@ -73,10 +71,9 @@ std::unique_ptr<Common::Input::InputDevice> TouchFromButton::Create(
const std::string null_engine = Common::ParamPackage{{"engine", "null"}}.Serialize();
auto button = Common::Input::CreateDeviceFromString<Common::Input::InputDevice>(
params.Get("button", null_engine));
- const auto touch_id = params.Get("touch_id", 0);
const float x = params.Get("x", 0.0f) / 1280.0f;
const float y = params.Get("y", 0.0f) / 720.0f;
- return std::make_unique<TouchFromButtonDevice>(std::move(button), touch_id, x, y);
+ return std::make_unique<TouchFromButtonDevice>(std::move(button), x, y);
}
} // namespace InputCommon
diff --git a/src/input_common/input_engine.h b/src/input_common/input_engine.h
index d4c264a8e..6cbcf5207 100644
--- a/src/input_common/input_engine.h
+++ b/src/input_common/input_engine.h
@@ -133,7 +133,7 @@ public:
return Common::Input::CameraError::NotSupported;
}
- // Request nfc data from a controller
+ // Returns success if nfc is supported
virtual Common::Input::NfcState SupportsNfc(
[[maybe_unused]] const PadIdentifier& identifier) const {
return Common::Input::NfcState::NotSupported;
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index 4ac182147..fb8be42e2 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -229,13 +229,12 @@ private:
class InputFromTouch final : public Common::Input::InputDevice {
public:
- explicit InputFromTouch(PadIdentifier identifier_, int touch_id_, int button_, bool toggle_,
- bool inverted_, int axis_x_, int axis_y_,
- Common::Input::AnalogProperties properties_x_,
+ explicit InputFromTouch(PadIdentifier identifier_, int button_, bool toggle_, bool inverted_,
+ int axis_x_, int axis_y_, Common::Input::AnalogProperties properties_x_,
Common::Input::AnalogProperties properties_y_,
InputEngine* input_engine_)
- : identifier(identifier_), touch_id(touch_id_), button(button_), toggle(toggle_),
- inverted(inverted_), axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_),
+ : identifier(identifier_), button(button_), toggle(toggle_), inverted(inverted_),
+ axis_x(axis_x_), axis_y(axis_y_), properties_x(properties_x_),
properties_y(properties_y_), input_engine(input_engine_) {
UpdateCallback engine_callback{[this]() { OnChange(); }};
const InputIdentifier button_input_identifier{
@@ -271,8 +270,7 @@ public:
}
Common::Input::TouchStatus GetStatus() const {
- Common::Input::TouchStatus status;
- status.id = touch_id;
+ Common::Input::TouchStatus status{};
status.pressed = {
.value = input_engine->GetButton(identifier, button),
.inverted = inverted,
@@ -307,7 +305,6 @@ public:
private:
const PadIdentifier identifier;
- const int touch_id;
const int button;
const bool toggle;
const bool inverted;
@@ -919,7 +916,6 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTriggerDevice(
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
const Common::ParamPackage& params) {
- const auto touch_id = params.Get("touch_id", 0);
const auto deadzone = std::clamp(params.Get("deadzone", 0.0f), 0.0f, 1.0f);
const auto range = std::clamp(params.Get("range", 1.0f), 0.25f, 1.50f);
const auto threshold = std::clamp(params.Get("threshold", 0.5f), 0.0f, 1.0f);
@@ -954,8 +950,8 @@ std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateTouchDevice(
input_engine->PreSetAxis(identifier, axis_x);
input_engine->PreSetAxis(identifier, axis_y);
input_engine->PreSetButton(identifier, button);
- return std::make_unique<InputFromTouch>(identifier, touch_id, button, toggle, inverted, axis_x,
- axis_y, properties_x, properties_y, input_engine.get());
+ return std::make_unique<InputFromTouch>(identifier, button, toggle, inverted, axis_x, axis_y,
+ properties_x, properties_y, input_engine.get());
}
std::unique_ptr<Common::Input::InputDevice> InputFactory::CreateBatteryDevice(