Input source types are not pure bit flags, they are combinations of flags, so != 0 check was incorrect and resulted in crashes later, when trying to obtain the device.