#

### Input Cleanup and Fixes

This episode starts with some cleanup and fixes to the input handling code from yesterday.

- Windows API often uses a `0` return value to indicate success. Our stubs probably shouldn't return `0`.
- Windows 8 ships with `xinput1_4.dll` only. So we need to try each version in turn
- When you handle WM_SYSKEY* messages, you lose built in Alt-F4 functionality, and have to reimplement it.

### Sound Programming for Games

Casey starts with a high level overview of sound programing for games. The key ideas here are that we are allocating a circular buffer for sound, and the system will play it continually on a loop. If you haven't worked with circular buffers (or ring buffers) before, much of this code will be confusing. It's worth taking some time to familiarize yourself with them.

Resources:

- Ring Buffers on "Learn C The Hard Way"

### Working with DirectSound

The basic process for initializing DirectSound is as follows:

1. Load the Library - `LoadLibrary``("dsound.dll")`
2. Create a DirectSound object - `DirectSoundCreate()`
3. Set the Cooperative Level - `IDirectSound8::SetCooperativeLevel()`
4. "Create" a primary buffer - `IDirectSound8::CreateSoundBuffer()`
5. Create a secondary buffer
6. Tell DirectSound to start playing the secondary buffer - `IDirectSoundBuffer8::Play()`

In the next episode we will look closely at how to fill this buffer and implement it in the game loop.