[fixed] EKEY_CODE in Keycodes.h has insufficient range

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Klokancz
Posts: 2
Joined: Thu Mar 16, 2017 9:42 am

[fixed] EKEY_CODE in Keycodes.h has insufficient range

Post by Klokancz »

Enum EKEY_CODE for keyeboard input accepts only 255 codes.

Problem:
Presses of 'fn' button on notebook keyboard yields code 255. As far as KEY_KEY_CODES_COUNT = 0xff is used for KeyIsDown[KEY_KEY_CODES_COUNT]; the value ends in next variable. (In my case it was left mouse button clicked)

Code: Select all

 //problem
bool KeyIsDown[255];
KeyIsDown[255] = true; // problem here
 
Suggested fix:
Add fn key to the enum. Variable will support complete 8b input.

Code: Select all

        KEY_FN               = 0xFF,   // Function key on notebook
 
        KEY_KEY_CODES_COUNT  = 0x100 // this is not a key, but the amount of keycodes there are.
 
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: enum EKEY_CODE in Keycodes.h has insuffitient range [1.8

Post by CuteAlien »

That is probably not the key-code (those have only 8 bit). Next bit is the one that tells that a key is an extended key. But fn key shouldn't even create a key-message I think. Unfortunately I can't test right now because the ssd of my laptop broke down and I didn't get around yet figuring out how to replace it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Klokancz
Posts: 2
Joined: Thu Mar 16, 2017 9:42 am

Re: enum EKEY_CODE in Keycodes.h has insuffitient range [1.8

Post by Klokancz »

Good 8 bit codes then it seems ok. 0xFF is the maximum value you can fit into 8 bit variable.
Image

Not to wast time with this there is some detail to array:

Code: Select all

char[1] //declared array for single character
char[255]//declared array for 255 characters - values from 0x0 to 0x254(this is 0xFE not full char 1111 1110 <- LSB is zero)
char[256]//declared array for 256 characters - values from 0x0 to 0x255(this is 0xFF)
 
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: enum EKEY_CODE in Keycodes.h has insuffitient range [1.8

Post by CuteAlien »

Ah, right. I suppose we should add 0xff as KEY_NONE (all names are based on the VK_ names from Windows) and then increase KEY_KEY_CODES_COUNT.

And with the KeyIsDown you mean the examples I guess?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: enum EKEY_CODE in Keycodes.h has insuffitient range [1.8

Post by CuteAlien »

OK, I changed in svn 1.8 and trunk branches.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply