Home » Extra libraries, Code snippets, applications etc. » OS Problems etc., Win32, POSIX, MacOS, FreeBSD, X11 etc » X11App.cpp: GetKbdDelay()/GetkbdSpeed()
X11App.cpp: GetKbdDelay()/GetkbdSpeed() [message #3830] |
Wed, 28 June 2006 20:49 |
guido
Messages: 169 Registered: April 2006
|
Experienced Member |
|
|
I noticed GetKbdDelay()/GetkbdSpeed() are only returning default values yet, so I gave it a go, equipped with the source of Xorg's xset utility.
It doesn't compile yet due to X11/XKBlib.h importing union structs, incompatible with C++. After getting it to compile, it should work alright.
I think the xkb is ubicituous enough that no extra PLATFORM_ variable needs to be introduced.
#include <X11/XKBlib.h>
static int xkbdelay = 660, xkbrate = (1000/40);
static void GetXkbControls()
{
int xkbmajor = XkbMajorVersion, xkbminor = XkbMinorVersion;
int xkbopcode, xkbevent, xkberror;
XkbDescPtr xkb;
if (XkbQueryExtension(Xdisplay, &xkbopcode, &xkbevent,
&xkberror, &xkbmajor, &xkbminor)
&& (xkb = XkbAllocKeyboard()) != NULL)
{
if (XkbGetControls(Xdisplay, XkbRepeatKeysMask, xkb) == Success)
{
xkbdelay = xkb->ctrls->repeat_delay;
xkbrate = 1000/xkb->ctrls->repeat_interval;
}
XkbFreeKeyboard(xkb, 0, XTrue);
}
}
int Ctrl::GetKbdDelay()
{
GetXkbControls();
return xkbdelay;
}
int Ctrl::GetKbdSpeed()
{
GetXkbControls();
return xkbrate;
}
PS:
What does upp use those methods for anyway?
|
|
|
|
Goto Forum:
Current Time: Sat Sep 21 02:47:00 CEST 2024
Total time taken to generate the page: 0.04038 seconds
|