How to make custom button mapping persistent in Half-Life 2

half-life-2

I'm playing Half-Life 2 with an Xbox 360 wired controller in Ubuntu Steam, but the default key mapping is really weird: not only is the default mapping strange to me (e.g. L_SHOULDER for jumping), many actions are just unmapped.

Anyway, every time I run the game I have to remap everything, since the changes are not persistent. I've seen a thread that offers a solution involving the creation of a config file. This is helpful, but still requires loading the cfg file every time and looks more like a workaround than a solution. I can't believe there isn't a better way to save a custom mapping!

By the way, this is really exclusive to HL2. I've tried the same in other Valve titles (namely, Portal and Team Fortress 2) and in games from other companies and never had a problem.

Best Answer

According to this article:

By default the Half Life 2 engine looks for autoexec.cfg at startup, and if it finds it, it will automatically load and execute all the valid commands in it along with those in config.cfg while starting up Half Life 2.

Additionally, you can create any other .cfg files you need, name them as you wish (as long as they end in .cfg), such as mytweaks.cfg, place them in the same directory as config.cfg, and then run the commands they contain from the Half Life 2 console (or from autoexec.cfg) by using the "exec" command. For example typing the command: exec mytweaks.cfg in the console will execute the command variables contained in the mytweaks.cfg file. They will not run automatically at startup however - only autoexec.cfg and config.cfg can do that.