code: def _count_devices(self):
          
          number_of_devices = ctypes.c_uint()
  
          if ctypes.windll.user32.GetRawInputDeviceList(
                  ctypes.POINTER(ctypes.c_int)(),
                  ctypes.byref(number_of_devices),
                  ctypes.sizeof(RawInputDeviceList)) == -1:
              warn("Call to GetRawInputDeviceList was unsuccessful."
                   "We have no idea if a mouse or keyboard is attached.",
                   RuntimeWarning)
              return
  
          devices_found = (RawInputDeviceList * number_of_devices.value)()
  
          if ctypes.windll.user32.GetRawInputDeviceList(
                  devices_found,
                  ctypes.byref(number_of_devices),
                  ctypes.sizeof(RawInputDeviceList)) == -1:
              warn("Call to GetRawInputDeviceList was unsuccessful."
                   "We have no idea if a mouse or keyboard is attached.",
                   RuntimeWarning)
              return
  
          for device in devices_found:
              if device.dwType == 0:
                  self._raw_device_counts['mice'] += 1
              elif device.dwType == 1:
                  self._raw_device_counts['keyboards'] += 1
              elif device.dwType == 2:
                  self._raw_device_counts['otherhid'] += 1
              else:
                  self._raw_device_counts['unknown'] += 1
docs: See what Windows' GetRawInputDeviceList wants to tell us.
  
          For now, we are just seeing if there is at least one keyboard
          and/or mouse attached.
  
          GetRawInputDeviceList could be used to help distinguish between
          different keyboards and mice on the system in the way Linux
          can. However, Roma uno die non est condita.