There are two ways to find out whether input data is available: by polling and by event notification.
Polling a device means regularly getting the current state of the device objects with IDirectInputDevice::GetDeviceState or retrieving the contents of the buffer with IDirectInputDevice::GetDeviceData. Polling is typically used by real-time games that are never idle but are constantly updating and rendering the game world.
Event notification is suitable for applications like the Scrawl sample that wait for input before doing anything. To use event notification, you set up a thread synchronization object with the Win32 CreateEvent function and then associate this event with the device by passing its handle to the IDirectInputDevice::SetEventNotification method. The event is then signaled by DirectInput whenever the state of the device changes. Your application can receive notification of the event with a Win32 function such as WaitForSingleObject, and then respond by checking the input buffer to find out what the event was. For sample code, see the Scrawl sample and the reference for IDirectInputDevice::SetEventNotification.
Some joysticks and other game devices, or particular objects on them, do not generate hardware interrupts and will not return any data or signal any events until you call the IDirectInputDevice2::Poll method. To find out whether this is necessary, first set the data format for the device, then call the IDirectInputDevice::GetCapabilities method and check for the DIDC_POLLEDDATAFORMAT flag in the DIDEVCAPS structure.
Do not confuse the DIDC_POLLEDDATAFORMAT flag with the DIDC_POLLEDDEVICE flag. The latter will be set if any object on the device requires polling. You can then find out whether this is the case for a particular object by calling the IDirectInputDevice::GetObjectInfo method and checking for the DIDOI_POLLED flag in the DIDEVICEOBJECTINSTANCE structure.
The DIDC_POLLEDDEVICE flag describes the worst case for the device, not the actual situation. For example, a HID mouse with software-controllable resolution might be marked as DIDC_POLLEDDEVICE because reading the resolution information requires polling. Polling the device under these conditions is pointless if all you want is the standard button and axis data.
Nonetheless it doesn't hurt to call the IDirectInputDevice2::Poll method for any input device. If the call is unnecessary, it will have no effect and will be very fast.