Use X360 Controller in Blender Add-on

I’m new to Python and scripting in Blender, but I do have extensive knowledge of other programming languages (including C# and Java). I’ve spent the past few days reading up on the Blender API and scripting capabilities, and I believe that what I want to do is possible. I just don’t know how/where to start.

Short version: I want to be able, in my module, to read input from an XBox 360 gamepad. (How) can I access this from a Blender Add-on?

I’ve already done the basic tutorial about setting up, registering and installing an add-on, and from what I’ve seen I expect to define keymaps for the gamepad. However, I don’t know how to access the (events fired by) the gamepad. Searching the internet has yielded no results for me, unfortunately.

If you are working with the game engine, then it already supports gamepads though SDL and the ‘joystick’ sensor and ‘bge.logic.joysticks’ variables.

If you want to use the gamepad in Blender proper, then I would recommend looking at how the BGE accesses the joystick data though SDL and see if you can use that as a starting point.