SDL is a cross-platform multimedia framework. In layman's terms: games use it because it does a lot of work for the developers, such as video and sound processing, as well as obtaining and analyzing user input from keyboards, mice, controllers, and other things like that. Generally, it does a very good job of doing this, but there's one MASSIVE flaw in it: It has a nasty habit of ensuring that alt-tab and other very useful keyboard shortcuts don't and can't work while playing a game in Linux.
The reason for this is a massive programming oversight. It's related to the programming function SDL_WM_GrabInput. What this does is "grabs" the mouse. It's referred to that because it takes the mouse and holds on to it like a child, saying, "you can't have it! It's mine!" Only there's a good reason that it's doing that; this makes sure that the mouse doesn't go flying out of the game window or runs into an invisible edge. This is especially important in First-Person Shooters, where you could be turning to aim at an enemy, and suddenly stop because your hidden mouse cursor hit the edge of the screen, leading to the enemy humiliatingly cherry-tapping you to death. So, how is something related to the mouse somehow blocking Alt-Tab from working? That's the oversight I'm referring to. SDL on Windows and Mac (and probably others) only grabs the mouse when using that function, but SDL on Linux also grabs the keyboard, so that other applications, such as, you know, THE PART OF THE DESKTOP ENVIRONMENT THAT CONTROLS KEYBOARD SHORTCUTS, can't use it. Unlike with grabbing the mouse, there is no logical reason to grab the keyboard. In addition, this is a massive inconsistency in the cross-platform implementation of the command.
Thank God SDL is open-source, because the only solution is to edit the source code. Thankfully for you, I've already done this for you. You can download a precompiled 32-bit binary build, it's source code, and a patch file from my age-old GameFront account that somehow is still valid. The following instructions are for people masochistic enough to want to do it completely themselves:
- Download SDL's source code from here and extract it somewhere easy like the desktop.
- Open a folder view to the source code directory.
- Browse to src/video/x11/
- Open SDL_x11wm.c
- Scroll down to function X11_GrabInputNoLock
- Comment the two lines below this comment "/* Now grab the keyboard */"
- To do this, just type // in front of them.
- Verify that your changes match this image, except without the obvious image edits I did.
- Navigate to the main SDL directory.
- Open a terminal here.
- Type in ./configure.
- ONLY IF YOU GET ERRORS: generally those errors will be a missing something error. These can be resolved by downloading the necessary files through your distribution's package manager. So do that, then go back to step 9 and keep trying it until it doesn't give you an error.
- IF YOU DIDN'T GET ANY ERRORS WITH STEP 10: Type in make
- In your terminal, type in make install.
- IF YOU GET A PERMISSIONS ERROR: look up how to run a command as root on your distribution. For most, it should be as simple as typing in sudo in front of it, like this:
sudo make install - IF YOU GET A COMPILING ERROR: You're screwed. Sorry. Maybe you can ask around somewhere, but don't expect any help from me.
- Open a folder view to the main SDL directory
- Navigate to the "build" directory.
- Navigate to the ".libs" directory.
- IF YOU DON'T SEE ".libs": Tell your file browser to show hidden files and folders.
- In Nautilus (GNOME), this can be done by pressing ctrl+H
- In Dolphin (KDE), I think (unsure) this can be done by pressing ctrl+. Or maybe alt+. I don't remember.
- Copy and paste "libSDL-1.2.so.0.11.3" somewhere easy like the desktop.
- IF YOU CAN'T FIND THAT EXACT FILE: It's probably the file with the most similar name. A newer or otherwise modified source code may produce one with a different file name.
- Rename the file to "libSDL-1.2.so.0"
- Copy and paste "libSDL-1.2.so.0" into the game's binary directory, where the included SDL binaries were.
If you benefited from this, please share this link around. I want to actually help people who have this issue, and not just myself. Feel free to package up my hacked SDL and share it. I really don't care what you do with it. I don't care if I don't get any credit for it. I just want to help. Just be sure to keep the LGPL license, so that SDL's developers don't get mad at anybody.
No comments:
Post a Comment