Pathoschild / SMAPI

The modding API for Stardew Valley.
https://smapi.io/
GNU Lesser General Public License v3.0
1.8k stars 259 forks source link

Add keybind registration API #630

Closed Pathoschild closed 3 years ago

Pathoschild commented 5 years ago

Extend the helper.Input API to let mods register key bindings, optionally with an in-game UI which lets the user change bindings.

See #744 for a proposed API with a smaller scope.

Pathoschild commented 5 years ago

Some preliminary requirements per discussion in #modding:

Possible API designs:

The ideal is to possibly support a key bind UI (not necessarily in the first release). This would be something similar to this Minecraft UI, where each mod is a section:

qqkookie commented 5 years ago

How about let, or prompt moder to declare default key usage info in "manifest.json"?, so that player can recognize potential key conflict at least, and change key setting accordingly. There may be such key assignment info in "config.json", but at mod install time, it is not created yet, so not available to player to check. If default keys are listed in "manifest.json", it would be much easier for player to use the the mod in game and to check potential key conflict of all mods.

Example entry in "manifest.json", "UsedButtons": "OemTilde, P, F8, ControllerA, RightShoulder,~LeftControl" "UsedButtons": "None" (for mod that does not use keyboard key)

The "~" notation before LeftControl is to denote that it is used as modifier key or used only in some special case like in Menu or debugging, so that the key can be shared with other mod without conflict so no need to worry or change.

For the time being, SMAPI will not utilize such info, or just print warning log for potential key bind conflict with the SDV game key binding or other installed mods.

And it may be interim solution and preparing for future with key assignment API you suggested, before such API is widely adopted by future updated mod's. It does not require source code change, just editing and adding one entry to "manifest.json" will do and it can be done on mod without source code, or even by the player.

And it is good for suggested keybinding API, because the SMAPI can get key binding infos of those old mod that does not use new keybinding API, but with such Default key entry. If player changed the key binding of such old mod, simply change the "UsedButtons" in "manifest.json" so that the keybinding API will avoid assigning such keys.

This measure can be done now so that all moder can follow the measure from now on , without new SMAPI 3.0 or keybind API will be available in future.

Pathoschild commented 5 years ago

Unfortunately there's a few issues with that approach:

Pathoschild commented 3 years ago

744 adds a multi-keybind API in SMAPI 3.9. We could still add a keybind registry eventually, but I have no plans to work on one in the foreseeable future, so I'll close this ticket.