linusg / xbox360controller

🎮 A pythonic Xbox360 controller API built on top of the xpad Linux kernel driver
MIT License
96 stars 17 forks source link

Xbox One #15

Open binaryhellstorm opened 4 years ago

binaryhellstorm commented 4 years ago

Trying this with the Xbox One bluetooth controller and it seems to be reading the B and X keys as axis.

linusg commented 4 years ago

Don't have one of those so I can't confirm or fix this issue :shrug:

PR welcome, though I'm not really interested in adding support for multiple controllers.

xboxone08 commented 4 years ago

Please add support for Xbox One, or make a module for that with a similar interface. This is the easiest to use module I've found, but it only supports Xbox 360.

linusg commented 4 years ago

@xboxone08 I appreciate it, but again, I don't have the required hardware (Xbox One controller) for testing so that's no going to happen.

wullxz commented 4 years ago

@xboxone08 I'm using linusg's work as base to use my Xbox One Wireless controller (using xpadneo driver). It doesn't "know" the Trigger Axis though when used "normally". I can get values from them by using the Raw mode though.

Try this code snippet and see if the output shows you something useful:

import signal
from xbox360controller import Xbox360Controller

def on_button_pressed(button):
    print('Button {0} was pressed'.format(button.name))

def on_button_released(button):
    print('Button {0} was released'.format(button.name))

def on_axis_moved_raw(axis):
    print('Axis {0} moved to {1}'.format(axis.name, axis.value))

try:
    with Xbox360Controller(0, axis_threshold=0.2, raw_mode=True) as controller:
        # Button events
        for b in controller.buttons:
            b.when_pressed = on_button_pressed
            b.when_released = on_button_released

        for a in controller.axes:
            a.when_moved = on_axis_moved_raw

        signal.pause()
except KeyboardInterrupt:
    pass