当前位置: 首页>>代码示例>>C++>>正文


C++ input_manager::get_input_event方法代码示例

本文整理汇总了C++中input_manager::get_input_event方法的典型用法代码示例。如果您正苦于以下问题:C++ input_manager::get_input_event方法的具体用法?C++ input_manager::get_input_event怎么用?C++ input_manager::get_input_event使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在input_manager的用法示例。


在下文中一共展示了input_manager::get_input_event方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

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.
    }
}
开发者ID:8Z,项目名称:Cataclysm-DDA,代码行数:25,代码来源:input.cpp

示例2: wait_for_any_key

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;
        }
    }
}
开发者ID:greenalgae3183,项目名称:Cataclysm-DDA,代码行数:14,代码来源:input.cpp

示例3: while

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.
    }
}
开发者ID:Acherontius,项目名称:Cataclysm-DDA,代码行数:43,代码来源:input.cpp


注:本文中的input_manager::get_input_event方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。