Hi, I've a similar problem. I need to check which is the physical modifiers' positions, Control, Shift and Alt. On Windows I did it handling the winEvents I'm trying to do the same in linunx handling the x11events but I can't check if the current XEvent is a KeyPress event. One of the problems is what you mentioned, I needed to undef the X11 KeyPress macro. I have tried to compare the XEvent type with 2 because this is the constant declared in X11/X.h but didn't work.
maiko@cits-d530:~/Projetos/Positivo$ grep -i keypress /usr/include/X11/X.h
#define KeyPressMask (1L<<0)
#define KeyPress 2
maiko@cits-d530:~/Projetos/Positivo$ grep -i keypress /usr/include/X11/X.h
#define KeyPressMask (1L<<0)
#define KeyPress 2
To copy to clipboard, switch view to plain text mode
this is my current code
bool MainWindow::x11Event(XEvent *xe)
{
//TODO: remove #undef KeyPress
if(xe->type == 2)
{
switch (xe->xkey.keycode)
{
case 37://Control_L
keyPressEvent(xe->xkey.keycode, "Key_ControlL");
break;
case 105://Control_R
keyPressEvent(xe->xkey.keycode, "Key_ControlR");
break;
case 50://Shift_L
keyPressEvent(xe->xkey.keycode, "Key_ShiftL");
break;
case 62://Shift_R
keyPressEvent(xe->xkey.keycode, "Key_ShiftR");
break;
default:
return false;
}
return true;
}
return false;
}
bool MainWindow::x11Event(XEvent *xe)
{
//TODO: remove #undef KeyPress
if(xe->type == 2)
{
switch (xe->xkey.keycode)
{
case 37://Control_L
keyPressEvent(xe->xkey.keycode, "Key_ControlL");
break;
case 105://Control_R
keyPressEvent(xe->xkey.keycode, "Key_ControlR");
break;
case 50://Shift_L
keyPressEvent(xe->xkey.keycode, "Key_ShiftL");
break;
case 62://Shift_R
keyPressEvent(xe->xkey.keycode, "Key_ShiftR");
break;
default:
return false;
}
return true;
}
return false;
}
To copy to clipboard, switch view to plain text mode
Bye and thx.
Bookmarks