コード例 #1
0
    def open(self, stick=0):
        if self.joystick:
            self.close()

        try:
            self.joystick = SDL_JoystickOpen(stick)
        except Exception as err:
            log.warn(str(err))

        if self.joystick:
            self.num_axes = SDL_JoystickNumAxes(self.joystick)
            self.num_buttons = SDL_JoystickNumButtons(self.joystick)
            self.num_hats = SDL_JoystickNumHats(self.joystick)
            self.num_trackballs = SDL_JoystickNumBalls(self.joystick)

            for i in range(self.num_axes):
                self.axes[i] = SDL_JoystickGetAxis(self.joystick, i)
                self.axis_repeat_timers[i] = QTime()
                self.deadzones[i] = self.joystick_deadzone
                self.sensitivities[i] = self.joystick_sensitivity

            for i in range(self.num_buttons):
                self.buttons[i] = SDL_JoystickGetButton(self.joystick, i)
                self.button_repeat_timers[i] = QTime()

            for i in range(self.num_hats):
                self.hats[i] = SDL_JoystickGetHat(self.joystick, i)
                self.hat_repeat_timers[i] = QTime()

            self.clear_events()
            self.joystick_timer.start(self.event_timeout)
            return True
        else:
            log.warn("couldn't open SDL joystick #%d", stick)
            return False
コード例 #2
0
    def open(self, stick=0):
        if self.joystick:
            self.close()

        try:
            self.joystick = SDL_JoystickOpen(stick)
        except Exception, err:
            log.warn(str(err))