diff options
Diffstat (limited to 'source/nds/draw.c')
-rw-r--r-- | source/nds/draw.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source/nds/draw.c b/source/nds/draw.c index f373aa3..3eab510 100644 --- a/source/nds/draw.c +++ b/source/nds/draw.c @@ -883,24 +883,42 @@ u32 draw_hotkey_dialog(enum SCREEN_ID screen, u32 sy, char *clear, char *cancel) ds2_flipScreen(screen, 2); - // While there are no keys pressed, wait for keys. + // This function has been started by a key press. Wait for it to end. struct key_buf inputdata; do { mdelay(1); ds2_getrawInput(&inputdata); + } while (inputdata.key != 0); + + // While there are no keys pressed, wait for keys. + do { + mdelay(1); + ds2_getrawInput(&inputdata); } while (inputdata.key == 0); // Now, while there are keys pressed, keep a tally of keys that have // been pressed. (IGNORE TOUCH AND LID! Otherwise, closing the lid or // touching to get to the menu will do stuff the user doesn't expect. // Also ignore the direction pad because every game uses it.) - u32 TotalKeys = inputdata.key; + u32 TotalKeys = 0; do { + TotalKeys |= inputdata.key & ~(KEY_TOUCH | KEY_LID | KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT); + // If there's a touch on either button, turn it into a + // clear (A) or cancel (B) request. + if (inputdata.key & KEY_TOUCH) + { + if (inputdata.y >= 128 && inputdata.y < 128 + ICON_BUTTON.y) + { + if (inputdata.x >= 49 && inputdata.x < 49 + ICON_BUTTON.x) + return KEY_A; + else if (inputdata.x >= 136 && inputdata.x < 136 + ICON_BUTTON.x) + return KEY_B; + } + } mdelay(1); ds2_getrawInput(&inputdata); - TotalKeys |= inputdata.key & ~(KEY_TOUCH | KEY_LID | KEY_UP | KEY_DOWN | KEY_LEFT | KEY_RIGHT); - } while (inputdata.key != 0); + } while (inputdata.key != 0 || TotalKeys == 0); return TotalKeys; } |