From 247d75b75bc0ecd5cde1fce2e08029f51595fd63 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 25 May 2010 07:46:01 +0200 Subject: [PATCH] Fixed: #937 Implement first time pressed keys on Linux --- code/nel/src/3d/driver/opengl/unix_event_emitter.cpp | 11 ++++++----- code/nel/src/3d/driver/opengl/unix_event_emitter.h | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp index 2db33f5fd..587d440fe 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -23,12 +23,11 @@ #include #include "nel/misc/debug.h" -#include "nel/misc/events.h" #include "unix_event_emitter.h" namespace NLMISC { -CUnixEventEmitter::CUnixEventEmitter () +CUnixEventEmitter::CUnixEventEmitter ():_dpy(NULL), _win(0), _PreviousKey(KeyNOKEY) { } @@ -309,8 +308,9 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server) TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0)); if(key == KeyNOKEY) key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1)); - // TODO manage the bool (first time pressed) - server.postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), true, this)); + + server.postEvent (new CEventKeyDown (key, getKeyButton(event.xbutton.state), _PreviousKey != key, this)); + _PreviousKey = key; // don't send a control character when deleting if (key == KeyDELETE) @@ -336,8 +336,9 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server) TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0)); if(key == KeyNOKEY) key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1)); - // TODO manage the bool (first time pressed) + server.postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this)); + _PreviousKey = KeyNOKEY; break; } Case(FocusIn) diff --git a/code/nel/src/3d/driver/opengl/unix_event_emitter.h b/code/nel/src/3d/driver/opengl/unix_event_emitter.h index cb6592ba4..0c434f4b2 100644 --- a/code/nel/src/3d/driver/opengl/unix_event_emitter.h +++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.h @@ -19,6 +19,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/event_emitter.h" +#include "nel/misc/events.h" #ifdef NL_OS_UNIX @@ -38,10 +39,10 @@ class CUnixEventEmitter : public IEventEmitter { public: - /// Constructor - CUnixEventEmitter(); + /// Constructor + CUnixEventEmitter(); - void init (Display *dpy, Window win); + void init (Display *dpy, Window win); /** * sends all events to server @@ -53,9 +54,10 @@ public: public: void processMessage (XEvent &event, CEventServer &server); - private: +private: Display *_dpy; Window _win; + TKey _PreviousKey; };