mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-29 20:30:54 +00:00
Fixed: #937 Implement first time pressed keys on Linux
This commit is contained in:
parent
23d3e04d3e
commit
247d75b75b
2 changed files with 12 additions and 9 deletions
|
@ -23,12 +23,11 @@
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
|
|
||||||
#include "nel/misc/debug.h"
|
#include "nel/misc/debug.h"
|
||||||
#include "nel/misc/events.h"
|
|
||||||
#include "unix_event_emitter.h"
|
#include "unix_event_emitter.h"
|
||||||
|
|
||||||
namespace NLMISC {
|
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));
|
TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0));
|
||||||
if(key == KeyNOKEY)
|
if(key == KeyNOKEY)
|
||||||
key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1));
|
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
|
// don't send a control character when deleting
|
||||||
if (key == KeyDELETE)
|
if (key == KeyDELETE)
|
||||||
|
@ -336,8 +336,9 @@ void CUnixEventEmitter::processMessage (XEvent &event, CEventServer &server)
|
||||||
TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0));
|
TKey key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 0));
|
||||||
if(key == KeyNOKEY)
|
if(key == KeyNOKEY)
|
||||||
key = getKey(XKeycodeToKeysym(_dpy, ((XKeyEvent*)&event)->keycode, 1));
|
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));
|
server.postEvent (new CEventKeyUp (key, getKeyButton(event.xbutton.state), this));
|
||||||
|
_PreviousKey = KeyNOKEY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Case(FocusIn)
|
Case(FocusIn)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "nel/misc/types_nl.h"
|
#include "nel/misc/types_nl.h"
|
||||||
#include "nel/misc/event_emitter.h"
|
#include "nel/misc/event_emitter.h"
|
||||||
|
#include "nel/misc/events.h"
|
||||||
|
|
||||||
#ifdef NL_OS_UNIX
|
#ifdef NL_OS_UNIX
|
||||||
|
|
||||||
|
@ -38,10 +39,10 @@ class CUnixEventEmitter : public IEventEmitter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// Constructor
|
/// Constructor
|
||||||
CUnixEventEmitter();
|
CUnixEventEmitter();
|
||||||
|
|
||||||
void init (Display *dpy, Window win);
|
void init (Display *dpy, Window win);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sends all events to server
|
* sends all events to server
|
||||||
|
@ -53,9 +54,10 @@ public:
|
||||||
public:
|
public:
|
||||||
void processMessage (XEvent &event, CEventServer &server);
|
void processMessage (XEvent &event, CEventServer &server);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Display *_dpy;
|
Display *_dpy;
|
||||||
Window _win;
|
Window _win;
|
||||||
|
TKey _PreviousKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue