summaryrefslogtreecommitdiffstats
path: root/src/hid_core/resources/touch_screen/touch_screen.h
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-01 17:33:44 +0100
committerGitHub <noreply@github.com>2024-02-01 17:33:44 +0100
commit21138b6a867632c56330a48a7389430ae2b6e321 (patch)
tree6be048ee977f29f4c132d0cfb0bcdb79a7c5966d /src/hid_core/resources/touch_screen/touch_screen.h
parentMerge pull request #12870 from liamwhite/mac-ci (diff)
parentservice: hid: Restore active aruid (diff)
downloadyuzu-21138b6a867632c56330a48a7389430ae2b6e321.tar
yuzu-21138b6a867632c56330a48a7389430ae2b6e321.tar.gz
yuzu-21138b6a867632c56330a48a7389430ae2b6e321.tar.bz2
yuzu-21138b6a867632c56330a48a7389430ae2b6e321.tar.lz
yuzu-21138b6a867632c56330a48a7389430ae2b6e321.tar.xz
yuzu-21138b6a867632c56330a48a7389430ae2b6e321.tar.zst
yuzu-21138b6a867632c56330a48a7389430ae2b6e321.zip
Diffstat (limited to 'src/hid_core/resources/touch_screen/touch_screen.h')
-rw-r--r--src/hid_core/resources/touch_screen/touch_screen.h71
1 files changed, 46 insertions, 25 deletions
diff --git a/src/hid_core/resources/touch_screen/touch_screen.h b/src/hid_core/resources/touch_screen/touch_screen.h
index 4b3824742..2fcb6247f 100644
--- a/src/hid_core/resources/touch_screen/touch_screen.h
+++ b/src/hid_core/resources/touch_screen/touch_screen.h
@@ -1,43 +1,64 @@
-// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
-#include <array>
+#include <mutex>
-#include "hid_core/hid_types.h"
-#include "hid_core/resources/controller_base.h"
-#include "hid_core/resources/touch_screen/touch_types.h"
+#include "common/common_types.h"
+#include "core/hle/result.h"
namespace Core::HID {
-class EmulatedConsole;
-} // namespace Core::HID
+struct TouchScreenConfigurationForNx;
+}
+
+namespace Core::Timing {
+struct EventType;
+}
namespace Service::HID {
-struct TouchScreenSharedMemoryFormat;
+class TouchResource;
+struct AutoPilotState;
-class TouchScreen final : public ControllerBase {
+/// Handles touch request from HID interfaces
+class TouchScreen {
public:
- explicit TouchScreen(Core::HID::HIDCore& hid_core_);
- ~TouchScreen() override;
+ TouchScreen(std::shared_ptr<TouchResource> resource);
+ ~TouchScreen();
- // Called when the controller is initialized
- void OnInit() override;
+ Result Activate();
+ Result Activate(u64 aruid);
- // When the controller is released
- void OnRelease() override;
+ Result Deactivate();
- // When the controller is requesting an update for the shared memory
- void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
+ Result IsActive(bool& out_is_active) const;
- void SetTouchscreenDimensions(u32 width, u32 height);
+ Result SetTouchScreenAutoPilotState(const AutoPilotState& auto_pilot_state);
+ Result UnsetTouchScreenAutoPilotState();
-private:
- TouchScreenState next_state{};
- Core::HID::EmulatedConsole* console = nullptr;
+ Result RequestNextTouchInput();
+ Result RequestNextDummyInput();
+
+ Result ProcessTouchScreenAutoTune();
+
+ Result SetTouchScreenMagnification(f32 point1_x, f32 point1_y, f32 point2_x, f32 point2_y);
+ Result SetTouchScreenResolution(u32 width, u32 height, u64 aruid);
+
+ Result SetTouchScreenConfiguration(const Core::HID::TouchScreenConfigurationForNx& mode,
+ u64 aruid);
+ Result GetTouchScreenConfiguration(Core::HID::TouchScreenConfigurationForNx& out_mode,
+ u64 aruid) const;
- std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{};
- u32 touchscreen_width;
- u32 touchscreen_height;
+ Result SetTouchScreenDefaultConfiguration(const Core::HID::TouchScreenConfigurationForNx& mode);
+ Result GetTouchScreenDefaultConfiguration(
+ Core::HID::TouchScreenConfigurationForNx& out_mode) const;
+
+ void OnTouchUpdate(u64 timestamp);
+
+private:
+ mutable std::mutex mutex;
+ std::shared_ptr<TouchResource> touch_resource;
+ std::shared_ptr<Core::Timing::EventType> touch_update_event;
};
+
} // namespace Service::HID