示例#1
0
    def _init_hats(self):
        """Retrieves all hats present on the vJoy device and creates their
        control objects.

        A single device can either have continuous or discrete hats, but
        not both at the same time.

        :returns list of Hat objects
        """
        hats = {}
        # We can't use discrete hats as such their existence is considered
        # an error
        if VJoyInterface.GetVJDDiscPovNumber(self.vjoy_id) > 0:
            error_msg = "vJoy is configured incorrectly. \n\n" \
                    "Please ensure hats are configured as 'Continuous' " \
                    "rather then '4 Directions'."
            logging.getLogger("system").error(error_msg)
            raise VJoyError(error_msg)
        # for hat_id in range(1, VJoyInterface.GetVJDDiscPovNumber(self.vjoy_id)+1):
        #     hats[hat_id] = Hat(self, hat_id, HatType.Discrete)
        for hat_id in range(
                1,
                VJoyInterface.GetVJDContPovNumber(self.vjoy_id) + 1):
            hats[hat_id] = Hat(self, hat_id, HatType.Continuous)
        return hats
示例#2
0
def hat_configuration_valid(vjoy_id):
    """Returns if the hats are configured properly.

    In order for hats to work properly they have to be set as continous and
    not discrete.

    Parameters
    ==========
    vjoy_id : int
        Index of the vJoy device to query

    Returns
    =======
    bool
        True if the hats are configured properly, False otherwise
    """
    continuous_count = VJoyInterface.GetVJDContPovNumber(vjoy_id)
    discrete_count = VJoyInterface.GetVJDDiscPovNumber(vjoy_id)

    return continuous_count >= discrete_count