From 85872d7e715e49c4995fb66cf045c227a0fed965 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 14 May 2024 20:58:51 +0200 Subject: [PATCH 1/2] port: add mouse controls to virtual keyboard --- src/game/menuitem.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/game/menuitem.c b/src/game/menuitem.c index 117d92bd4..6f585b75b 100644 --- a/src/game/menuitem.c +++ b/src/game/menuitem.c @@ -1366,6 +1366,34 @@ bool menuitemKeyboardTick(struct menuitem *item, struct menuinputs *inputs, u32 s16 prevcol = kb->col; s16 prevrow = kb->row; +#ifndef PLATFORM_N64 + // handle mouse + struct menudialog *dialog = g_Menus[g_MpPlayerNum].curdialog; + if (dialog && dialog->usingmouse && !inputs->leftright && !inputs->updown) { + const s32 dleft = dialog->x + 4; + const s32 dright = dleft + 12 * 10; + const s32 dtop = dialog->y + 13 + 12; + const s32 dbottom = dtop + 11 * 5; + const s32 mx = inputs->mousex; + const s32 my = inputs->mousey; + if (mx > dleft && mx < dright && my > dtop && my < dbottom) { + kb->row = (my - dtop) / 11; + kb->col = (mx - dleft) / 12; + if (kb->row == 4) { + if (kb->col < 2) { + kb->col = 0; + } else if (kb->col < 5) { + kb->col = 2; + } else if (kb->col < 8) { + kb->col = 5; + } else { + kb->col = 8; + } + } + } + } +#endif + // Handle left/right movement // In most cases the loop only runs once, but on row 4 the buttons span // across multiple columns so the loop will run again until the column From 548e2c1f0bd2e871ac4e2ade1220cbf18e090709 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Tue, 14 May 2024 21:06:16 +0200 Subject: [PATCH 2/2] port: only navigate with mouse if it's enabled in the dialog --- src/game/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/menu.c b/src/game/menu.c index 68742bf24..f660a8bbf 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -1361,8 +1361,8 @@ bool dialogChangeItemFocusWithMouse(struct menudialog *dialog, s32 mx, s32 my) s32 curx, cury; s32 colwidth = 0; - // only allow mouse control of player 1 menus - if (menu->playernum != 0) { + // only allow mouse control of player 1 menus; ignore mouse if navigating with keyboard + if (menu->playernum != 0 || !dialog->usingmouse) { return false; }