From dbacce0c569d90e91bb153c9a035b03742e0692f Mon Sep 17 00:00:00 2001 From: offtkp Date: Mon, 23 Oct 2023 14:02:07 +0300 Subject: [PATCH] Add hydra touch support --- src/hydra_core.cpp | 15 ++++++++++++++- third_party/hydra_core | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/hydra_core.cpp b/src/hydra_core.cpp index 383718f72..c9afa09cf 100644 --- a/src/hydra_core.cpp +++ b/src/hydra_core.cpp @@ -1,7 +1,6 @@ #include #include #include - #include class HC_GLOBAL HydraCore final : public hydra::IBase, public hydra::IOpenGlRendered, public hydra::IFrontendDriven, public hydra::IInput { @@ -72,6 +71,20 @@ void HydraCore::runFrame() { int y = !!checkButtonCallback(0, hydra::ButtonType::Analog1Up) - !!checkButtonCallback(0, hydra::ButtonType::Analog1Down); hid.setCirclepadX(x * 0x9C); hid.setCirclepadY(y * 0x9C); + + u32 touch = checkButtonCallback(0, hydra::ButtonType::Touch); + if (touch != hydra::TOUCH_RELEASED) { + u16 x = touch >> 16; + u16 y = touch; + if (y >= 240 && y <= 480 && x >= 40 && x < 40 + 320) { + hid.setTouchScreenPress(x - 40, y - 240); + } else { + hid.releaseTouchScreen(); + } + } else { + hid.releaseTouchScreen(); + } + hid.updateInputs(emulator->getTicks()); emulator->runFrame(); diff --git a/third_party/hydra_core b/third_party/hydra_core index 5b7b38be0..e4cc6b0fc 160000 --- a/third_party/hydra_core +++ b/third_party/hydra_core @@ -1 +1 @@ -Subproject commit 5b7b38be0507ae2f4cc7026b3897f3db0b1bbc7e +Subproject commit e4cc6b0fc224583e509bc3472a4c11eafb69c041