本文整理汇总了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.
}
}
示例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;
}
}
}
示例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.
}
}