static int menu_input_mouse_frame( menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action) { bool mouse_activity = false; bool no_mouse_activity = false; uint64_t mouse_state = MENU_MOUSE_ACTION_NONE; int ret = 0; settings_t *settings = config_get_ptr(); menu_input_t *menu_input = &menu_input_state; bool mouse_enable = settings->bools.menu_mouse_enable; if (mouse_enable) ret = menu_input_mouse_post_iterate(&mouse_state, cbs, action, &mouse_activity); if ((settings->bools.menu_pointer_enable || mouse_enable)) { menu_ctx_pointer_t point; point.x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); point.y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS); point.ptr = 0; point.cbs = NULL; point.entry = NULL; point.action = 0; point.retcode = 0; if (menu_input_dialog_get_display_kb()) menu_driver_ctl(RARCH_MENU_CTL_OSK_PTR_AT_POS, &point); if (rarch_timer_is_running(&mouse_activity_timer)) rarch_timer_tick(&mouse_activity_timer); if (mouse_old_x != point.x || mouse_old_y != point.y) { if (!rarch_timer_is_running(&mouse_activity_timer)) mouse_activity = true; menu_event_set_osk_ptr(point.retcode); } else { if (rarch_timer_has_expired(&mouse_activity_timer)) no_mouse_activity = true; } mouse_old_x = point.x; mouse_old_y = point.y; } if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_BUTTON_L)) { menu_ctx_pointer_t point; point.x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); point.y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS); point.ptr = menu_input->mouse.ptr; point.cbs = cbs; point.entry = entry; point.action = action; if (menu_input_dialog_get_display_kb()) { menu_driver_ctl(RARCH_MENU_CTL_OSK_PTR_AT_POS, &point); if (point.retcode > -1) { menu_event_set_osk_ptr(point.retcode); menu_event_osk_append(point.retcode); } } else { menu_driver_ctl(RARCH_MENU_CTL_POINTER_UP, &point); menu_driver_ctl(RARCH_MENU_CTL_POINTER_TAP, &point); ret = point.retcode; } } if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_BUTTON_R)) { size_t selection = menu_navigation_get_selection(); menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL); } if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_WHEEL_DOWN)) { unsigned increment_by = 1; menu_driver_ctl(MENU_NAVIGATION_CTL_INCREMENT, &increment_by); } if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_WHEEL_UP)) { unsigned decrement_by = 1; menu_driver_ctl(MENU_NAVIGATION_CTL_DECREMENT, &decrement_by); } if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_HORIZ_WHEEL_UP)) { /* stub */ } if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_HORIZ_WHEEL_DOWN)) { /* stub */ } if (mouse_activity) { menu_ctx_environment_t menu_environ; rarch_timer_begin(&mouse_activity_timer, 4); menu_environ.type = MENU_ENVIRON_ENABLE_MOUSE_CURSOR; menu_environ.data = NULL; menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ); } if (no_mouse_activity) { menu_ctx_environment_t menu_environ; rarch_timer_end(&mouse_activity_timer); menu_environ.type = MENU_ENVIRON_DISABLE_MOUSE_CURSOR; menu_environ.data = NULL; menu_driver_ctl(RARCH_MENU_CTL_ENVIRONMENT, &menu_environ); } return ret; }
bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) { struct menu_bind_state binds; bool timed_out = false; settings_t *settings = config_get_ptr(); rarch_timer_tick(&menu_input_binds.timer); if (!bind) return false; if (rarch_timer_has_expired(&menu_input_binds.timer)) { input_driver_keyboard_mapping_set_block(false); menu_input_binds.begin++; menu_input_binds.target++; rarch_timer_begin_new_time(&menu_input_binds.timer, settings->uints.input_bind_timeout); timed_out = true; } snprintf(bind->s, bind->len, "[%s]\npress keyboard or joypad\n(timeout %d %s)", input_config_bind_map_get_desc( menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN), rarch_timer_get_timeout(&menu_input_binds.timer), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SECONDS)); /* binds.begin is updated in keyboard_press callback. */ if (menu_input_binds.begin > menu_input_binds.last) { /* Avoid new binds triggering things right away. */ input_driver_set_flushing_input(); /* We won't be getting any key events, so just cancel early. */ if (timed_out) input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); return true; } binds = menu_input_binds; input_driver_keyboard_mapping_set_block(true); menu_input_key_bind_poll_bind_state(&binds, menu_bind_port, timed_out); if ((binds.skip && !menu_input_binds.skip) || menu_input_key_bind_poll_find_trigger(&menu_input_binds, &binds)) { input_driver_keyboard_mapping_set_block(false); /* Avoid new binds triggering things right away. */ input_driver_set_flushing_input(); binds.begin++; if (binds.begin > binds.last) { input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_CANCEL_WAIT_KEYS, NULL); return true; } binds.target++; rarch_timer_begin_new_time(&binds.timer, settings->uints.input_bind_timeout); } menu_input_binds = binds; return false; }
int menu_dialog_iterate(char *s, size_t len, const char *label) { #ifdef HAVE_CHEEVOS cheevos_ctx_desc_t desc_info; #endif bool do_exit = false; settings_t *settings = config_get_ptr(); switch (menu_dialog_current_type) { case MENU_DIALOG_WELCOME: { static rarch_timer_t timer; if (!rarch_timer_is_running(&timer)) rarch_timer_begin(&timer, 3); rarch_timer_tick(&timer); menu_hash_get_help_enum( MENU_ENUM_LABEL_WELCOME_TO_RETROARCH, s, len); if (!timer.timer_end && rarch_timer_has_expired(&timer)) { rarch_timer_end(&timer); do_exit = true; } } break; case MENU_DIALOG_HELP_CONTROLS: { unsigned i; char s2[PATH_MAX_LENGTH]; const unsigned binds[] = { RETRO_DEVICE_ID_JOYPAD_UP, RETRO_DEVICE_ID_JOYPAD_DOWN, RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_SELECT, RETRO_DEVICE_ID_JOYPAD_START, RARCH_MENU_TOGGLE, RARCH_QUIT_KEY, RETRO_DEVICE_ID_JOYPAD_X, RETRO_DEVICE_ID_JOYPAD_Y, }; char desc[ARRAY_SIZE(binds)][64]; for (i = 0; i < ARRAY_SIZE(binds); i++) desc[i][0] = '\0'; for (i = 0; i < ARRAY_SIZE(binds); i++) { const struct retro_keybind *keybind = &input_config_binds[0][binds[i]]; const struct retro_keybind *auto_bind = (const struct retro_keybind*) input_config_get_bind_auto(0, binds[i]); input_config_get_bind_string(desc[i], keybind, auto_bind, sizeof(desc[i])); } s2[0] = '\0'; menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_MENU_ENUM_CONTROLS_PROLOG, s2, sizeof(s2)); snprintf(s, len, "%s" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n" "[%s]: " "%-20s\n", s2, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_SCROLL_UP), desc[0], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_SCROLL_DOWN), desc[1], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_CONFIRM), desc[2], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK), desc[3], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_INFO), desc[4], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_START), desc[5], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_TOGGLE_MENU), desc[6], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_QUIT), desc[7], msg_hash_to_str( MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_TOGGLE_KEYBOARD), desc[8] ); } break; #ifdef HAVE_CHEEVOS case MENU_DIALOG_HELP_CHEEVOS_DESCRIPTION: desc_info.idx = menu_dialog_current_id; desc_info.s = s; desc_info.len = len; cheevos_get_description(&desc_info); break; #endif case MENU_DIALOG_HELP_WHAT_IS_A_CORE: menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_WHAT_IS_A_CORE_DESC, s, len); break; case MENU_DIALOG_HELP_LOADING_CONTENT: menu_hash_get_help_enum(MENU_ENUM_LABEL_LOAD_CONTENT_LIST, s, len); break; case MENU_DIALOG_HELP_CHANGE_VIRTUAL_GAMEPAD: menu_hash_get_help_enum( MENU_ENUM_LABEL_VALUE_HELP_CHANGE_VIRTUAL_GAMEPAD_DESC, s, len); break; case MENU_DIALOG_HELP_AUDIO_VIDEO_TROUBLESHOOTING: menu_hash_get_help_enum( MENU_ENUM_LABEL_VALUE_HELP_AUDIO_VIDEO_TROUBLESHOOTING_DESC, s, len); break; case MENU_DIALOG_HELP_SCANNING_CONTENT: menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_HELP_SCANNING_CONTENT_DESC, s, len); break; case MENU_DIALOG_HELP_EXTRACT: menu_hash_get_help_enum(MENU_ENUM_LABEL_VALUE_EXTRACTING_PLEASE_WAIT, s, len); if (settings->bools.bundle_finished) { settings->bools.bundle_finished = false; do_exit = true; } break; case MENU_DIALOG_QUIT_CONFIRM: case MENU_DIALOG_INFORMATION: case MENU_DIALOG_QUESTION: case MENU_DIALOG_WARNING: case MENU_DIALOG_ERROR: menu_hash_get_help_enum(menu_dialog_current_msg, s, len); break; case MENU_DIALOG_NONE: default: break; } if (do_exit) { menu_dialog_current_type = MENU_DIALOG_NONE; return 1; } return 0; }