Jump to content

Possible to get event-driven raw keyboard input?


photo

Recommended Posts

I am using App::setKeyPressUnicodeFunc to handle keyboard input. The uint arg passed to the keypress function provided appears to be a hybrid mix of "raw" keys and characters. That is, if the user presses the F1 key, the function receives uint value 277=KEY_F1. If the user presses the 'm' key alone, the function receives uint 109='m'. If the user presses 'm' while holding shift, the function receives uint 77='M'. If the user presses the 'm' key while holding control, the function receives uint 13, a carriage return. 

 

If a user presses any particular key, I would prefer the function always be called with the same value, regardless of what modifier keys may already be held. Is there a way to do this? Converting between upper- and lower-case letters is trivial but mildly inconvenient. Having to convert control characters into raw keyboard input is more of a nuisance.

 

I would also like to avoid using App::getKeyState to check all applicable key states every tick as an alternative.

Link to comment

Hi Adam,

 

Sorry for the late reply.

 

Task called "create RAW-input" sample is more complicated than we thought before. I will raise priority, but more likely it will be delayed for next week.

 

Also currently it is not completely clear what to do with "Ctrl + M" key combination (for example, Notepad++ threat such combination as carriage return, but some other software - not).

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
Yes, keyboard input at a low level can be complicated in ways one would not expect. I have worked on / with other engines before with similar headaches, so I understand :)
I can mostly work around the problem with ugly hack in the meantime:

void MyClass::OnKeyPressed(uint key)
{
key=tolower(key); // convert capital letters into lower case letters
if(key<=26) key+=96; // convert control characters into lower case letters
if(key==27) key='[';
if(key==28) key=\\';
if(key==29) key=]';
if(key==30) key='6'; // CTRL ^ produces 30, and ^ is on the 6 key
if(key==31) key='-'; // CTRL _ produces 31, and _ is on the - key
 ...
}
 
27 through 31 probably won't work on other keyboard layouts...
 
Link to comment
  • 3 weeks later...

Hi Adam,

 

I'm afraid the best solution our devs can provide to you is looking like your ugly hack. The second solution will be to write your custom App that will handle all the input, but it will require a lot of time and debugging.

 

We will keep in mind this use-case (it still opened in our internal bug tracker) when the controls system will be refactored or updated in the next SDK versions (probably, not this year).

 

Sorry for the inconvenience caused.

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...