Analog joystick support?

I’ve been looking at moving a project I started with another “non-programmer friendly” game engine over to Blender, but one of my concerns was joystick support. I’ve learned that Blender GE now supports “digital” joysticks (basically on - off commands only), but that really don’t work well when trying to drive or steer a vehicle in a 3D simulator type game.

Searching the forum here, the only answer I found was that the interface would have to be programmed in Python, perhaps with PyGame, but I didn’t find any samples or further help.

I recently ran into this thread on the GameBlender forum:

which has given me new hope of using Blender for my simulator. I haven’t tried this yet (I hope to later today), but has anyone else tried this method or any other for “analog” control in Blender Game Engine? Are there any sample files I can look at to see how it is done?

Thanks very much!

using python it is possible to get the position along a particular axis, but I don’t have the code handy at the moment [or a joystick to test it with]

Thanks! I had looked for it, but didn’t find it before :smiley: . The joystick sensor has a function getAxisValue() that returns an array with values of the axes.
I made a quick test with a script that calls this function and shows the values of the x and y axes as debug info:

I just gave this a try and it definitely works. It would take fair number of logic blocks to make it behave even remotely like an analog joystick (perhaps 3 or 4 “steps” in each direction?), but it works and it didn’t require any programming at all.

Lauens - I’m going to give your blend a try next, thanks!

Ahhh… now we’re getting somewhere :wink: I see what you’re doing, but since I’m not a programmer, I don’t know how to make this “move” my object. But it does show me just how short the code can be to access the joystick using Python.

Are there other joystick functions (I’m guessing there must be) and where can I find their documentation?


I didn’t find the joystick sensor in the docs on I found what I needed from the source files of the blender game engine:

I hope it gets some proper documentation some day :-? .

The other functions do basicly the same as what you can do with the joystick sensor logic brick.

Thanks Lauens,

I found these joystick functions in your link:


Now all I have to do is learn how to use them :wink:

I have been requesting analog steering for quite a while, and the other day, I managed to get a sort of “psuedo-steering” by using the later versions that have the ON/OFF joystick function in the logic sensors. You will see that there is a threshold setting, so just set ascending trigger points, and you can the link this to a steering function. I use dRot plus a forward motion, and I can steer fairly well. Even if you use about 6 steps each way, it looks reasonably smooth. The numbers for the threshold points are in the thousands. and are not linear. Set the first point at around 2000 or so if you need a dead zone around the centre. After that just try different numbers and see how it suits your program. The highest number is around 32000.

I also don’t know how to program, so this is a good compromise. Enjoy, and thanks to all for the other links. I’ll have a look at them.

Keith R


The method you describe and the link in my first post are the same. Works fine for me, too. Bottom line: analog joystick steering in Blender Game Engine without programming -IS- possible. Yippee! :smiley:

Yup, you are right. I somehow missed that one before. I’m pretty sure that snailrose, Erwin etc. can sort out the logic bricks to do this a lot better, but for now this at least allows us to start getting our sims working. I am also hoping that the guys can sort out the “jerky” motion, or flickering when you use the latest versions that can read joysticks. The old 2.25 still has the best GE when it comes to making the runtime. It makes the smallest files, and does not require the end user to add the extra python files.

Anyway, so far Blender is still awesome and can only get better.

Keith R

The old 2.25 still has the best GE when it comes to making the runtime.
I keep on seeing this comment in this forum. Should I forget about using 2.37 (or even 2.41) and go back to 2.25?

I don’t think so, because some of the new features in the later versions are really good. I use the animation stuff as well for video production, so the new features are awesome. I mainly use 2.34, and then create the runtime with 2.25, but it’s only for ver. 2.37 that the sensor for the joysticks work. The bottom line is that we need to learn Python to get into the real nitty-gritty of just how useful Blender can be. All of the other game engines require programming, and then compiling. Blender spoils us by allowing us to do some work and simply hit the P button to see direct results. Basically I think think that there is still enough interest globally to continue with developing the game engine, so we need to just hang in there and help in any way that we can.

Keith (apologies for the delays in these replies, but I’m still on a dial-up system in South Africa)

I just downloaded 2.41 and tested some of the demos… very cool in deed. I’m going to try to create my current project in 2.41 and see how it goes. When or if I run into problems with 2.41 that I can’t resolve, then I’ll worry about using something else, but for now 2.41 looks like the way to go.

BTW I’m also on a dial up, no need to apologise :wink:

hehe, I saw this and thought it was really interesting.

Anyone know who created the joystick sensor? It’s missing 1 key important thing. The keyboard sensor has an “all keys” thing you can click, so in python you can practically read in whatever key was pressed.

However, the joystick button doesn’t have “all buttons” so you would literally need tons of joystick sensors. I haven’t tried or know how to code in the GE source so :smiley: it would be great if we could find the person and have him/her code it in.

Jason Lin

… and it also doesn’t have sensors for the “twist” and “throttle” on many joysticks & gamepads. From the list I posted earlier, it appears they aren’t accessable through the API either. Would be nice if it did.

Still, something’s better 'n nothing :wink:

My old cheapo joystick doesn’t have twists and throttles :stuck_out_tongue: , but I can imagine that for example the throttle is just another axis which you can read with python.
An “any joystick button/axis”-event for the sensor would definitely be welcome!

Btw. does anyone know how to get the minimum/maximum value that an axis can get?