Hi everyone,
I’ve written this little InputHandler to simplify the use of Keyboard and Gamepad.
The main reason i’ve wrote this is because the gamepad hasn’t someting like just_released build in and i had to write it everytime again.But now this script supports a little bit more.
Usage:
import bge,Input
player_input = Input.InputHandler()
print(player_input.Key("jump",bge.logic.KX_INPUT_ACTIVE))
Now you get no matter if the keyboard or the gamepad “jump” button or one of the button group is pressed.
The idea is that you have a dictionary where you define an action bind to an/multiple Keys.
{
"gamepad":{
"jump": "a",
"sprint":{
"key1":"lstick",
"key2":"r2"
}
},
"keyboard": {
"jump":32,
"sprint":{
"key1":129
}
}
}
This dict is saved as json.
And because every gamepad has other mapping there is also a json dict for every controller where you can also define things like deadzone,inverted and strenght of an axis.
All those (at the beginning two ) files are saved to a subfolder of your blend named Keyconfig(you can also change the location for example when you create it )
If there is no such folder when init it will create it with the needed files.
I plan on writting an api for it but this will propably need a few days.
Hereis the module:
Tesed with blender 2.71
You can use/edit this however you want.
It would be nice if you tell me what you think or this should need.