【发布时间】:2017-05-15 15:14:02
【问题描述】:
我希望能够独立检测扳机拉动,但扳机似乎共享一个轴。
我在 MSDN 文档中没有看到有关 Xbox One 控制器的任何内容,但对于 Xbox 360 控制器,DirectInput 触发器共享轴,而 XInput 为每个触发器提供单独的轴。这表明 pygame 使用的是 DirectInput 而不是 Xinput,但我不知道如何强制 pygame 使用 Xinput。
(如何)我可以强制 pygame 使用 xinput 而不是直接输入? 如果这真的不可行,我愿意使用不同的语言。
我正在使用这个脚本从控制器读取输入:
import pygame
pygame.init()
screen = pygame.display.set_mode((400,400))
joysticks = []
for i in range(0, pygame.joystick.get_count()):
joysticks.append(pygame.joystick.Joystick(i))
joysticks[-1].init()
while True:
for event in pygame.event.get():
print event
编辑:我现在没有时间完整地写出来,但与此同时,我发现这段代码似乎对我有用(在 Xbox One Spectra 控制器上):https://github.com/r4dian/Xbox-360-Controller-for-Python
【问题讨论】: