Beispiel #1
0
const std::string& input_context::handle_input() {
    while(1) {
        input_event next_action = inp_mngr.get_input_event(NULL);

        const std::string& action = input_to_action(next_action);

        // Special help action
        if(action == "HELP_KEYBINDINGS") {
            display_help();
            continue;
        }

        if(action != CATA_ERROR) {
            return action;
        }
        // If we registered to receive any input, return ANY_INPUT
        // to signify that an unregistered key was pressed.
        if(registered_any_input) {
            return ANY_INPUT;
        }

        // If it's an invalid key, just keep looping until the user
        // enters something proper.
    }
}
Beispiel #2
0
void input_manager::wait_for_any_key()
{
    while( true ) {
        switch( inp_mngr.get_input_event().type ) {
            case CATA_INPUT_KEYBOARD:
                return;
            // errors are accepted as well to avoid an infinite loop
            case CATA_INPUT_ERROR:
                return;
            default:
                break;
        }
    }
}
Beispiel #3
0
const std::string &input_context::handle_input()
{
    next_action.type = CATA_INPUT_ERROR;
    while(1) {
        next_action = inp_mngr.get_input_event(NULL);
        if (next_action.type == CATA_INPUT_TIMEOUT) {
            return TIMEOUT;
        }

        const std::string &action = input_to_action(next_action);

        // Special help action
        if(action == "HELP_KEYBINDINGS") {
            display_help();
            return HELP_KEYBINDINGS;
        }

        if(next_action.type == CATA_INPUT_MOUSE) {
            if(!handling_coordinate_input) {
                continue; // Ignore this mouse input.
            }

            coordinate_input_received = true;
            coordinate_x = next_action.mouse_x;
            coordinate_y = next_action.mouse_y;
        } else {
            coordinate_input_received = false;
        }

        if(action != CATA_ERROR) {
            return action;
        }

        // If we registered to receive any input, return ANY_INPUT
        // to signify that an unregistered key was pressed.
        if(registered_any_input) {
            return ANY_INPUT;
        }

        // If it's an invalid key, just keep looping until the user
        // enters something proper.
    }
}