From a9de3771e304d6cc23e7e0f435b5201743726384 Mon Sep 17 00:00:00 2001 From: Insality Date: Sun, 17 Oct 2021 16:55:23 +0300 Subject: [PATCH] #112 Add allow remap default Druid input bindings --- README.md | 19 +++++++++++++++++++ docs_md/changelog.md | 1 + druid/const.lua | 20 ++++++++++---------- game.project | 10 ++++++++++ 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d76286f..02b1be4 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,25 @@ Or point to the ZIP file of a [specific release](https://github.com/Insality/dru ![](media/input_binding_1.png) +### Change key bindings [optional] +If you have to use your own key bindings (and key name), you can change it in your *game.project* file. + +Here is current default values for key bindings: +``` +[druid] +input_text = text +input_touch = touch +input_marked_text = marked_text +input_key_esc = key_esc +input_key_back = key_back +input_key_enter = key_enter +input_key_backspace = key_backspace +input_multitouch = multitouch +input_scroll_up = scroll_up +input_scroll_down = scroll_down +``` + + ### Input capturing [optional] By default, **Druid** will auto-capture input focus, if any input component will be created. So you don't need to call `msg.post(".", "acquire_input_focus")` diff --git a/docs_md/changelog.md b/docs_md/changelog.md index 8cfb9ca..30a3391 100644 --- a/docs_md/changelog.md +++ b/docs_md/changelog.md @@ -212,3 +212,4 @@ Have a good day. - If true - Static Grid will by always align to content anchor. - If false (currently behaviour) - all poses for static grid is predefined and not depends on element's count (see example: static grid and static grid with dynamic poses) - **#132** Add example with grid add/remove with animations +- **#112** Allow remap default Druid input bindings. \ No newline at end of file diff --git a/druid/const.lua b/druid/const.lua index 047229a..778dd4a 100644 --- a/druid/const.lua +++ b/druid/const.lua @@ -5,18 +5,18 @@ local M = {} -M.ACTION_TEXT = hash("text") -M.ACTION_MARKED_TEXT = hash("marked_text") +M.ACTION_TEXT = hash(sys.get_config("druid.input_text", "text")) +M.ACTION_TOUCH = hash(sys.get_config("druid.input_touch", "touch")) +M.ACTION_MARKED_TEXT = hash(sys.get_config("druid.input_marked_text", "marked_text")) -M.ACTION_BACKSPACE = hash("key_backspace") -M.ACTION_ENTER = hash("key_enter") -M.ACTION_BACK = hash("key_back") -M.ACTION_ESC = hash("key_esc") +M.ACTION_ESC = hash(sys.get_config("druid.input_key_esc", "key_esc")) +M.ACTION_BACK = hash(sys.get_config("druid.input_key_back", "key_back")) +M.ACTION_ENTER = hash(sys.get_config("druid.input_key_enter", "key_enter")) +M.ACTION_MULTITOUCH = hash(sys.get_config("druid.input_multitouch", "multitouch")) +M.ACTION_BACKSPACE = hash(sys.get_config("druid.input_key_backspace", "key_backspace")) -M.ACTION_TOUCH = hash("touch") -M.ACTION_SCROLL_UP = hash("scroll_up") -M.ACTION_MULTITOUCH = hash("multitouch") -M.ACTION_SCROLL_DOWN = hash("scroll_down") +M.ACTION_SCROLL_UP = hash(sys.get_config("druid.input_scroll_up", "scroll_up")) +M.ACTION_SCROLL_DOWN = hash(sys.get_config("druid.input_scroll_down", "scroll_down")) M.RELEASED = "released" diff --git a/game.project b/game.project index 7140890..ee33433 100644 --- a/game.project +++ b/game.project @@ -25,6 +25,16 @@ use_accelerometer = 0 [druid] no_auto_input = 0 +input_text = text +input_touch = touch +input_marked_text = marked_text +input_key_esc = key_esc +input_key_back = key_back +input_key_enter = key_enter +input_key_backspace = key_backspace +input_multitouch = multitouch +input_scroll_up = scroll_up +input_scroll_down = scroll_down [html5] engine_arguments = --verify-graphics-calls=false