diff options
| author | 2022-12-17 17:16:13 -0800 | |
|---|---|---|
| committer | 2022-12-17 17:16:13 -0800 | |
| commit | 48108a8c9b28e08f86aab5c2ad41414e455f4706 (patch) | |
| tree | 2dc3ff390a17ebdee32958eac619632cef424fe4 /src/input_common/drivers/virtual_gamepad.h | |
| parent | Merge pull request #7450 from FernandoS27/ndc-vulkan (diff) | |
| parent | input_common: Add virtual gamepad (diff) | |
| download | yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar.gz yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.tar.xz yuzu-48108a8c9b28e08f86aab5c2ad41414e455f4706.zip | |
Merge pull request #9456 from german77/virtual_gamepad
input_common: Add virtual gamepad
Diffstat (limited to '')
| -rw-r--r-- | src/input_common/drivers/virtual_gamepad.h | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/input_common/drivers/virtual_gamepad.h b/src/input_common/drivers/virtual_gamepad.h new file mode 100644 index 000000000..3df91cc6f --- /dev/null +++ b/src/input_common/drivers/virtual_gamepad.h | |||
| @@ -0,0 +1,73 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "input_common/input_engine.h" | ||
| 7 | |||
| 8 | namespace InputCommon { | ||
| 9 | |||
| 10 | /** | ||
| 11 | * A virtual controller that is always assigned to the game input | ||
| 12 | */ | ||
| 13 | class VirtualGamepad final : public InputEngine { | ||
| 14 | public: | ||
| 15 | enum class VirtualButton { | ||
| 16 | ButtonA, | ||
| 17 | ButtonB, | ||
| 18 | ButtonX, | ||
| 19 | ButtonY, | ||
| 20 | StickL, | ||
| 21 | StickR, | ||
| 22 | TriggerL, | ||
| 23 | TriggerR, | ||
| 24 | TriggerZL, | ||
| 25 | TriggerZR, | ||
| 26 | ButtonPlus, | ||
| 27 | ButtonMinus, | ||
| 28 | ButtonLeft, | ||
| 29 | ButtonUp, | ||
| 30 | ButtonRight, | ||
| 31 | ButtonDown, | ||
| 32 | ButtonSL, | ||
| 33 | ButtonSR, | ||
| 34 | ButtonHome, | ||
| 35 | ButtonCapture, | ||
| 36 | }; | ||
| 37 | |||
| 38 | enum class VirtualStick { | ||
| 39 | Left = 0, | ||
| 40 | Right = 1, | ||
| 41 | }; | ||
| 42 | |||
| 43 | explicit VirtualGamepad(std::string input_engine_); | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Sets the status of all buttons bound with the key to pressed | ||
| 47 | * @param player_index the player number that will take this action | ||
| 48 | * @param button_id the id of the button | ||
| 49 | * @param value indicates if the button is pressed or not | ||
| 50 | */ | ||
| 51 | void SetButtonState(std::size_t player_index, int button_id, bool value); | ||
| 52 | void SetButtonState(std::size_t player_index, VirtualButton button_id, bool value); | ||
| 53 | |||
| 54 | /** | ||
| 55 | * Sets the status of all buttons bound with the key to released | ||
| 56 | * @param player_index the player number that will take this action | ||
| 57 | * @param axis_id the id of the axis to move | ||
| 58 | * @param x_value the position of the stick in the x axis | ||
| 59 | * @param y_value the position of the stick in the y axis | ||
| 60 | */ | ||
| 61 | void SetStickPosition(std::size_t player_index, int axis_id, float x_value, float y_value); | ||
| 62 | void SetStickPosition(std::size_t player_index, VirtualStick axis_id, float x_value, | ||
| 63 | float y_value); | ||
| 64 | |||
| 65 | /// Restores all inputs into the neutral position | ||
| 66 | void ResetControllers(); | ||
| 67 | |||
| 68 | private: | ||
| 69 | /// Returns the correct identifier corresponding to the player index | ||
| 70 | PadIdentifier GetIdentifier(std::size_t player_index) const; | ||
| 71 | }; | ||
| 72 | |||
| 73 | } // namespace InputCommon | ||