diff options
| author | 2021-11-27 11:52:08 +0100 | |
|---|---|---|
| committer | 2021-11-27 11:52:08 +0100 | |
| commit | 564f10527745f870621c08bbb5d16badee0ed861 (patch) | |
| tree | e8ac8dee60086facf1837393882865f5df18c95e /src/input_common/drivers/touch_screen.cpp | |
| parent | Merge pull request #7431 from liushuyu/fix-linux-decoding (diff) | |
| parent | config: Remove vibration configuration (diff) | |
| download | yuzu-564f10527745f870621c08bbb5d16badee0ed861.tar.gz yuzu-564f10527745f870621c08bbb5d16badee0ed861.tar.xz yuzu-564f10527745f870621c08bbb5d16badee0ed861.zip | |
Merge pull request #7255 from german77/kraken
Project Kraken: Input rewrite
Diffstat (limited to 'src/input_common/drivers/touch_screen.cpp')
| -rw-r--r-- | src/input_common/drivers/touch_screen.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/input_common/drivers/touch_screen.cpp b/src/input_common/drivers/touch_screen.cpp new file mode 100644 index 000000000..45b3086f6 --- /dev/null +++ b/src/input_common/drivers/touch_screen.cpp | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included | ||
| 4 | |||
| 5 | #include "common/param_package.h" | ||
| 6 | #include "input_common/drivers/touch_screen.h" | ||
| 7 | |||
| 8 | namespace InputCommon { | ||
| 9 | |||
| 10 | constexpr PadIdentifier identifier = { | ||
| 11 | .guid = Common::UUID{Common::INVALID_UUID}, | ||
| 12 | .port = 0, | ||
| 13 | .pad = 0, | ||
| 14 | }; | ||
| 15 | |||
| 16 | TouchScreen::TouchScreen(const std::string& input_engine_) : InputEngine(input_engine_) { | ||
| 17 | PreSetController(identifier); | ||
| 18 | } | ||
| 19 | |||
| 20 | void TouchScreen::TouchMoved(float x, float y, std::size_t finger) { | ||
| 21 | if (finger >= 16) { | ||
| 22 | return; | ||
| 23 | } | ||
| 24 | TouchPressed(x, y, finger); | ||
| 25 | } | ||
| 26 | |||
| 27 | void TouchScreen::TouchPressed(float x, float y, std::size_t finger) { | ||
| 28 | if (finger >= 16) { | ||
| 29 | return; | ||
| 30 | } | ||
| 31 | SetButton(identifier, static_cast<int>(finger), true); | ||
| 32 | SetAxis(identifier, static_cast<int>(finger * 2), x); | ||
| 33 | SetAxis(identifier, static_cast<int>(finger * 2 + 1), y); | ||
| 34 | } | ||
| 35 | |||
| 36 | void TouchScreen::TouchReleased(std::size_t finger) { | ||
| 37 | if (finger >= 16) { | ||
| 38 | return; | ||
| 39 | } | ||
| 40 | SetButton(identifier, static_cast<int>(finger), false); | ||
| 41 | SetAxis(identifier, static_cast<int>(finger * 2), 0.0f); | ||
| 42 | SetAxis(identifier, static_cast<int>(finger * 2 + 1), 0.0f); | ||
| 43 | } | ||
| 44 | |||
| 45 | void TouchScreen::ReleaseAllTouch() { | ||
| 46 | for (int index = 0; index < 16; ++index) { | ||
| 47 | SetButton(identifier, index, false); | ||
| 48 | SetAxis(identifier, index * 2, 0.0f); | ||
| 49 | SetAxis(identifier, index * 2 + 1, 0.0f); | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | } // namespace InputCommon | ||