MP1-4585: Fixing support for background handling of HID events. Doing some minor win32 clean-up too.