KeyPress/KeyRelease on Linux

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
cubicool
Posts: 10
Joined: Sun Jan 29, 2006 7:15 pm

KeyPress/KeyRelease on Linux

Post by cubicool »

I'm pretty sure that what I'm experiencing isn't the "norm" in terms of what is supposed to be happening and what is actually happening. I'm using Ubuntu Breezy, Xorg 6.8.2, a 2.6.15.2 kernel and the latest version of Irrlicht compiled from source.

If I press and hold a certain key I get a constant stream if KeyInput events. However, each event's PressedDown boolean switches back and forth, rather than staying true until I release the key. For example, if I hold the "A" for 10 seconds, I'll get about 200 key press events, 100 of which are "up" and 100 of which are "down" (according to the PressedDown boolean).

Has anyone else experienced this before? I've include my "debugging" function as well, for good measure.

Code: Select all

std::ostream& operator<<(std::ostream& out, const SEvent& event) {
        static std::string events[] = {
                "EET_GUI_EVENT",
                "EET_MOUSE_INPUT_EVENT",
                "EET_KEY_INPUT_EVENT",
                "EET_LOG_TEXT_EVENT",
                "EET_USER_EVENT"
        };

        out << events[event.EventType];

        if(event.EventType == EET_KEY_INPUT_EVENT) out
                << " {"                << std::endl
                << " -> Char: "        << event.KeyInput.Char        << std::endl
                << " -> PressedDown: " << event.KeyInput.PressedDown << std::endl
                << " -> Shift: "       << event.KeyInput.Shift       << std::endl
                << " -> Control: "     << event.KeyInput.Control     << std::endl
                << " -> Key: "         << event.KeyInput.Key         << std::endl
                << "}"
        ;

        return out;
}
cubicool
Posts: 10
Joined: Sun Jan 29, 2006 7:15 pm

Post by cubicool »

After a little more investigation on my part it turns out that this is a "feature" of your window manager; X is actually propagating events exactly as I'm interpreting them in irrlicht. Apparently, when you hold down a key your window manager simulates you pressing it over and over at some user-defined speed. You can bypass X and read from /dev/input/event* directly (which supports a notion of "KeyRepeat"), but that'd be more work than it's worth.

Anyone have any advice? How does Windows handle this?
cubicool
Posts: 10
Joined: Sun Jan 29, 2006 7:15 pm

Post by cubicool »

The answer is to call XAutoRepeatOff using the Display pointer Irrlicht sets up in the IrrlichtDevice. The question now is--what's the best way to do that? :/
LunaRebirth
Posts: 386
Joined: Sun May 11, 2014 12:13 am

Re: KeyPress/KeyRelease on Linux

Post by LunaRebirth »

Was this ever solved?
I get the same results on Irrlicht 1.9 (Windows)

Update: Only happens when I remote desktop into my PC (using TeamViewer). Could also be on their side.
CuteAlien
Admin
Posts: 9646
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: KeyPress/KeyRelease on Linux

Post by CuteAlien »

You can try calling the XAutoRepeatOff he mentioned. You can access the display pointer from IVideoDriver.getExposedVideoData().OpenGLLinux.X11Display.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply