all repos — mgba @ c14e5dcb88fc7fcc9feda4af8298e89f25c912e0

mGBA Game Boy Advance Emulator

Switch: Add touch
Vicki Pfau vi@endrift.com
Sat, 15 Sep 2018 11:13:30 -0700
commit

c14e5dcb88fc7fcc9feda4af8298e89f25c912e0

parent

7bbc607a4c57ab8b64be823b2d389c850a6f0ae7

1 files changed, 14 insertions(+), 1 deletions(-)

jump to
M src/platform/switch/main.csrc/platform/switch/main.c

@@ -161,6 +161,19 @@ keys |= mInputMapKeyBits(map, AUTO_INPUT, padkeys, 0);

return keys; } +static enum GUICursorState _pollCursor(unsigned* x, unsigned* y) { + hidScanInput(); + if (hidTouchCount() < 1) { + return GUI_CURSOR_NOT_PRESENT; + } + touchPosition touch; + hidTouchRead(&touch, 0); + *x = touch.px; + *y = touch.py; + return GUI_CURSOR_DOWN; +} + + static void _setup(struct mGUIRunner* runner) { _mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_A, GBA_KEY_A); _mapKey(&runner->core->inputMap, AUTO_INPUT, KEY_B, GBA_KEY_B);

@@ -377,7 +390,7 @@ .params = {

width, height, font, "/", _drawStart, _drawEnd, - _pollInput, NULL, + _pollInput, _pollCursor, NULL, NULL, NULL, },