360 controller interface in python

This forum is currently in read-only mode.
From the Asset Store
Small pixel icons for the 3 most popular controller types.
  • Hey all! Has anyone tried handling input from a Xbox360 controller in python? The analog sticks and triggers seem pretty straightforward, but I haven't been able to figure out how to get button presses (face buttons, shoulders, etc).

    Using the excellent Python Shell by Silent Cacophony I was able to locate the Xbox360Controller.ButtonState and XboxController360.IsButtonDown functions, but they both take a second mystery parameter that I'm unable to figure out (the first parameter, of course, being the controller index (non-zero based, incidentally)).

    All these return false:

    Xbox360Controller.ButtonState(controllerIndex, "B")

    Xbox360Controller.ButtonState(controllerIndex, "Button B")

    Xbox360Controller.ButtonState(controllerIndex, "Button_B")

    Has anyone had any success with either of these functions, or can someone point me to some documentation for the Xbox360Controller plugin?

    Thanks!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • [quote:2msn40p7]non-zero based, incidentally

    Perhaps the second parameter is.

    Cough, Boolean.

  • The best reference is just plain events. The first param is the controller (1-4).

    With the "control is down" condition, param 2 is a combo box to select a button. Parameters that were combos in the events are an index in python, 0 for the fist line and so on. "Button B" would be 13. I imagine it works the same way with "ButtonState" but since I don't have a controller I can't test it.

    So this should test button B on controler 1:

    Xbox360Controller.ButtonState(1, 13)

  • Brilliant! That worked perfectly, R0J0 - I'll file that bit of knowledge away for future use.

    For anyone else who's curious about the specifics:

    Xbox360Controller.ButtonState(1, 13) returns 1.0 if B is pressed on controller 1, 0.0 otherwise.

    Xbox360Controller.IsButtonDown(1,13) returns True if B is pressed on controller 1, False otherwise.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)