OISInput.cfg: input text fields don't work

Problems and solutions for installing or running FreeOrion, including discussion of bugs if needed before posting a bug report on GitHub. For problems building from source, post in Compile.

Moderator: Oberlus

Message
Author
User avatar
mrSpaceman
Space Floater
Posts: 31
Joined: Fri Apr 29, 2011 3:58 pm
Location: UK

Re: OISInput.cfg: input text fields don't work

#46 Post by mrSpaceman »

I tried both. And also with capture calls after each keyRelease call. No luck :(

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: OISInput.cfg: input text fields don't work

#47 Post by Geoff the Medio »

Geoff the Medio wrote:Regardless, did it cause any problems?

User avatar
mrSpaceman
Space Floater
Posts: 31
Joined: Fri Apr 29, 2011 3:58 pm
Location: UK

Re: OISInput.cfg: input text fields don't work

#48 Post by mrSpaceman »

Not that I have detected.

User avatar
mrSpaceman
Space Floater
Posts: 31
Joined: Fri Apr 29, 2011 3:58 pm
Location: UK

Re: OISInput.cfg: input text fields don't work

#49 Post by mrSpaceman »

I am now trying the newest version of libOIS and I'm going to try a few things in its codebase to try and work out the problem. It might be futile as the project isn't maintained, etc., but I might uncover something useful. :idea:

Is there no option of creating a fork of the code (call it "FreeOrion Object-Orient Input System", and change the namespace a little, etc.) to then distribute with the FreeOrion code. It would be easier than switching the GUI system to SDL, surely. The existing FreeOrion 0.4.x code will easily switch to something that is essentially the same, but with code improvements and a slightly different name. :?:

EDIT: Oh, and libOIS 1.4.0 doesn't fix the Alt-TAB problem.

jcantero
Krill Swarm
Posts: 12
Joined: Sun Nov 24, 2013 5:08 pm

Re: OISInput.cfg: input text fields don't work

#50 Post by jcantero »

mrSpaceman wrote:I am now trying the newest version of libOIS and I'm going to try a few things in its codebase to try and work out the problem. It might be futile as the project isn't
maintained, etc., but I might uncover something useful. :idea:
mrSpaceman wrote:EDIT: Oh, and libOIS 1.4.0 doesn't fix the Alt-TAB problem.
There is not libOIS 1.4.0. I suppose you mean the last version from GitHub master branch, where OIS_VERSION_NAME is "1.4.0" (but that version never was released).
mrSpaceman wrote:Is there no option of creating a fork of the code (call it "FreeOrion Object-Orient Input System", and change the namespace a little, etc.) to then distribute with the FreeOrion code. It would be easier than switching the GUI system to SDL, surely. The existing FreeOrion 0.4.x code will easily switch to something that is essentially the same, but with code improvements and a slightly different name. :?:
The problem is what version is used in each distro. For example, FreeOrion source code include its own OIS version based on that is called "1.4.0", but Debian packages (and therefore Ubuntu) links FO to libois 1.3.0: see the Debian Package and Ubuntu package pages.

On the other hand, the problem with ALT+TAB is quite common, even with games that use SDL. It can be related to how X server handles keyboard grabs (it's a complex subject). Can I suggest you to look at the keyboard events that X is sending to FreeOrion? Try to install xtrace (an apt-get install xtrace should suffice) and open a terminal to launch FreeOrion from the command line with this:

Code: Select all

xtrace -D:9 -m 20 -d:0 -k freeorion | grep "Event Key"
Now you can see the keyboard events that the X server is sending to FO when you press or release a key. Check the behavior before, during and after an ALT+TAB. If the events are still receiving, then you have to trace up the keyboard event handing (again). But if not... well, that's a new line of research. :?

cataclysm
Space Krill
Posts: 6
Joined: Mon Aug 11, 2014 1:32 am

Re: OISInput.cfg: input text fields don't work

#51 Post by cataclysm »

The core problem is that the OIS Linux driver (others may be affected as well) updates its internal key state buffer only when it receives key up and key down events. Keyboard state changes that occur while the application does not have keyboard focus do not send events to the application so the internal key state buffer gets out of sync with the physical keyboard state.

The GG OIS driver determines which modifiers are in effect by querying OIS for the state of each modifier key. When the internal key state buffer is incorrect, GG will apply modifier keys incorrectly. I patched the Linux driver to update the key state each time the application gains focus. This should fix the Alt-Tab problem in addition to other modifier key issues when changing focus.
Attachments

[The extension patch has been deactivated and can no longer be displayed.]

Any code of mine in this post is released under the GPL 2.0 or later.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: OISInput.cfg: input text fields don't work

#52 Post by Geoff the Medio »

cataclysm wrote:I patched the Linux driver to update the key state each time the application gains focus.
Please edit your post or signature to note that you release this or any changes you post under the GPL 2.0 or later.

User avatar
mrSpaceman
Space Floater
Posts: 31
Joined: Fri Apr 29, 2011 3:58 pm
Location: UK

Re: OISInput.cfg: input text fields don't work

#53 Post by mrSpaceman »

cataclysm wrote:The core problem is that the OIS Linux driver (others may be affected as well) updates its internal key state buffer only when it receives key up and key down events. Keyboard state changes that occur while the application does not have keyboard focus do not send events to the application so the internal key state buffer gets out of sync with the physical keyboard state.

The GG OIS driver determines which modifiers are in effect by querying OIS for the state of each modifier key. When the internal key state buffer is incorrect, GG will apply modifier keys incorrectly. I patched the Linux driver to update the key state each time the application gains focus. This should fix the Alt-Tab problem in addition to other modifier key issues when changing focus.
The problem with your patch is that the OIS Linux driver source files supplied with FreeOrion are not built. The driver is built as the libois-1.3.0.so library. However, I have been tinkering and building my own library based on the OIS GitHub source: https://github.com/urkle/ois I'll add your patch code to this source and see if has any positive effect on the problem.

The issue then is how to allow FreeOrion to use this code rather than the buggy code which is distributed as the libois-1.3.0 OIS library. I don't know how much cajoling the OIS people would have to take for a 1.3.1 or 1.4.0 library to appear, so that the Linux Alt-TAB problem is solved. Since their forum is pretty dead (and the GitHub), I think it will be more than a little nudging, shall we say.

User avatar
Geoff the Medio
Programming, Design, Admin
Posts: 13587
Joined: Wed Oct 08, 2003 1:33 am
Location: Munich

Re: OISInput.cfg: input text fields don't work

#54 Post by Geoff the Medio »

FreeOrion doesn't have to use a library called "libois". If set up to produce "libfreeorionois" or "libextremebanana", and then set up to load the same when running, the existence of an installed libois on the system is presumably irrelevant.

User avatar
mrSpaceman
Space Floater
Posts: 31
Joined: Fri Apr 29, 2011 3:58 pm
Location: UK

Re: OISInput.cfg: input text fields don't work

#55 Post by mrSpaceman »

Geoff the Medio wrote:FreeOrion doesn't have to use a library called "libois". If set up to produce "libfreeorionois" or "libextremebanana", and then set up to load the same when running, the existence of an installed libois on the system is presumably irrelevant.
Then there might not be any big problem with the OIS project being a bit 'dormant' :wink:

cataclysm
Space Krill
Posts: 6
Joined: Mon Aug 11, 2014 1:32 am

Re: OISInput.cfg: input text fields don't work

#56 Post by cataclysm »

mrSpaceman wrote: The problem with your patch is that the OIS Linux driver source files supplied with FreeOrion are not built.
I realize that this is a problem. I am leaving to others the difficult task of figuring out how to get FreeOrion to use the patched code. For my development, I simply built a static version of OIS to link with libGiGiOgrePlugin_ois.so. The licenses seem to allow this as an option for distribution.

Since OIS appears unmaintained, I think the only workable options long-term are to build a modified version of OIS or to switch to a new input library. Since I'm unfamiliar with alternative libraries, I figured I'd just submit the fix and let others decide what to do with it. At the very least, people can build a patched OIS library to get things working for themselves.
Any code of mine in this post is released under the GPL 2.0 or later.

User avatar
adrian_broher
Programmer
Posts: 1156
Joined: Fri Mar 01, 2013 9:52 am
Location: Germany

Re: OISInput.cfg: input text fields don't work

#57 Post by adrian_broher »

Thanks for your effort cataclysm, but we're not the OIS upstream and have no use for your patch.

I already stated in another thread that we (the freeorion team) won't maintain a fork for reasons [1]. mrSpaceman started a thread discussing if we should SDL/SDL2 in the future [2]. I haven't seen any objections to that idea from other developers and Mitten.O even stepped up to make his hands dirty on that and the patch is looking good so far. I'm almost incline to say that freeorion will move to SDL.

[1] viewtopic.php?p=71045#p71045
[2] viewtopic.php?f=9&t=8989
Resident code gremlin
Attached patches are released under GPL 2.0 or later.
Git author: Marcel Metz

jcantero
Krill Swarm
Posts: 12
Joined: Sun Nov 24, 2013 5:08 pm

Re: OISInput.cfg: input text fields don't work

#58 Post by jcantero »

Well, since OIS will no longer be used, I'm going to stop my quest with the "mysterious keyboard events coming from nowhere". Lucky me, because I think it's a bug within the X server, and it would be a hell to try to find it. But I can't resist to outline what I found, in case anybody in the future is reading this thread trying to fix OIS (a la XKCD's Wisdom of the Ancients). So, Dear people from the future:

For whatever reason, Ogre (and the example app OISConsole) handles the app window separately. First it creates the window for rendering, without input, and then it passes the window handler (the window id in Linux/X) to OIS to delegate input to the library. In Linux/X, this means that OIS opens a second connection to the X server, and starts listening to keyboard and mouse events of the window id from this second connection. When xscreensaver (or another app with the same XSelectInput) tries to listen KeyPress (but no the corresponding KeyRelease) events of the same window from a third connection, somehow the mask events get mixed and the second connection seems to receive some events virtually created but unsolicited (KeyReleases) for the third connection. For me, this is the X server messing with the queues of events, but I know what the X devs are going to say: that X server is full of race conditions and pathological cases never fixed and it's not worth the time.

With SDL you can't separate input and output (unless you modify SDL sources), so the chances of an error of the same type is almost nonexistent.

Post Reply