im releasing a bit of my codebase that i think will be useful. it still has some stuff to be done, but hopefully it will make someones life easier.
here is my keymap setup which has support for gamepads and joysticks too. i plan to add the globalDict part and a method to change the key binds.
the goal is simplicity and flexibility. no complex blend setups or a pile of game properties to keep track of.
-to download, click the “source code (ZIP)” link
–copy the scripts from PY into your scripts folder or add them to your blend (make internal)
–edit line 28 in keymap.py:
—[import PY.input as input] replace PY with your folder
—[import input] if your scripts are internal/packed
never done this whole github thing before, so let me know if im doing it wrong
What I posted is just an API, which happens to be implemented with Python using the BGE API just as yours, and it’s trivial to port to BGE or implement from scratch on any other engine.
In fact, it’s the design that counts rather than its implementation, and it’s at that that linked rather than the code or the full addon.
I create a screen with game commands and ‘press any key’ after you activate it,
then when you press the button it saves the rule in a dictionary then it looks that up later when proccessing the input and spits out the gamecommand to the target agent
control = {eventString:[‘GameCommand’,index, playerTargetSlot] }
I take each of these and build a game command list per agent, and aort by index and then copy strings to a list if they are not in it, stripping doubles and serializing the list…
i could make a prefix to “BIND” to indicate which bind dictionary its stored in. like “BINDS.JUMP” or “SYS.PAUSE”. but the whole point of different dictionaries is to prevent some keys from being remapped.
if you wanted, you could make a branch with proposed code.
glad to hear it was easy to follow, that was a main goal.
for the sake of simplicity, all core classes and functions will be put in the input.py. otherwise it would mean more importing and trying to figure out what classes are where when building a keymap. plus, less files means easier to maintain and install.
im looking into starting a branch optimized for UPBGE. if someone is interested in helping out, that would be great. that someone would have alot of freedom to make changes in that branch.
also, in the near future im going to create a binds manager example blend so you can interact with the keybinds in game. you could even drop it next to your game and use the “start game from file” to easily snap it to your project.
Are you able to share the exact specifications of your project ?
If its about implementing your mapper class into the bge, I would not recommend it as I don’t think its general enough. Maybe make it an official side Python module ?
What is your goal ?
the goal is to make a setup thats easy to snap on to a project. nothing deep. i want it to make it simpler for newbies to get into python, while also providing something scalable to fit any project. less of an example and more like an asset. copy the files, import keymap, done.
ive even considered how to make it work with the keyboard sensor brick for those who like them. not likely to happen due to the complexity of the solution on the users end.
getting joysticks and gamepads to work in harmony with keyboard commands is the strongest point so far i think. not to mention JUST_ACTIVATED for gamepad buttons.
im new to this whole open source development stuff, so im open to suggestions, questions, and critics. not sure if the project is as simple to use as i think it is. with little in the way of feedback, its hard to advance with confidence.
work on the keymapping utility is moving forward. i have the visual elements all in place. some efficiency issues still need to be worked out on the code side of things.