You certainly already have your own keyboard sensors already, these should represent âhigh level actionsâ.
What I mean is your sensor shouldnât be named âWâ for the âWâ key, but maybe âForwardâ. You would do that for most actions in your game where you need a button to trigger the action.
Then you need a Python script that would allow you to edit the keys your sensors are listening to while your game is running. I can only recommend to start learning basics of Python and how to edit the sensorâs configuration.
Because if you want to be able to configure game controls, you will have to write that logic yourself
Is there no template to use for a control pad, what control pad can be used? USB type one? I have one myself only the direction buttons work and a number of others so x, circle, square and triangle, like an old PS2 control pad.
(Original) Xbox 360 controllers (2x)
(Logitech) PS3 controller
All controllers should work with BGE / UPBGE joystick inputs (Logic_Brick or Python)
There really isnât a guide to all the joystick input numbers, their all different in someway.
There is one major bug tho (it might be fixed in UPBGE)
The bug is joystick input not being received by Blender when game is played in the 3D View-Port.
Joysticks always work fine in Blenderplayer tho.
bge.logic.joysticks gives you a list of slots each containing a joystick object if one is available at that index else none. At init, I run a loop over it like so to get whichever slot I got mine plugged into.
from bge.logic import joysticks
joy_index = -1
for i, stick in enumerate(joysticks):
if stick:
joy_index = i
break
joy = joysticks[joy_index]
Now that you have a reference to the thing, you can get a list of indexes for pressed buttons. Print it to console, it spits out a number from 0 to number of buttons on your joystick. This integer represents that button, you can use it to check for that particular input.
butts = joy.activeButtons
if butts:
print(butts)
if 0 in butts: print("X on a ps2 controller")
Then you just write down which one is which or whatever.
Unavoidable pain in the arse as it is, youâre gonna have a hard time doing this kind of thing without any programming knowledge.
I havenât been very successful with the game engine, I wanted to do more than I have, I was lucky to get some help from a number of users here, who helped me out with programming, and brick programming.
I guess, the first step is to get one button to move a character. At the most, I would need perhaps four buttons. If it is possible to close the game, then five. One button would be for an alterntive camera view.
A current file I am messing with not related to my released couple of files, may require some kind of camera change or targeting system, otherwise the FP canât see the AI, or much.
bge.logic import joysticks
joy_index = -1
for i, stick in enumerate(joysticks):
if stick:
joy_index = i
break
joy = joysticks[joy_index]
butts = joy.activeButtons
if butts:
print(butts)
if 0 in butts: print(âX on a ps2 controllerâ)
joy.activeButtons is a list of active inputs. Here Iâm just assigning it the name butts and totally not what you think, itâs just short for buttons.
if joy.activeButtons: #the list has values; i.e. it's not empty
if 0 in joy.activeButtons: #joystick button nÂș 0 is pressed
#put your logic for this button press here
if 1 in joy.activeButtons: #joystick button nÂș 1 is pressed
#same as before
And so on, up to total number of buttons on your pad.