Linux: KEY_KEY_X instead of KEY_NUMPADX

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
sash
Competition winner
Posts: 35
Joined: Thu Nov 05, 2009 8:46 am
Location: Novosibirsk

Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by sash »

Hello.

I noticed Irrlicht under linux sends arrows for numpad keys, regardless of numlock state.
Ok, it seems like this is a bug and fixed in svn trunk, right? http://irrlicht.sourceforge.net/forum/v ... 15#p289630

Also I noticed

Code: Select all

 
 void CIrrDeviceLinux::createKeyMap()
{
  ....
    KeyMap.push_back(SKeyMap(XK_KP_0, KEY_KEY_0));
  // and so on
  ...
  //so, shouldn't it be 
    KeyMap.push_back(SKeyMap(XK_KP_0, KEY_NUMPAD0));
  // instead ?
}
 
Irrlicht: last release 1.8.1
Debian 7 x64
CuteAlien
Admin
Posts: 9633
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by CuteAlien »

Sorry, that was not the bug fixed in that other thread. And not easy to fix yet, this likely needs a new flag for "numlock" in the key-input (as we can't easily add more keycodes which would be the other solution).

I changed the part with the numpad numbers in svn trunk r5003, but for some reason it makes no difference. I don't have the time to debug it further right now, but my first guess would be that X11 maybe never sends the XK_KP codes.
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
lisacvuk
Posts: 21
Joined: Thu Apr 17, 2014 4:50 pm

Re: Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by lisacvuk »

I noticed this problem in SuperTuxKart. I doesn't seem to be able to add keyboard setting to numpad keys.
sash
Competition winner
Posts: 35
Joined: Thu Nov 05, 2009 8:46 am
Location: Novosibirsk

Re: Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by sash »

CuteAlien wrote:but my first guess would be that X11 maybe never sends the XK_KP codes.
Currently I postponed input part of my application, but I hope I will look closer on this problem soon.
sash
Competition winner
Posts: 35
Joined: Thu Nov 05, 2009 8:46 am
Location: Novosibirsk

Re: Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by sash »

As I can see current svn trunk version is already refactored, but this bug still presents in the trunk.
The good news X11 clearly distingushes between arrows, numpad arrows, digits and numpad digits with respect of numlock state.
I was able to (quick, not thoroughly tested) fix it in both 1.8.1 and latest svn revision (5018).
What is worked for me is XLookupString without clearing original event.xkey.state

Code: Select all

 
  // .... CIrrDeviceLinux.cpp, 1.8.1 release
  //event.xkey.state = 0; // ignore shift-ctrl states for figuring out the key
  XLookupString(&event.xkey, buf, sizeof(buf), &mp.X11Key, NULL);
 
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by zerochen »

hi,

this was fixed in r4669.

due to later changes this code is not longer present or do i missing something?

regards
zerochen
sash
Competition winner
Posts: 35
Joined: Thu Nov 05, 2009 8:46 am
Location: Novosibirsk

Re: Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by sash »

Hi,
In the last svn trunk version there's a dedicated method

Code: Select all

EKEY_CODE CIrrDeviceLinux::getKeyCode(XEvent &event)
and it doesn't work.
CuteAlien
Admin
Posts: 9633
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Linux: KEY_KEY_X instead of KEY_NUMPADX

Post by CuteAlien »

XLookupString is no longer used because it can't handle international keyboard input. We use XwcLookupString now which unfortunately works slightly different.
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