[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.

[fixed] EKEY_CODE in Keycodes.h has insufficient range

Postby Klokancz » Thu Mar 16, 2017 9:58 am

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)

cpp 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.
cpp 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.
 
Klokancz
 
Posts: 2
Joined: Thu Mar 16, 2017 9:42 am

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

Postby CuteAlien » Thu Mar 16, 2017 11:12 am

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.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

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

Postby Klokancz » Thu Mar 16, 2017 5:51 pm

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:
cpp 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)
 
Klokancz
 
Posts: 2
Joined: Thu Mar 16, 2017 9:42 am

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

Postby CuteAlien » Thu Mar 16, 2017 6:56 pm

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.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

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

Postby CuteAlien » Thu Mar 16, 2017 10:43 pm

OK, I changed in svn 1.8 and trunk branches.
IRC: #irrlicht on irc.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8533
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany


Return to Bug reports

Who is online

Users browsing this forum: No registered users and 1 guest