Custom/generalized keybindings

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Custom/generalized keybindings

by taikedz » Sun Aug 14, 2016 09:35

Hello

I wanted to know if it would be of interest to add the possibility to register custom key bindings to Minetest for mods purposes?

I see there's this already

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
player:get_player_control().up


I was wondering if it would be of interest to add these:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_control("j") -- defined by letter
minetest.register_control("k","cust1") -- custom table entry name
minetest.register_control(17,"ctrl1") -- defined by code

-- return error if custom key already defined so as to avoid mod conflicts?

-- Usage examples:

player:get_player_control().keyj -- automatically generated name
player:get_player_control().cust1
player:get_player_control().ctrl1


I am presuming the W3C's codes are general-purpose and not just for the web?

https://www.w3.org/2002/09/tests/keys.html

My own intention is to be able to add a mod that would allow the use of I,J,K,L keys as well as U,O,P to set yaw, pitch and usage, for full keyboard control.
 

User avatar
Krock
Member
 
Posts: 3598
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker

Re: Custom/generalized keybindings

by Krock » Sun Aug 14, 2016 10:48

And how, do you think, can these keys be configured individually for players who already use them for another function?
Newest Win32 builds - Find a mod - All my mods
ALL YOUR DONATION ARE BELONG TO PARAMAT (Please support him and Minetest)
New DuckDuckGo !bang: !mtmod <keyword here>
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Custom/generalized keybindings

by taikedz » Sun Aug 14, 2016 16:30

Are you talking about conflicts where 2 mods use the same keys for different functions?

I'd expect that would be an admin task when introducing two overlapping mods - they would have to configure these appropriately, just as if two different mods were to try to redefine the same block.

+++

Alternatively, providing a key assignment interface as part of the engine. So a mod make woudl be able to do something like this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.registerkey("secondpunch")

-- .... to be used like this ...

if player:get_player_control().secondpunch then
-- ...


and add to the Minetest application interface a key configuration panel accessible during gameplay.

Would that make sense?
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: Custom/generalized keybindings

by Wuzzy » Sun Aug 14, 2016 21:48

I also strongly object to the idea of hardcoding any keys via the Lua API. It wouldn't even work as soon anyone is using custom controls. In other words, it simply can't work.

However, adding a small set of abstract “Lua keys” to be used for special actions is a pretty good idea.
The mods simply use something like “Lua key #1” without knowing the actual key binding. The clients then have bindings to the “Lua keys” which can in turn be configured freely.

I think such an approach would work and it would make sense. I have seen such an approach being used in a different game for 3 keys and it worked just fine.

What could be still tricky is to make sure that no 2 mods want to use the same key for completely different reasons.
I'm creating MineClone 2, a Minecraft clone for Minetest.
I made the Help modpack, adding in-game help to Minetest.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Custom/generalized keybindings

by Byakuren » Tue Aug 16, 2016 07:37

taikedz wrote:Are you talking about conflicts where 2 mods use the same keys for different functions?

I'd expect that would be an admin task when introducing two overlapping mods - they would have to configure these appropriately, just as if two different mods were to try to redefine the same block.

+++

Alternatively, providing a key assignment interface as part of the engine. So a mod make woudl be able to do something like this:

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.registerkey("secondpunch")

-- .... to be used like this ...

if player:get_player_control().secondpunch then
-- ...


and add to the Minetest application interface a key configuration panel accessible during gameplay.

Would that make sense?

I like this reassignment idea, except I think key registrations should have their id modname-prefixed to prevent collisions, and also include a description meant for humans, so the player knows what the mapping is for. The key settings between a player and a particular key id should be saved also, on the client.

This avoids the problem Wuzzy mentioned about different mods wanting the same abstract key, since there would be as many keys possible as there are strings, and they would be unique across all mods as long as prefixes are enforced.

It creates another problem though, where players might have the same physical key for different abstract keys in different worlds, because there was no conflict in the individual worlds. If the player then plays in a world with both mods, they will have a key conflict. Maybe this should be resolved manually by the player (and have the game alert them), or settings should be saved per-world rather than globally.
Every time a mod API is left undocumented, a koala dies.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Custom/generalized keybindings

by Byakuren » Sun Aug 28, 2016 00:33

Rethinking, I think the best option would be to have a large number of lua keys as Wuzzy suggested, in the C++ part of the engine. A way to parcel out and configure the mapping to lua keys could be implemented in lua engine code or as part of a framework mod. This would make the C++ portion simpler and still allow unambiguous configurable key mappings.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
taikedz
Member
 
Posts: 587
Joined: Sun May 15, 2016 11:11
GitHub: taikedz
IRC: DuCake
In-game: DuCake

Re: Custom/generalized keybindings

by taikedz » Tue Sep 20, 2016 00:22

After sitting on it, I'm still thinking it would be nice for a mod to be able to say "hey I expose an extra key, please configure me", and for the UI to have a responsive thing - once loged in to server, user can bring up a "key bindings" window and see what extra keys can be configured, for each mod, on that server.

It leaves it up to the player to configure it, and the mod just registers a handler by name/ID
 

User avatar
kaadmy
Member
 
Posts: 627
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD

Re: Custom/generalized keybindings

by kaadmy » Tue Sep 20, 2016 15:38

There should at least be some "user" keys, such as userbind0, userbind1, ...
And have mods use those instead, like @taikedz suggested.
Never paint white stripes on roads near Zebra crossings.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 44 guests

cron