joystick.py 文件源码

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

项目:hacked_cnc 作者: hackerspace 项目源码 文件源码
def run(self):
        import pygame

        os.environ["SDL_VIDEODRIVER"] = "dummy"
        pygame.init()
        pygame.joystick.init()
        done = False
        while not done:
            # reinnitialize the joystick every loop, this is so if the contoller is turned
            # on after the loop starts, it can still be read

            #joystick_count = pygame.joystick.get_count()
            joystick = pygame.joystick.Joystick(0)
            joystick.init()
            for event in pygame.event.get():
                if event.type == pygame.JOYBUTTONDOWN:
                    self.button_down.emit(event.button)
                elif event.type == pygame.JOYAXISMOTION:
                    self.axis_moving.emit(event.axis, event.value)

            time.sleep(0.2)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号