summaryrefslogtreecommitdiffstats
path: root/src/input_common/input_poller.cpp
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-10-25 06:23:54 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2021-11-25 03:30:26 +0100
commit064ddacf49aa7155e26add55983b81fdda997077 (patch)
tree17f6d767233c10578d84d2029014a3dfa4b55396 /src/input_common/input_poller.cpp
parentinput_common: Add manual update options to input devices (diff)
downloadyuzu-064ddacf49aa7155e26add55983b81fdda997077.tar
yuzu-064ddacf49aa7155e26add55983b81fdda997077.tar.gz
yuzu-064ddacf49aa7155e26add55983b81fdda997077.tar.bz2
yuzu-064ddacf49aa7155e26add55983b81fdda997077.tar.lz
yuzu-064ddacf49aa7155e26add55983b81fdda997077.tar.xz
yuzu-064ddacf49aa7155e26add55983b81fdda997077.tar.zst
yuzu-064ddacf49aa7155e26add55983b81fdda997077.zip
Diffstat (limited to 'src/input_common/input_poller.cpp')
-rw-r--r--src/input_common/input_poller.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/input_common/input_poller.cpp b/src/input_common/input_poller.cpp
index 024bd28ef..6edb8d900 100644
--- a/src/input_common/input_poller.cpp
+++ b/src/input_common/input_poller.cpp
@@ -183,6 +183,17 @@ public:
return status;
}
+ void ForceUpdate() {
+ const Input::CallbackStatus status{
+ .type = Input::InputType::Stick,
+ .stick_status = GetStatus(),
+ };
+
+ last_axis_x_value = status.stick_status.x.raw_value;
+ last_axis_y_value = status.stick_status.y.raw_value;
+ TriggerOnChange(status);
+ }
+
void OnChange() {
const Input::CallbackStatus status{
.type = Input::InputType::Stick,
@@ -448,6 +459,16 @@ public:
return static_cast<Input::BatteryLevel>(input_engine->GetBattery(identifier));
}
+ void ForceUpdate() {
+ const Input::CallbackStatus status{
+ .type = Input::InputType::Battery,
+ .battery_status = GetStatus(),
+ };
+
+ last_battery_value = status.battery_status;
+ TriggerOnChange(status);
+ }
+
void OnChange() {
const Input::CallbackStatus status{
.type = Input::InputType::Battery,
@@ -579,6 +600,18 @@ public:
return status;
}
+ void ForceUpdate() {
+ const Input::CallbackStatus status{
+ .type = Input::InputType::Motion,
+ .motion_status = GetStatus(),
+ };
+
+ last_axis_x_value = status.motion_status.gyro.x.raw_value;
+ last_axis_y_value = status.motion_status.gyro.y.raw_value;
+ last_axis_z_value = status.motion_status.gyro.z.raw_value;
+ TriggerOnChange(status);
+ }
+
void OnChange() {
const Input::CallbackStatus status{
.type = Input::InputType::Motion,
@@ -868,6 +901,9 @@ InputFactory::InputFactory(std::shared_ptr<InputEngine> input_engine_)
: input_engine(std::move(input_engine_)) {}
std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPackage& params) {
+ if (params.Has("battery")) {
+ return CreateBatteryDevice(params);
+ }
if (params.Has("button") && params.Has("axis")) {
return CreateTriggerDevice(params);
}
@@ -892,9 +928,6 @@ std::unique_ptr<Input::InputDevice> InputFactory::Create(const Common::ParamPack
if (params.Has("axis")) {
return CreateAnalogDevice(params);
}
- if (params.Has("battery")) {
- return CreateBatteryDevice(params);
- }
LOG_ERROR(Input, "Invalid parameters given");
return std::make_unique<DummyInput>();
}