From 93e2d87390657011b93e0ceb68063d408d06d423 Mon Sep 17 00:00:00 2001 From: dandistine <34634876+dandistine@users.noreply.github.com> Date: Sat, 3 Oct 2026 10:50:24 -0500 Subject: [PATCH] Add a GetTouch function --- dev/src/core.cpp | 4 ++++ dev/src/core.h | 1 + examples/olcPGE3_Touch.cpp | 2 +- olcPixelGameEngine3.h | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dev/src/core.cpp b/dev/src/core.cpp index 19da9c9..b170c9e 100644 --- a/dev/src/core.cpp +++ b/dev/src/core.cpp @@ -338,6 +338,10 @@ namespace olc return keyboard; } + olc::hw::Touch& PGEWindow::GetTouch() { + return touch; + } + const olc::vi2d& PGEWindow::ScreenSize() { return GetScreen().Size(); diff --git a/dev/src/core.h b/dev/src/core.h index 231a0d4..46db13b 100644 --- a/dev/src/core.h +++ b/dev/src/core.h @@ -121,6 +121,7 @@ namespace olc // Input devices are handled by a regular olc::Window, but for convenience... olc::hw::Mouse& GetMouse(); olc::hw::Keyboard& GetKeyboard(); + olc::hw::Touch& GetTouch(); // Returns the current size of the "screen" in pixels const olc::vi2d& ScreenSize(); diff --git a/examples/olcPGE3_Touch.cpp b/examples/olcPGE3_Touch.cpp index c611e66..e465431 100644 --- a/examples/olcPGE3_Touch.cpp +++ b/examples/olcPGE3_Touch.cpp @@ -39,7 +39,7 @@ class Example_Touch : public olc::PixelGameEngine // All "touches" get given a unique ID and are tracked by the OS. This ID // could be anything, so we never really want to work with t directly. - auto touches = touch.GetTouchIDs(); + auto touches = GetTouch().GetTouchIDs(); // Display total number of touches draw.String({ 2.0f, 2.0f }, "Touch Points: " + std::to_string(touches.size()), olc::Colour::WHITE); diff --git a/olcPixelGameEngine3.h b/olcPixelGameEngine3.h index 3725ed0..02c2b8c 100644 --- a/olcPixelGameEngine3.h +++ b/olcPixelGameEngine3.h @@ -4401,6 +4401,7 @@ namespace olc // Input devices are handled by a regular olc::Window, but for convenience... olc::hw::Mouse& GetMouse(); olc::hw::Keyboard& GetKeyboard(); + olc::hw::Touch& GetTouch(); // Returns the current size of the "screen" in pixels const olc::vi2d& ScreenSize(); @@ -20194,6 +20195,10 @@ namespace olc return keyboard; } + olc::hw::Touch& PGEWindow::GetTouch() { + return touch; + } + const olc::vi2d& PGEWindow::ScreenSize() { return GetScreen().Size();