小编SGo*_*olt的帖子

Pygame Joystick.get_axis() 总是返回零

我买了一个罗技 Gamepad F310 来远程控制机器人。我在 Linux Mint(版本 18,Sarah)上使用 Pygame(版本 1.9.1,Python 版本 2.7.11+)。

作为检查操纵杆功能的简单测试,我编写了这个简短的脚本来输出不同轴的值:

import pygame

pygame.display.init()
pygame.joystick.init()
pygame.joystick.Joystick(0).init()

# Get the name of the joystick and print it
JoyName = pygame.joystick.Joystick(0).get_name()
print "Name of the joystick:"
print JoyName

# Get the number of axes
JoyAx = pygame.joystick.Joystick(0).get_numaxes()
print "Number of axis:"
print JoyAx

# Print the values for the axes
pygame.event.pump()
print pygame.joystick.Joystick(0).get_axis(0)
print pygame.joystick.Joystick(0).get_axis(1)
print pygame.joystick.Joystick(0).get_axis(2)
print pygame.joystick.Joystick(0).get_axis(3)
Run Code Online (Sandbox Code Playgroud)

无论我运行脚本时轴的位置如何,我总是得到以下输出:

import pygame

pygame.display.init()
pygame.joystick.init()
pygame.joystick.Joystick(0).init()

# Get the name of the …
Run Code Online (Sandbox Code Playgroud)

python pygame zero joystick logitech

5
推荐指数
1
解决办法
5755
查看次数

标签 统计

joystick ×1

logitech ×1

pygame ×1

python ×1

zero ×1