From 4f24343f32ed253efb2cedba03d20c620841dca1 Mon Sep 17 00:00:00 2001 From: NeatNit Date: Mon, 1 Oct 2018 22:42:49 +0300 Subject: implemented touch in Qt and SDL change TouchToPixelPos to return std::pair static_cast (SDL) various minor style and code improvements style - PascalCase for function names made touch events private const pointer arg in touch events make TouchToPixelPos a const member function did I do this right? braces on barely-multiline if remove question comment (confirmed in Discord) fixed consts remove unused parameter from TouchEndEvent DRY - High-DPI scaled touch put in separate function also fixes a bug where if you start touching (with either mouse or touchscreen) and drag the mouse to the LEFT of the emulator window, the touch point jumps to the RIGHT side of the touchscreen; draggin to above the window would make it jump to the bottom. implicit conversion from QPoint to QPointF, apparently I have no idea what const even means but I'll put it here anyway remove unused or used-once variables make touch scaling functions const, and put their implementations together removed unused FingerID parameters QTouchEvent forward declaration; add comment to TouchBegin that was lost in an edit better DRY in SDL To do -> TODO(NeatNit) remove unused include --- src/yuzu_cmd/emu_window/emu_window_sdl2.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/yuzu_cmd/emu_window/emu_window_sdl2.h') diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index d34902109..b0d4116cc 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h @@ -40,6 +40,18 @@ private: /// Called by PollEvents when a mouse button is pressed or released void OnMouseButton(u32 button, u8 state, s32 x, s32 y); + /// Translates pixel position (0..1) to pixel positions + std::pair TouchToPixelPos(float touch_x, float touch_y) const; + + /// Called by PollEvents when a finger starts touching the touchscreen + void OnFingerDown(float x, float y); + + /// Called by PollEvents when a finger moves while touching the touchscreen + void OnFingerMotion(float x, float y); + + /// Called by PollEvents when a finger stops touching the touchscreen + void OnFingerUp(); + /// Called by PollEvents when any event that may cause the window to be resized occurs void OnResize(); -- cgit v1.2.3