Note: This feature is present in tools revision 16. It is a bit rough regarding setup and we'd love feedback.
For a realistic sensor emulation, the emulator uses a connection with an actual Android device running the SdkControllerSensor application. The application monitors changes in the sensors on the device, and transmits them to the emulator. The emulator then injects those changes into the guest system image. This requires Android 4.0, system image revision 2.
The SdkControllerSensor application source code is located in $SDK/tools/apps/SdkController/
ADB port forwarding is used for the data transfer between the device and the emulator.
Here is how you enable sensor emulation:
Note that port forwarding between the host and the device can be fragile. If you see that sensor events have stopped in the emulator, run the adb forward tcp:1968 tcp:1968 command again. This should restore the connection.