From 8395b14de836e9655b6435a6a28c182b9578412d Mon Sep 17 00:00:00 2001 From: zoeyjodon Date: Mon, 27 May 2024 11:49:20 -0400 Subject: [PATCH] Add scroll bars to the virtual mouse --- 3ds/gfx/touchpad.png | Bin 1246 -> 1749 bytes src/input/n3ds/MouseTouchHandler.cpp | 21 ++++++++++++++++++--- src/input/n3ds/N3dsTouchscreenInput.hpp | 2 ++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/3ds/gfx/touchpad.png b/3ds/gfx/touchpad.png index d14770aadbc0c2e67070a61a17d0fc1dc2e55c80..f8482ae2466af9e93b6b26b117fb61671a316b50 100644 GIT binary patch literal 1749 zcmeHI`BRfe7~U`W5&}#hs7NV-Nk?gIL97TBXh;IcQ3wSo0wR}k$PofXIn^W<4IZEt znkY4pvB;st07g+U5K+bs$YsNA4y76yNI*eC31UC&blQKw-?}qgoWX!aeq#_fPwbRD~T08H+#bm*tM-}?c8P4V-heU}@pk$0z$Qa?K0-*@WK=Usbt@gv^Yjs+MSWiqB- zt+#1Y`vylyhiw=7lZ2hmk)~6dN;gL<6{6Y@Ygo3bh@+)<`%5>E_ehWemDRSp~F*&r%~RMv87LNp?2ah8M!lK)Vq$)%lbj zjlE}hi?&R!Ls(*=>DF}{3w7yw$7Y%m_1Pim`SL7QJ)tLR-&7_G9e%yE-C#{G?x{q3 zQ+;59I|KR4#BqTz|M+bGxDN%h);;zlIr2-fU{rGk+aSwI=5S`mE}5s+eAdV|G%uFjTXDkUo7rKy88*J5DzQsH>rZ~6x>UL(X1ajw z+CMe4!*3B?#N>oL7szY4|uP> z&<<6uky?>p?F~iY6`;V8;@$kwiI^F09I4Ajy;LzNTIBX~ugQ0;8f|#!@}#*q$!Tvt zJRE9rset&*K=aa#)qBW9i!RXnA_M~Nojj0hldrDWBNCP{FwC=QSxBN$6TI*G(G#^C;`S(Y=-4kc*~039(`R?r`0S@iM0Xw)AP56DE7eoGP>o zp^z%_DG+Rutl8ASBtvldR%ba~uxx}-sr8#O_FE&A#o<_{*fppE4p&l(8dm_^n)00 z^7Z2UvOd2cq|NfhhyZ7%#`LuXd<^j{NBoL3T)}-%VZ}_6p(ZAf4F#9WM2SXoLmk%WNPG8lmmxr z(s_AHyrrvJXH%BVGVR-do6GaIN;JsO)OD}HS(eC3BA`9_pqi>uJhpwr*m)4pQ>13y z$swVj!*qMos5jk2xB%JLCJ$6Oc!wj=QQioi#baH7#cQXOX$f% z_rb~aeNBzW@z|gxwqvfWNr4a&@ zs?&?3gL+aC4wbZ3CRTv8pWrUu`-O+cHV|mSgnjtPITnWxH!piwl<$6YCtn22 zyW2Uu0LEa|$_BBpI?wv%**-P9w1*4@Y@mSb!azAdh<3kBP8CHLE%Z*RK)9xP9;ej+6{o1vXmcdNz&L*2WbNAnw71#XnC z*1PjYasdZZbM&?c%k&*x1a9TsZTR|Z$1m>*$=zQV_N3<6-(a@=excP>?LeZUnT5g8 zNqZx{h*jKQbcf6N^uGN+m$ENCI-hYCOQYfTjKgmj;;OQYS)C5sZcPqjI3L@fDe&Xn z9knyLmrgR8tYrM2;WyilYrzl3?{BWS`SJl7{ST&u`TkP+qWWlib-(?$ne%wfc6`eX zUiaU0mhrO}EES#cED4#xw@M8f9v-xVzAkK_t@WEtYVH2Bzw2!eo^h 285) { + v_scroll = true; + } else if (touch.py < 35) { + h_scroll = true; + } } else if (touch.px > 160) { mouse_button = BUTTON_RIGHT; LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); @@ -53,15 +58,25 @@ void MouseTouchHandler::_handle_touch_up(touchPosition touch) { mouse_button = -1; previous_x = -1; previous_y = -1; + v_scroll = false; + h_scroll = false; } void MouseTouchHandler::_handle_touch_hold(touchPosition touch) { if (previous_x == -1) { return; } - short deltaX = N3DS_MOUSEPAD_SENSITIVITY * (touch.px - previous_x); - short deltaY = N3DS_MOUSEPAD_SENSITIVITY * (touch.py - previous_y); + short deltaX = touch.px - previous_x; + short deltaY = touch.py - previous_y; previous_x = touch.px; previous_y = touch.py; - LiSendMouseMoveEvent(deltaX, deltaY); + + if (v_scroll) { + LiSendScrollEvent(-1 * deltaY); + } else if (h_scroll) { + LiSendHScrollEvent(deltaX); + } else { + LiSendMouseMoveEvent(N3DS_MOUSEPAD_SENSITIVITY * deltaX, + N3DS_MOUSEPAD_SENSITIVITY * deltaY); + } } diff --git a/src/input/n3ds/N3dsTouchscreenInput.hpp b/src/input/n3ds/N3dsTouchscreenInput.hpp index 35fe77a9..dd298170 100644 --- a/src/input/n3ds/N3dsTouchscreenInput.hpp +++ b/src/input/n3ds/N3dsTouchscreenInput.hpp @@ -79,6 +79,8 @@ class MouseTouchHandler : public TouchHandlerBase { int mouse_button = -1; int previous_x = 0; int previous_y = 0; + bool v_scroll = false; + bool h_scroll = false; }; enum KeyState { KEY_DISABLED, KEY_TEMPORARY, KEY_LOCKED, KEY_SHIFT };