hiddrv.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:sc-controller 作者: kozec 项目源码 文件源码
def _build_button_map(self, config):
        """
        Returns button  map readed from configuration, in format situable
        for HIDDecoder.buttons.button_map field.

        Generates default if config is not available.
        """
        if config:
            # Last possible value is default "maps-to-nothing" mapping
            buttons = [BUTTON_COUNT - 1] * BUTTON_COUNT
            for keycode, value in config.get('buttons', {}).items():
                keycode = int(keycode) - FIRST_BUTTON
                if keycode < 0 or keycode >= BUTTON_COUNT:
                    # Out of range
                    continue
                if value in TRIGGERS:
                    # Not used here
                    pass
                else:
                    buttons[keycode] = self.button_to_bit(getattr(SCButtons, value))
        else:
            buttons = list(xrange(BUTTON_COUNT))

        return (ctypes.c_uint8 * BUTTON_COUNT)(*buttons)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号