mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-10 09:19:01 +00:00
Fixed: #1057 X11 Key auto repeat
This commit is contained in:
parent
e0ebfebeac
commit
1c88b0ada0
2 changed files with 21 additions and 15 deletions
|
@ -29,7 +29,7 @@ typedef bool (*x11Proc)(NL3D::IDriver *drv, XEvent *e);
|
||||||
|
|
||||||
namespace NLMISC {
|
namespace NLMISC {
|
||||||
|
|
||||||
CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _PreviousKey(KeyNOKEY), _emulateRawMode(false), _driver(NULL)
|
CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _emulateRawMode(false), _driver(NULL)
|
||||||
{
|
{
|
||||||
_im = 0;
|
_im = 0;
|
||||||
_ic = 0;
|
_ic = 0;
|
||||||
|
@ -533,8 +533,14 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
|
||||||
if(key == KeyNOKEY)
|
if(key == KeyNOKEY)
|
||||||
key = getKeyFromKeycode(keyCode);
|
key = getKeyFromKeycode(keyCode);
|
||||||
|
|
||||||
server->postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), _PreviousKey != key, this));
|
// search for key in map
|
||||||
_PreviousKey = key;
|
std::map<TKey, bool>::const_iterator it = _PressedKeys.find(key);
|
||||||
|
|
||||||
|
// if key is not found or value is false, that's the first time
|
||||||
|
bool firstTime = (it == _PressedKeys.end()) || !it->second;
|
||||||
|
|
||||||
|
server->postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), firstTime, this));
|
||||||
|
_PressedKeys[key] = true;
|
||||||
|
|
||||||
// don't send a control character when deleting
|
// don't send a control character when deleting
|
||||||
if (key == KeyDELETE)
|
if (key == KeyDELETE)
|
||||||
|
@ -568,7 +574,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server)
|
||||||
key = getKeyFromKeycode(event.xkey.keycode);
|
key = getKeyFromKeycode(event.xkey.keycode);
|
||||||
|
|
||||||
server->postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
|
server->postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
|
||||||
_PreviousKey = KeyNOKEY;
|
_PressedKeys[key] = false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ private:
|
||||||
|
|
||||||
Display* _dpy;
|
Display* _dpy;
|
||||||
Window _win;
|
Window _win;
|
||||||
TKey _PreviousKey;
|
std::map<TKey, bool> _PressedKeys;
|
||||||
XIM _im;
|
XIM _im;
|
||||||
XIC _ic;
|
XIC _ic;
|
||||||
bool _emulateRawMode;
|
bool _emulateRawMode;
|
||||||
|
|
Loading…
Reference in a new issue