[SDL] Alt-F4 not working on Windows

Scott Harper orcein at gmail.com
Thu May 1 15:39:36 PDT 2008


On May 2, 2008, at 3:16 AM, Mason Wheeler wrote:

>> If ALT-F4 is supposed to generate an SDL_QUIT under windows, then  
>> what
>> about lining up code that generates an SDL_QUIT via some automagical
>> window manager / OS detection routine and associated keyboard
>> combinations ?  And what if I wanted to make any of those given key
>> combinations usable within my application rather than force a program
>> close ?
>
> I can't agree with that.  Conventions and standards exist for a  
> reason, and this one has a very good reason behind it.  If you don't  
> have an arbitrarily defined and universally observed "close now"  
> command, then the only way to quit out of a game is to select the  
> game's own in-game close command, which is generally found in a menu  
> somewhere.  Menus aren't always accessible--during cutscenes, for  
> example-- and sometimes it's necessary to go through several menus  
> to find the "Exit" command.  This can be a real nuisance if you need  
> to get out of a program quickly, especially a fullscreen game.  I've  
> also played some games where <ALT>-<F4> doesn't quit, and a few  
> where it does but doesn't quit *properly*, leaving the screen  
> corrupted or various other nuisances. This is very bad programming  
> and annoys users that are used to using <ALT>-<F4> to quit, and it  
> shouldn't be associated with SDL.

I'm not sure if I'm allowed to make this argument or not, but as a  
user I've always been wary of the Alt-F4 command in games, because my  
general impression is that it implies a "merciless" end-program  
request, and I'm pretty sure that I've NEVER wanted that feature  
barring times I've played games at work, which is a no-no anyhow. ^_^   
And by "merciless" I don't mean like kill -9, I mean that Windows just  
assumes that you MEANT to press that key-combination.  For office  
applications this is likely okay.

I feel like I should point out that, even on Mac, the Command-Q  
combination is a standard defined by Apple, but not ENFORCED by  
Apple.  It's just as easy to change the "Quit" key command to be  
nothing at all, or something completely different.  And case-in-point,  
World of Warcraft does not recognize the Command-Q keystroke unless  
you define it to have some in-game meaning, and I think this is  
important.  See, what happens if I'm playing your game and I try to  
press Alt-4 (keeping with Warcraft, this is a default keystroke for  
performing a skill), but I have fat fingers and move a little too  
aggressively to the key, and manage instead to hit the F4 key?   
Suddenly my game quits on me, and my party hates me, and I've gotten  
quite angry and may even take steps to remove the key from my keyboard.

Gamers DO remove keys from their keyboard.  For instance, back when I  
used to play Final Fantasy Online (admittedly a poorly-designed game  
in many technical ways) we would often remove the "Windows" key from  
our keyboards because not only did it LEAVE the program, but when the  
program lost front-focus, it cried like a baby and quit on you.  The  
Windows-key became the enemy.

Anyway, what I'm trying to say is that for normal programs, I think  
yes, adhering to the standard is good.  For games, I think you need to  
be able to say "shove-off" to the standard.  I can as easily see a  
game designed that used commands Alt-F1 through Alt-F6 for a  
legitimate sequence of commands, and having to work around that, were  
the ability you're describing to be built into SDL, that would provide  
a lot of excess work specifically for the Windows port of the game,  
wouldn't it?

Isn't it just simpler to use "#ifdef __WINDOWS" or whatever the  
Windows identifier is to capture Alt-F4 if that's a feature you want  
to support, rather than forcing other non-Windows developers to  
redesign their keyboard command interface (which is completely  
legitimate on Linux AND Mac) for the Windows version, or add what I  
could only imagine to likely be excess code to work AROUND the Alt-F4  
check in the Windows version of their software?

-- Scott

On a side note, you mentioned a game which you said is fortunately  
very stable, because were it to crash you would have to reinstall the  
game, as your data would be corrupt.  As a user and gamer myself, this  
scares the living you-know-what out of me.  I would probably never  
even TRY playing a game if I heard this about it, because there are a  
LOT of things OTHER than the game itself which can cause a crash,  
including cats, electrical storms, hot coffee or other drinks), faulty  
power-supplies, problems with motherboard/video cards, etc...  Even as  
a relatively inexperienced developer, though, I have to believe that  
there's a better way to store game data that doesn't force you to  
reinstall the ENTIRE game if something crashes and/or gets corrupted.   
Speaking as a mere user again, this sounds to me like an INCREDIBLY  
bad design decision.

Anyway, my $.02.


More information about the SDL mailing list