Half-Life 2: Episode 2, Portal, Team Fortress 2, and Left 4 Dead have their own built-in configuration for the XBOX 360 controller. To use this configuration, simply open the console and type exec 360controller then press enter. For more information on enabling and using the console, please see the Console article.
These games use special joystick interface configurations that may interfere with the usability of the keyboard and mouse - if you wish to undo these configuration changes, there is a second configuration file you may run by opening the console and typing exec undo360controller then pressing enter.
If you wish to customize the configuration, or use one of these configurations with Half-Life 2 or Half-Life 2: Episode One, you will need to create your own copy in a text editor (such as Notepad) modifying the default settings below and save it as something different (such as joystick.cfg), then place it in the \cfg\ folder inside the game's directory, which uses the following basic structure:
\Steam\steamapps\\\\cfg\
Windows PCs: \Steam\ is located in C:\Program Files\ by default.
Mac OS X: /Steam/ is located in ~/Library/Application Support/ by default.
The configuration file's contents are offered below for use in Half-Life 2 and Half-Life 2: Episode One, or for customization purposes; game-specific configurations are noted and should be left out when using in a different game. Please see the Configuring a Joystick or Gamepad for Source article for customization information.
//**************************************************
//Joystick configuration for XBOX 360 controllers
//**************************************************
joy_name "Xbox360 controller"
joy_advanced 1
joy_advaxisx 3
joy_advaxisy 1
joy_advaxisz 0
joy_advaxisr 2
joy_advaxisu 4
joy_advaxisv 0
joy_forwardsensitivity -1
joy_sidesensitivity 1
joy_pitchsensitivity 1.0
joy_yawsensitivity -1.25
joy_autoaimdampenrange 0.85
joy_autoaimdampen 0.5
joy_lowend 0.65
joy_lowmap 0.15
joy_accelscale 1.4
joy_response_move 5
joy_response_look 1
joyadvancedupdate
crosshair 0
hud_draw_fixed_reticle 1
+jlook
//**************************************************
//Half-Life 2 and Episodes, Portal specific settings
//**************************************************
bind "Z AXIS POS" "+attack2"
bind "Z AXIS NEG" "+attack"
bind "JOY1" "+jump"
bind "JOY2" "+reload"
bind "JOY3" "+use"
bind "JOY4" "impulse 100"
bind "JOY5" "+speed"
bind "JOY6" "phys_swap"
bind "JOY7" "impulse 50"
bind "JOY10" "+zoom"
bind "JOY9" "toggle_duck"
bind "JOY8" "pause"
bind "POV_UP" "slot1"
bind "POV_RIGHT" "slot2"
bind "POV_DOWN" "slot3"
bind "POV_LEFT" "slot4"
joystick 1
sk_autoaim_mode 2
hud_fastswitch 2
player_limit_jump_speed 0
All presented in this Steam article.