Closed HuntClauss closed 2 years ago
Thank you for your contribution, but custom keyboard shortcuts are already beeing worked on by @MrApplejuice. See: https://github.com/mbrlabs/Lorien/discussions/144. I'll leave this open for now though.
Hey @MrApplejuice, you were right, ConfigFile supports Arrays so I fixed that, and now multiple bindings per action work. I had to add a prefix to every shortcut: KB:
representing keyboard and JOY:
representing joypad, but I think this shouldn't be a problem.
Edit: I created config in a way that allows manual modification by the user directly in the file, for this reason, each button is turned into an easy to read string. Currently, I think this approach doesn't make sense because the user will modify the shortcuts through the GUI anyway, but I would like to hear other people's opinion on this
I think this is everything for now. I hope you find this useful.
Thank you for your suggestions, godot is totally new for me so I appreciate every help :-)
Persistence-wise i probably would have done it the same: Shortcuts section in settings.cfg
, and then a list of actions. Basically like this (simplified):
[shortcuts]
save_project = [InputEvent("CTRL+S")]
undo = [InputEvent("CTRL+Z"), "..."]
As for how to serialize the key combinantions: just let Godot do it (InputEvent is a Resource, so that should be no problem). It's less readable then a custom format, but it's still possible if you want to debug/check something by reading or changing the file directly. For example a single-event action would look like this:
shortcut_undo=[ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,
"alt":false,"shift":false,"control":true,"meta":false,"command":true,"pressed":false,"scancode":90,
"physical_scancode":0,"unicode":0,"echo":false,"script":null) ]
In order to save it like this you can just pass in the array of InputEvents into the set_value method of the ConfigFile. Serialization & deserialization is automatic.
Thanks!
This is just a simple/primitive implementation of custom shortcuts. For now, editing shortcuts can be made only via settings.cfg file.
There is problem with some combination of shortucts (like Control+[key] and Control+Shift+[key]), because godot don't check other shortcuts if overlap. I found this about possible solution.
(I know almost nothing about godot so I am really sorry if I did something wrong.)