Hi All, I have downloaded the latest UPBGE and none of my USB joysticks work at all. I have not tried to use the joystick function since Blender 2.79. I had no luck getting this to work with true variable function for use in flight sim type programs. With the older Game engine my joysticks worked but only in digital or ON/OFF mode. This time, I would like to use my USB joystick, and a model R/C transmitter (6 channel Flysky) which also has it’s own USB output port.
It seems like something has to be initialized first to read the joysticks. Could some kind person please explain how to do this, or point me to an existing link. I’m 75 years of age now, so things take a little longer to figure out. However, I still enjoy playing with stuff, so I would really appreciate some help. Thanks.
Keith R
Analog joystick axes can only be used with Python (or logic nodes).
But there is an extra problem with Controllers other than Gamepads.
UPBGE makes usage of a file called gamecontrollerdb.txt created by an online community which only allows gamepads and no Flightsticks or other USB-Controllers.
So to use a Flightstick you must edit this file located in the directory datafiles/gamecontroller.
There you can add your own configuration.
To create a configuration you must use some external tools.
This is all quite fiddly you see.
But I managed to get my Microsoft Sidewinder ForceFeedback 2 Joystick working and also a virtual Joystick for HeadTracking.
Some more infos here:
Thanks very much Musukai. It looks like I need to just bite the bullet and learn how to use Python in Blender. I do programming with PIC chips for some years now, so I guess that I can learn this too.
O.K. so I went back 2.79 for my project and then I “cheated” by asking Chat GPT for a Python script and how to implement it. After trying a few options, it works like a charm on my Flysky R/C Tx. I am now able to modify the code myself to suit my program. If anyone is interested, I can post the script and how to use it in the Logic blocks. I will also try the same method (Chat GPT) on UPBGE soon.
Would be interesting to see the code.
For UPBGE you need to get the SDL mapping of the usb-controller and add it to the gamecontrollerdb.txt as stated in the above link.
To get the SDL mapping you can use one of these tools:
or
The most important part is the long id number at the start called SDL GUID. This is what recognizes the controller.
Once you have added it you can test it eg. with this basic blend-file (UPBGE 0.36 and higher):
036_Joystick_analog.blend (909.8 KB)
Thanks very much. I will try your suggestions shortly. Here is my script for 2 analog channels for my project:
import bge
cont = bge.logic.getCurrentController()
obj = cont.owner
joy = cont.sensors[“Joystick”]
if joy.connected:
steer = joy.axisValues[1] / 32767.0
throttle = joy.axisValues[2] / 32767.0
# Only allow forward throttle
throttle = throttle + 0.99
deadzone = 0.0
if abs(steer) < deadzone:
steer = 0
if abs(throttle) < deadzone:
throttle = 0
# Steering
obj.applyRotation([0, 0, steer * 0.04], True)
# Forward / Reverse
obj.applyMovement([throttle * -0.015, 0, 0], True)
Here’s is a pic of the logic blocks:
Yes, that’s regular code using sensors.
So original Blender 2.79 joystick support was more compatible than UPBGE’s use of sdl.
The same code would work in UPBGE, once you managed to get your controller recognized.
I downloaded your test Blender file and the SDL Gamepad Tool, but it does not recognize my usb R/C Tx as a gamepad. I don’t understand your comment about the long id number at the start called the SDL GUID. I also downloaded AntiMicrox but have no clue how to install/run it. If you could explain this, I would appreciate it. Thanks.
I think the gamepad tool is easier to work with than the antimicroX thing.
Your Controller is no gamepad but the tool can be used to make mapping so programs will recognize it as a gamepad.
It should be possible to click on “Create new mapping”, then you are asked to press buttons and move axes for assigning them to specific gamepad buttons and axes. You can skip unneeded ones.
At the end it will show the mapping code.
This code begins with the long GUID then the name, then assignements for buttons and axes.
The GUID is the ID of the controller. All other entries can also be changed by hand afterwards if you want.
For my Microsoft Flightstick the mapping looks like this.
030000005e0400001b00000000000000,SideWinder Force Feedback 2 Joystick,platform:Windows,a:b7,b:b4,x:b6,y:b5,leftshoulder:b2,rightshoulder:b3,leftstick:b0,rightstick:b1,leftx:a2,lefty:a3,rightx:a0,righty:a1,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,
This mapping can be added into the text-file “gamecontrollerdb.txt” in the UPBGE data folder.

