tomasz.krosnowski Posted August 2, 2013 Share Posted August 2, 2013 I have a question related to keboard access. I am currently trying to make my own key bindings. For this I use Unigine::Application *app = (...); if (app->getKeyState(Unigine::App::KEY_F1)) { // my stuff here for F1 key return -1; } It works for some keys, however I dont know how to overwrite default Unigine keybinds, like ESC, or ` ( console button).I tried if (app->getKeyState(Unigine::App::KEY_ESC)) { // my stuff here for ESC std::cout<<"ESC pressed"<<std::endl; return -1; } but never reached the cout. What am I doing wrong? Should I access the keys from different level? Thomas Link to comment
frustum Posted August 3, 2013 Share Posted August 3, 2013 System menu logic is located inside the data/core/scripts/system/system.h file. Console toggle key can be changed via "console_key" console variable. Link to comment
tomasz.krosnowski Posted August 7, 2013 Author Share Posted August 7, 2013 OK - but what am I supposed to do, to make my own keybind to ESC button from C++ level? My point is - I want to disable all keybinds, menuses, console etc, and make the app remotely (network) managed. I have disabled the gui and console in my idle function, so now the menu and console is not showing up: Unigine::Console m_pConsole = Unigine::Console::get(); Unigine::Gui m_spGui = Unigine::Gui::get(); if (!m_spGui->isHidden()) { m_spGui->setHidden(1); } if (m_pConsole->getActivity()) { m_pConsole->setActivity(0); } However still I dont know how to unbind the default meaning of ESC button, so I can connect them with my actions. Link to comment
frustum Posted August 24, 2013 Share Posted August 24, 2013 Please use an empty system script. There are no key bindings except console key inside the Engine. Link to comment
vadim.sergeev Posted May 28, 2014 Share Posted May 28, 2014 You can use exist system.h file, but in callback function you must drop APP_KEY_ESC state like this // Implement a callback function that takes key as an argument. int key_pressed_callback_func(int nKey) { //https://developer.unigine.com/forum/topic/2156-solved-keyboard-access/?hl=ESC#entry11783 // ESK key behavior implemented in "data/core/scripts/system/system.h" // show/hide main window // if(engine.console.getActivity() == 0 && engine.gui.getMouseGrab() == 0 && // engine.gui.getPermanentFocus() == NULL && engine.app.clearKeyState(APP_KEY_ESC)) { // // if(enabled == 0) show(); // else hide(); // } if (nKey == APP_KEY_ESC && engine.console.getLock()) engine.app.clearKeyState(APP_KEY_ESC); // TODO some logic return 0; } Link to comment
Recommended Posts