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:
As of 2011
XInput
is forXbox 360
controllers, whileDirectInput
is for any controller
Second:
Pygame is an SDL binding.
So pygame
can have XInput
support if SDL
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=35bdc1b1615f9ea081671ff548a7e360
You 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With