I'd like to be able to detect trigger pulls independently, but the triggers appear to share a single axis.
I didn't see anything on Xbox One controllers in the MSDN docs, but for Xbox 360 controllers, DirectInput triggers share the axis, and XInput gives separate axes to each trigger. This suggests that pygame is using DirectInput rather than Xinput, but I don't know how to force pygame to use Xinput instead.
(How) can I force pygame to use xinput instead of direct input? If this is not really feasible, I'd be willing to use a different language.
I am using this script to read input from the controller:
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
EDIT: I don't have time at the moment to write this out in full, but in the meantime, I found this code which appears to work for me (on an Xbox One Spectra controller): https://github.com/r4dian/Xbox-360-Controller-for-Python
First:
From https://en.wikipedia.org/wiki/DirectInput#DirectInput_vs_XInput:
Second:
So
pygame
can haveXInput
support ifSDL
has. Sadly,SDL
don't has. The reason is what I wrote before,DirectInput
is more popular. Also check out: http://forums.libsdl.org/viewtopic.php?t=6352&sid=35bdc1b1615f9ea081671ff548a7e360You can still write a wrapper around
XInput API
, if you want to.EDIT:
The repo you linked in uses ctypes to create a wrapper around the XInput API.