Joystick Issue


I am having a strange problem. For some reason this script is acting like I’m using two different joysticks. Even though I’m specifying joysticks[0] every time, I’m having to use two joysticks to interact with the object. 1 joystick for button input and one for 1 joystick for axis/sticks. Have I found a bug? Does anyone else have the same thing happen in blender 2.74? I’m using two official xbox controllers with Windows 7 64 bit.

Does anyone have an idea of what the problem might be?

import bge
from bge import logic

cont = bge.logic.getCurrentController()

own = cont.owner

if 11 in logic.joysticks[0].activeButtons:
if 12 in logic.joysticks[0].activeButtons:
if logic.joysticks[0].axisValues[0] > 0.5:
elif logic.joysticks[0].axisValues[0] < -0.5:

Edit: I’ve updated the blend for two players, so the problem is more visible.


JoystickTestblend.blend (477 KB)

What happens if only one joystick is connected?
It might be (and, having not looked at the source recently, I can only speculate) that the returned sequence for logic.joysticks is not ordered, and hence if you have > 1 joystick connected it returns different ones on successive calls, though, I doubt this is the case.

Unfortunately, as I do not have a joystick with me, I cannot provide any testing of your file, though thanks for providing it.

It works as expected. The problem is, I’m working on a local multiplayer game, so I need multiple joysticks to work. Maybe there is another way of doing this. It works fine in blender 2.71.

Ah, I recall some commits towards joysticks recently, this may well be a regression then.

I have issue with Official 2.74 too… The joystick is jumpy and not smooth and jumpy when multiple event triggered eg: twist, axis, thruster. It was smooth with 2.73. (standalone player, where embedded player failed).

The new SDL2 library uses a new XInput (in Windows) library for Joysticks. This new XInput provoques several issues. I’m trying to use the new SDL_GameController API that seems to solve all these related issues.

I guess that you are using windows, isn’t it?

I am using windows, yes.

How would I go about using the new SDL_GameController API?