diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2024-01-18 05:01:33 +0100 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2024-01-18 05:47:56 +0100 |
commit | 72f803c366f5406bc0098821f237c6185d1ed034 (patch) | |
tree | eb24af3dfdcb580a3236cd5f95cfdeb8eaa38252 /src/input_common/drivers/android.cpp | |
parent | Merge pull request #12689 from liamwhite/remove-format (diff) | |
download | yuzu-72f803c366f5406bc0098821f237c6185d1ed034.tar yuzu-72f803c366f5406bc0098821f237c6185d1ed034.tar.gz yuzu-72f803c366f5406bc0098821f237c6185d1ed034.tar.bz2 yuzu-72f803c366f5406bc0098821f237c6185d1ed034.tar.lz yuzu-72f803c366f5406bc0098821f237c6185d1ed034.tar.xz yuzu-72f803c366f5406bc0098821f237c6185d1ed034.tar.zst yuzu-72f803c366f5406bc0098821f237c6185d1ed034.zip |
Diffstat (limited to 'src/input_common/drivers/android.cpp')
-rw-r--r-- | src/input_common/drivers/android.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/input_common/drivers/android.cpp b/src/input_common/drivers/android.cpp new file mode 100644 index 000000000..b6a03fdc0 --- /dev/null +++ b/src/input_common/drivers/android.cpp @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "input_common/drivers/android.h" + +namespace InputCommon { + +Android::Android(std::string input_engine_) : InputEngine(std::move(input_engine_)) {} + +void Android::RegisterController(std::size_t controller_number) { + PreSetController(GetIdentifier(controller_number)); +} + +void Android::SetButtonState(std::size_t controller_number, int button_id, bool value) { + const auto identifier = GetIdentifier(controller_number); + SetButton(identifier, button_id, value); +} + +void Android::SetAxisState(std::size_t controller_number, int axis_id, float value) { + const auto identifier = GetIdentifier(controller_number); + SetAxis(identifier, axis_id, value); +} + +void Android::SetMotionState(std::size_t controller_number, u64 delta_timestamp, float gyro_x, + float gyro_y, float gyro_z, float accel_x, float accel_y, + float accel_z) { + const auto identifier = GetIdentifier(controller_number); + const BasicMotion motion_data{ + .gyro_x = gyro_x, + .gyro_y = gyro_y, + .gyro_z = gyro_z, + .accel_x = accel_x, + .accel_y = accel_y, + .accel_z = accel_z, + .delta_timestamp = delta_timestamp, + }; + SetMotion(identifier, 0, motion_data); +} + +PadIdentifier Android::GetIdentifier(std::size_t controller_number) const { + return { + .guid = Common::UUID{}, + .port = controller_number, + .pad = 0, + }; +} + +} // namespace InputCommon |