SFTtech / openage

Free (as in freedom) open source clone of the Age of Empires II engine 🚀
http://openage.dev
Other
12.77k stars 1.12k forks source link

doubled input handling #914

Open castilma opened 7 years ago

castilma commented 7 years ago

when I start the console and then select an input field from the game option, the keyboard input is put in the textfield and the console.

we currently have 3 input handler. one for qt, one for the normal keybindings and one for the console. they are called in that order in engine.h:359

for (auto &action : this->on_input_event) {
       if (false == action->on_input(&event)) {
              break;
       }
}

it looks like the handler can return false to indicate that they handled the input. strangely, input/input_manager.cpp:381 always returns true.

I guess we need to unselect the textfield when the console is set visible/clicked on. (why does the qt input manager return true if it handled the key?)

another problem is that Console::register_to_engine.h() registers "`" to be used to hide the console, but when pressing it, it is taken as literal text input to the console.

TheJJ commented 7 years ago

When the console is active (i.e. in foreground?) then all the keyboard input should go to it.

The decision if events shall go to qt is probably done by either qt reporting that some input field is now active (by mouse).

Maybe it would be better to totally transition all input to qt. This might be good as all keybindings in-game are just a shortcut for some button.

castilma commented 7 years ago

IIUC, the input is passed to qt to see if it has something to do with the qt handled parts of the gui.

IIUC there is no decision made wether or not to pass input events to qt. it is always passed, and qt says wether it handled it or not.

I can't say, if we should let qt handle all input/shortcuts.