diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2024-01-16 19:17:18 +0100 |
---|---|---|
committer | german77 <juangerman-13@hotmail.com> | 2024-01-29 01:27:25 +0100 |
commit | 575183d6dcd8da9b10ee41e47be4b7d4f8631783 (patch) | |
tree | d2898bdefae5be2fb68e7df97465422c0fae3991 /src/hid_core/resources/touch_screen/gesture_handler.h | |
parent | Merge pull request #12555 from flodavid/fix-gamemode-setting (diff) | |
download | yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar.gz yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar.bz2 yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar.lz yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar.xz yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.tar.zst yuzu-575183d6dcd8da9b10ee41e47be4b7d4f8631783.zip |
Diffstat (limited to 'src/hid_core/resources/touch_screen/gesture_handler.h')
-rw-r--r-- | src/hid_core/resources/touch_screen/gesture_handler.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/hid_core/resources/touch_screen/gesture_handler.h b/src/hid_core/resources/touch_screen/gesture_handler.h new file mode 100644 index 000000000..fda2040c9 --- /dev/null +++ b/src/hid_core/resources/touch_screen/gesture_handler.h @@ -0,0 +1,55 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#pragma once + +#include <span> + +#include "hid_core/resources/touch_screen/touch_types.h" + +namespace Service::HID { + +class GestureHandler { +public: + GestureHandler(); + ~GestureHandler(); + + void SetTouchState(std::span<TouchState> touch_state, u32 count, s64 timestamp); + + bool NeedsUpdate(); + void UpdateGestureState(GestureState& next_state, s64 timestamp); + +private: + // Initializes new gesture + void NewGesture(GestureType& type, GestureAttribute& attributes); + + // Updates existing gesture state + void UpdateExistingGesture(GestureState& next_state, GestureType& type); + + // Terminates exiting gesture + void EndGesture(GestureState& next_state, GestureType& type, GestureAttribute& attributes); + + // Set current event to a tap event + void SetTapEvent(GestureType& type, GestureAttribute& attributes); + + // Calculates and set the extra parameters related to a pan event + void UpdatePanEvent(GestureState& next_state, GestureType& type); + + // Terminates the pan event + void EndPanEvent(GestureState& next_state, GestureType& type); + + // Set current event to a swipe event + void SetSwipeEvent(GestureState& next_state, GestureType& type); + + GestureProperties gesture{}; + GestureProperties last_gesture{}; + GestureState last_gesture_state{}; + s64 last_update_timestamp{}; + s64 last_tap_timestamp{}; + f32 last_pan_time_difference{}; + f32 time_difference{}; + bool force_update{true}; + bool enable_press_and_tap{false}; +}; + +} // namespace Service::HID |