From 5da92267839a3f2ec25075d09edbd457fe27266d Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Sat, 9 Sep 2017 12:19:34 +0200 Subject: [PATCH] Support touch screen input This allows for using an actual touch screen to input on touch screen. Tested on a Linux tablet. --- src/wx/main.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/wx/main.cpp b/src/wx/main.cpp index 302f5dae..3005c533 100644 --- a/src/wx/main.cpp +++ b/src/wx/main.cpp @@ -622,6 +622,31 @@ void EmuThread::ProcessEvents() } break; + case SDL_FINGERDOWN: case SDL_FINGERMOTION: + if (!running) return; + if (evt.tfinger.x >= botdst.x && evt.tfinger.x < (botdst.x+botdst.w) && + evt.tfinger.y >= botdst.y && evt.tfinger.y < (botdst.y+botdst.h)) + { + NDS::PressKey(16+6); + int mx = ((evt.tfinger.x - botdst.x) * 256) / botdst.w; + int my = ((evt.tfinger.y - botdst.y) * 192) / botdst.h; + + if (mx < 0) mx = 0; + else if (mx > 255) mx = 255; + + if (my < 0) my = 0; + else if (my > 191) my = 191; + + NDS::TouchScreen(mx, my); + } + break; + + case SDL_FINGERUP: + if (!running) return; + NDS::ReleaseKey(16+6); + NDS::ReleaseScreen(); + break; + case SDL_KEYDOWN: if (!running) return; for (int i = 0; i < 10; i++)