Question: 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](https://github.com/ValveSoftware/Source-1-Games/issues/781) 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.

Answer: 
I've finally managed to get this to work. It turns out Half Life 2 executes a file named `360-controller.cfg` automatically whenever it starts (for Linux, it executes `360controller-linux.cfg`; both are located at `~/.steam/SteamApps/common/Half-Life 2/hl2/cfg`). So all you need to do is tweak that file to you liking. Here's my setup (the missing buttons are left to default):

```
joy_name "Game controller"

bind "A_BUTTON" "+jump"
bind "B_BUTTON" "+reload"
bind "X_BUTTON" "+use"
bind "Y_BUTTON" "phys_swap"

bind "L_SHOULDER" "+zoom"
bind "R_SHOULDER" "impulse 100"

bind "START" "pause"

bind "STICK1" "+speed"      // Right Stick Down
bind "STICK2" "+duck"       // Left Stick Down

```
[According to this article:](http://fr33man.altervista.org/HL2guida/HL2_7.htm)

> 
> 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.
> 
> 
>