예제 #1
0
    def test_is_controller(self):
        for i in range(controller.get_count()):
            if controller.is_controller(i):
                c = controller.Controller(i)
                self.assertIsInstance(c, controller.Controller)
                c.quit()
            else:
                with self.assertRaises(pygame._sdl2.sdl2.error):
                    c = controller.Controller(i)

        with self.assertRaises(TypeError):
            controller.is_controller('Test')
예제 #2
0
    def test_from_joystick(self):
        for i in range(controller.get_count()):
            if controller.is_controller(i):
                joy = pygame.joystick.Joystick(i)
                break
        else:
            self.skipTest("No controller connected")

        c = controller.Controller.from_joystick(joy)
        self.assertIsInstance(c, controller.Controller)
예제 #3
0
 def _get_first_controller(self):
     for i in range(controller.get_count()):
         if controller.is_controller(i):
             return controller.Controller(i)