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(); int64_t current = cpu_features_get_time_usec(); int timeout = (menu_input_binds.timeout_end - current) / 1000000; if (!bind) return false; if (timeout <= 0) { input_driver_keyboard_mapping_set_block(false); menu_input_binds.begin++; menu_input_binds.target++; menu_input_binds.timeout_end = cpu_features_get_time_usec() + settings->input.bind_timeout * 1000000; 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), timeout, 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++; binds.timeout_end = cpu_features_get_time_usec() + settings->input.bind_timeout * 1000000; } menu_input_binds = binds; return false; }
int menu_input_key_bind_iterate(char *s, size_t len) { struct menu_bind_state binds; bool timed_out = false; menu_input_t *menu_input = menu_input_get_ptr(); driver_t *driver = driver_get_ptr(); int64_t current = retro_get_time_usec(); int timeout = (menu_input->binds.timeout_end - current) / 1000000; if (timeout <= 0) { input_driver_keyboard_mapping_set_block(false); menu_input->binds.begin++; menu_input->binds.target++; menu_input->binds.timeout_end = retro_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; timed_out = true; } snprintf(s, len, "[%s]\npress keyboard or joypad\n(timeout %d %s)", input_config_bind_map[ menu_input->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc, timeout, menu_hash_to_str(MENU_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. */ driver->flushing_input = true; /* We won't be getting any key events, so just cancel early. */ if (timed_out) input_keyboard_wait_keys_cancel(); return 1; } binds = menu_input->binds; input_driver_keyboard_mapping_set_block(true); menu_input_key_bind_poll_bind_state(&binds, 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. */ driver->flushing_input = true; binds.begin++; if (binds.begin > binds.last) return 1; binds.target++; binds.timeout_end = retro_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; } menu_input->binds = binds; return 0; }
int menu_input_key_bind_iterate(char *s, size_t len) { struct menu_bind_state binds; bool timed_out = false; menu_input_t *menu_input = menu_input_get_ptr(); driver_t *driver = driver_get_ptr(); bool bind_mode_kb = menu_input->bind_mode_keyboard; int64_t current = retro_get_time_usec(); int timeout = (menu_input->binds.timeout_end - current) / 1000000; if (timeout <= 0) { if (!bind_mode_kb) input_driver_keyboard_mapping_set_block(false); menu_input->binds.begin++; menu_input->binds.target++; menu_input->binds.timeout_end = retro_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; timed_out = true; } if (bind_mode_kb) { snprintf(s, len, "[%s]\npress keyboard\n(timeout %d %s)", input_config_bind_map[ menu_input->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc, timeout, menu_hash_to_str(MENU_VALUE_SECONDS)); return menu_input_key_bind_iterate_keyboard(current, timeout, timed_out); } else snprintf(s, len, "[%s]\npress joypad\n(timeout %d %s)", input_config_bind_map[ menu_input->binds.begin - MENU_SETTINGS_BIND_BEGIN].desc, timeout, menu_hash_to_str(MENU_VALUE_SECONDS)); binds = menu_input->binds; input_driver_keyboard_mapping_set_block(true); menu_input_key_bind_poll_bind_state(&binds, 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. */ driver->flushing_input = true; binds.begin++; if (binds.begin > binds.last) return 1; binds.target++; binds.timeout_end = retro_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; } menu_input->binds = binds; return 0; }