Skip to content

Commit 50694a7

Browse files
committed
[app-vmu] Fix confirm window input handling
1 parent 27f3659 commit 50694a7

File tree

1 file changed

+44
-25
lines changed
  • applications/vmu_manager/modules

1 file changed

+44
-25
lines changed

applications/vmu_manager/modules/module.c

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -270,42 +270,61 @@ static void clr_statusbar() {
270270
}
271271

272272
static int Confirm_Window() {
273-
maple_device_t *cont;
274-
cont_state_t *state;
275-
int y, flag = CMD_ERROR;
273+
maple_device_t *controller_dev;
274+
maple_device_t *mouse_dev;
275+
int y, rv = CMD_ERROR;
276276

277277
SDL_GetMouseState(NULL, &y);
278278
SDL_WarpMouse(0,0);
279279
GUI_ContainerAdd(self.vmu_page, self.confirm);
280280
GUI_WidgetMarkChanged(self.vmu_page);
281-
LockVideo();
282281

283282
while(1) {
284-
if(! (cont = maple_enum_type(0, MAPLE_FUNC_MOUSE)) ) {
285-
if(!(cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER))) {
286-
continue;
283+
mouse_dev = maple_enum_type(0, MAPLE_FUNC_MOUSE);
284+
controller_dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
285+
286+
if(mouse_dev) {
287+
mouse_cond_t *state = (mouse_cond_t *)maple_dev_status(mouse_dev);
288+
289+
if(state) {
290+
if(state->buttons & MOUSE_LEFTBUTTON) {
291+
rv = CMD_OK;
292+
break;
293+
}
294+
else if(state->buttons & MOUSE_RIGHTBUTTON) {
295+
break;
296+
}
297+
else if(state->buttons & MOUSE_SIDEBUTTON) {
298+
rv = CMD_NO_ARG;
299+
break;
300+
}
287301
}
288302
}
289303

290-
if(!(state = (cont_state_t *) maple_dev_status(cont))) {
291-
continue;
292-
}
293-
294-
if(state->buttons & CONT_A) {
295-
flag = CMD_OK;
296-
break;
297-
}
298-
else if(state->buttons & CONT_B) {
299-
break;
300-
}
301-
else if(state->buttons & CONT_X) {
302-
flag = CMD_NO_ARG;
303-
break;
304+
if(controller_dev) {
305+
cont_state_t *state = (cont_state_t *)maple_dev_status(controller_dev);
306+
307+
if(state) {
308+
if(state->buttons & CONT_A) {
309+
rv = CMD_OK;
310+
break;
311+
}
312+
else if(state->buttons & CONT_B) {
313+
break;
314+
}
315+
else if(state->buttons & CONT_X) {
316+
rv = CMD_NO_ARG;
317+
break;
318+
}
319+
}
304320
}
305-
else {
306-
thd_sleep(50);
321+
322+
if(!mouse_dev && !controller_dev) {
323+
continue;
307324
}
308-
}
325+
326+
thd_sleep(50);
327+
}
309328

310329
GUI_ContainerRemove(self.vmu_page, self.confirm);
311330
GUI_WidgetMarkChanged(self.m_App->body);
@@ -314,7 +333,7 @@ static int Confirm_Window() {
314333
SDL_WarpMouse(270, y);
315334
UnlockVideo();
316335

317-
return flag;
336+
return rv;
318337
}
319338

320339
static void show_slots(int port) {

0 commit comments

Comments
 (0)