View Single Post
Posts: 805 | Thanked: 1,605 times | Joined on Feb 2010 @ Gdynia, Poland
#22
I managed to get keyboard working in your example

you need to change:

Code:
\\swa.event_mask  =  ExposureMask | PointerMotionMask;
swa.event_mask  =  ExposureMask | PointerMotionMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask;
and

Code:
while (!quit) {
XSetInputFocus( x_display, root, RevertToParent, CurrentTime);
XSetInputFocus( x_display, win, RevertToParent, CurrentTime);
XFlush( x_display );
while(XPending( x_display )) { ...
And then the main loop with xev.type will be able to handle: MotionNotify, ButtonPress, ButtonRelease and KeyPress events

note: you may need to add
Code:
#include <X11/Xutil.h>
after line with X11/Xlib.h , but I'm not sure, my code is a little bit longer at the moment... Can I change this in your code at wiki? do you agree? : ) I've spent 3 days on this silly little problem, but finally solved it, with help of this page (and other pages it links to, and so on) : http://talk.maemo.org/showthread.php?t=36952

It seems you need to setup this ButtonPressMask and manualy call XSetInputFocus to get keyboard running in X app... I will post in near future very simple code with implemented handling of keyboard, mouse (touchscreen), accelerometer and opengles 2.0, as I'm still working on it it's also very modular, splitted into files like "accelerometer.h", "glinit.h", "glrender.h", etc. ; ) Hope this helps many developers to start developing ( because this whole setup is the hardest part I think... )

Last edited by misiak; 2010-02-19 at 02:35. Reason: code was not working after switching to another window and going back, needed to change a little