Refactor if-blocks

Group all conditions requiring a controller in a single if-block.
This commit is contained in:
Romain Vimont 2022-01-23 12:11:53 +01:00
parent 855819bbd8
commit 7e35bfe382

View file

@ -707,13 +707,14 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
bool down = event->type == SDL_MOUSEBUTTONDOWN; bool down = event->type == SDL_MOUSEBUTTONDOWN;
if (!im->forward_all_clicks) { if (!im->forward_all_clicks) {
if (controller) {
enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP; enum sc_action action = down ? SC_ACTION_DOWN : SC_ACTION_UP;
if (controller && event->button == SDL_BUTTON_X1) { if (event->button == SDL_BUTTON_X1) {
action_app_switch(controller, action); action_app_switch(controller, action);
return; return;
} }
if (controller && event->button == SDL_BUTTON_X2 && down) { if (event->button == SDL_BUTTON_X2 && down) {
if (event->clicks < 2) { if (event->clicks < 2) {
expand_notification_panel(controller); expand_notification_panel(controller);
} else { } else {
@ -721,14 +722,15 @@ sc_input_manager_process_mouse_button(struct sc_input_manager *im,
} }
return; return;
} }
if (controller && event->button == SDL_BUTTON_RIGHT) { if (event->button == SDL_BUTTON_RIGHT) {
press_back_or_turn_screen_on(controller, action); press_back_or_turn_screen_on(controller, action);
return; return;
} }
if (controller && event->button == SDL_BUTTON_MIDDLE) { if (event->button == SDL_BUTTON_MIDDLE) {
action_home(controller, action); action_home(controller, action);
return; return;
} }
}
// double-click on black borders resize to fit the device screen // double-click on black borders resize to fit the device screen
if (event->button == SDL_BUTTON_LEFT && event->clicks == 2) { if (event->button == SDL_BUTTON_LEFT && event->clicks == 2) {