// Written and (C) by Francois Fleuret
// Contact <francois.fleuret@idiap.ch> for comments & bug reports
+#include <string.h>
+#include <stdlib.h>
+
#include "simple_window.h"
SimpleEvent::SimpleEvent() : type(UNDEFINED) {}
SimpleEvent SimpleWindow::event() {
SimpleEvent se;
+ KeySym mykey;
if(XPending(_display) > 0) {
case KeyPress:
se.type = SimpleEvent::KEY_PRESS;
- strncpy(se.key,
- XKeysymToString(XKeycodeToKeysym(_display, event.xkey.keycode, 0)),
- (sizeof(se.key)/sizeof(char) - 1));
+ mykey = XkbKeycodeToKeysym(_display,
+ event.xkey.keycode, 0,
+ event.xkey.state & ShiftMask ? 1 : 0);
+ strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
break;
case KeyRelease:
se.type = SimpleEvent::KEY_RELEASE;
- strncpy(se.key,
- XKeysymToString(XKeycodeToKeysym(_display, event.xkey.keycode, 0)),
- (sizeof(se.key)/sizeof(char) - 1));
+ mykey = XkbKeycodeToKeysym(_display,
+ event.xkey.keycode, 0,
+ event.xkey.state & ShiftMask ? 1 : 0);
+ strncpy(se.key, XKeysymToString(mykey), (sizeof(se.key)/sizeof(char) - 1));
break;
default:
se.type = SimpleEvent::UNDEFINED;
break;
+
}
} else se.type = SimpleEvent::NO_EVENT;
return se;