diff options
| author | 2021-12-18 13:57:14 +0800 | |
|---|---|---|
| committer | 2021-12-18 13:57:14 +0800 | |
| commit | e49184e6069a9d791d2df3c1958f5c4b1187e124 (patch) | |
| tree | b776caf722e0be0e680f67b0ad0842628162ef1c /src/input_common/drivers/touch_screen.cpp | |
| parent | Implement convert legacy to generic (diff) | |
| parent | Merge pull request #7570 from ameerj/favorites-expanded (diff) | |
| download | yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.gz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.xz yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.zip | |
Merge branch 'yuzu-emu:master' into convert_legacy
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..880781825 --- /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(std::string input_engine_) : InputEngine(std::move(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 | ||