Lales.Charles Posted January 16, 2023 Share Posted January 16, 2023 Hi, In UnigineInput.h, there is maybe an incomplete enum for the PLUS and MINUS keys.. For MINUS, 3 values.. KEY_MINUS KEY_NUMPAD_MINUS KEY_ANY_MINUS -> this one you confirm it is KEY_MINUS || KEY_NUMPAD_MINUS right? .. but for PLUS, only 1 value: KEY_NUMPAD_PLUS Is it normal? Regards, Charles Link to comment
silent Posted January 16, 2023 Share Posted January 16, 2023 Hi Charles, If you are talking about scan codes naming, "+" button on a keyboard is available only on NumPad, so there is no issue here. The other button that you may refer is probably "=" ("Shift" + "=" equals "+") on QWERTY. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Lales.Charles Posted January 16, 2023 Author Share Posted January 16, 2023 Hi, Thanks for indication regarding this API change. I do understand 2 ways to capture keyboard interaction: Logical key (char code) Physical key (scan code) Logical key -> depends on keyboard layout whereas we do have users with keyboard French, German or English. Our German users do have keyboard with +/- keys and +/- numpad keys. So, is there a nice way to handle it (as it was previously)? Would it make sense in the API to expose a getLogicalKey and getPhysicalKey? Regards, Charles Link to comment
silent Posted January 17, 2023 Share Posted January 17, 2023 As far as I know you can obtain local key from scan using Input::getKeyLocalName() and keyToUnicode() combination. Sample from Input class documentation: #include "AppWorldLogic.h" #include <UnigineInput.h> #include <UnigineConsole.h> using namespace Unigine; int AppWorldLogic::init() { Console::setOnscreen(true); return 1; } int AppWorldLogic::update() { auto print_info = [](const char *state, Input::KEY key) { unsigned int unicode = Input::keyToUnicode(key); Console::message("%s: (key='%s', unicode='%s', local_name='%s') ", state, Input::getKeyName(key), String::unicodeToUtf8(unicode).get(), Input::getKeyLocalName(key)); }; print_info("Up", Input::KEY_W); print_info("Jump", Input::KEY_SPACE); print_info("Run", Input::KEY_RIGHT_SHIFT); Console::message("\n"); return 1; } How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Amerio.Stephane Posted January 17, 2023 Share Posted January 17, 2023 Hi, This code doesn't consider any modifier (Shift or AltGrph). So I suspect it can only give the main symbol for a physical key. How do you account for a modifier then? Link to comment
silent Posted January 17, 2023 Share Posted January 17, 2023 getKeyLocalName() should return result with modifier applied. Did you test it on your side and have different results? Can you show us output of this code with shift pressed and released? How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Lales.Charles Posted January 17, 2023 Author Share Posted January 17, 2023 (edited) Hi, This is what I get with German (QWERTZ) keyboard: keyboard event: (key='RIGHT_BRACKET', unicode='+', local_name='+') keyboard event: (key='SLASH', unicode='-', local_name='-') keyboard event: (key='NUMPAD_PLUS', unicode='', local_name='Numpad Plus') keyboard event: (key='NUMPAD_MINUS', unicode='', local_name='Numpad Minus') So.. I guess I'll have to addCallback to receiving the immediate input and get an InputEventPtr with arbitrary key test string contain local_name with +/Plus or -/Minus.. Regards, Charles Edited January 17, 2023 by Lales.Charles Link to comment
silent Posted January 17, 2023 Share Posted January 17, 2023 Yep, something like that. The only why there is a KEY_ANY_MINUS constant exists because there are actually two "-" scan codes available at the same time, while "+" has only a single physical button that you can press without modifiers. How to submit a good bug report --- FTP server for test scenes and user uploads: ftp://files.unigine.com user: upload password: 6xYkd6vLYWjpW6SN Link to comment
Recommended Posts