code: def __read_device(self):
          
          state = XinputState()
          res = self.manager.xinput.XInputGetState(
              self.__device_number, ctypes.byref(state))
          if res == XINPUT_ERROR_SUCCESS:
              return state
          if res != XINPUT_ERROR_DEVICE_NOT_CONNECTED:
              raise RuntimeError(
                  "Unknown error %d attempting to get state of device %d" % (
                      res, self.__device_number))
          # else (device is not connected)
          return None
docs: Read the state of the gamepad.