-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explanation of input bindings is a bit confusing #268
Comments
Hello! Sure there are can be some misunderstanding, so we can help each other to understand it better ;) For input component you should pass the key ids that trigger this hotkey, for example self.druid:new_hotkey("key_g", ...)
-- or
self.druid:new_hotkey({ "key_lshift", "key_a" }, ...) The list of "modificator" key_ids are listed in the default
M["hotkey"] = {
-- Add key ids to mark it as modificator keys
MODIFICATORS = {
"key_lshift",
"key_rshift",
"key_lctrl",
"key_rctrl",
"key_lalt",
"key_ralt"
}
} So "Druid utilize default bindings" means this default modificator key ids. Also, if you don't need any modificators and want to add callback just for one key, you also can use next thing: local button = self.druid:new_button("button_node", ...)
button:set_key_trigger("key_g") About live example: In browser some of hotkeys can be hooked by the browser itself. In Druid example my |
Thanks for that quick response! I did get it working earlier with a single hotkey, but had to add that hotkey to my input bindings. I think my misunderstanding is related to what you said here:
I didn't even think about whether I was using it or not, and just assumed Druid magically uses it once the dependency is installed. Now I see there are two ways to use hotkeys:
So I wrongly assumed option 1 was sort of implicitly done when using Druid, but it's not. Probably anyone with more experience using Defold would not make that mistake, so we can probably close this 😅 [Edit] |
Good catch for the example issue, will update it! But I didn't get the which exactly thing should be better explained. In short current workflow I can describe next: Input bindings is just a map with So probably the advantage for this will be to add something about how input bindings works in Defold? wdyt? |
That workflow makes sense now -- I think the remaining question mark is that the above workflow still requires you to either declare the "non-custom" bindings, e.g. When I read this sentence from the README:
what my brain actually told me was:
So yeah I think adding a little "basic Defold" note there could help, e.g. something like this in the README (and Hotkey API page)? Assuming I finally understand things 😄 - Druid utilizes the /builtins/input/all.input_binding input bindings. For custom input
- bindings, refer to the Input Binding section in the [Advanced Setup](https://github.com/Insality/druid/blob/master/docs_md/advanced-setup.md#input-bindings).
+ Druid utilizes the /builtins/input/all.input_binding input bindings. Either use this
+ file for your project by setting the `Game binding` field in the `game.project` input
+ section to `/builtins/input/all.input_binding`, or add the specific bindings you need
+ to your game's input binding file. For custom input bindings, refer to the Input Binding
+ section in the [Advanced Setup](https://github.com/Insality/druid/blob/master/docs_md/advanced-setup.md#input-bindings). |
I ran into some confusion with
hotkey
after reading this part of the README:I took the reference to "all.input_binding" to mean that hotkeys would work with any key action defined there, but that's not how it is. Instead, any hotkey you want to use must have custom bindings defined in
/input/game.input_binding
. Perhaps we could add something to that effect (although I may be the first person on the planet who has misinterpreted the docs in this way).Incidentally when I clicked the hotkey example on the Druid site, it uses ctrl-G which doesn't seem to work in either Firefox or Chrome for me; it triggers the browser text search feature instead.
[edit]
I know the second half of that quote literally mentions "custom input bindings", but I wasn't sure what that meant, thinking maybe it meant gamepad inputs or something. Maybe it's clear enough and I just haven't had enough sleep!
The text was updated successfully, but these errors were encountered: