InputKeyMapListProvider
Centralizes input of keys. You can construct a new provider in a package and key bindings can be recovered from it. This is designed for user configuration/rebindings.
local inputMapProvider = InputKeyMapListProvider.new("General", function(self)
self:Add(InputKeyMapList.new("JUMP", {
InputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.Space });
InputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonA });
InputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton("primary3") });
}, {
bindingName = "Jump";
rebindable = true;
}))
self:Add(InputKeyMapList.new("HONK", {
InputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.H });
InputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.DPadUp });
InputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton("primary2") });
}, {
bindingName = "Honk";
rebindable = true;
}))
self:Add(InputKeyMapList.new("BOOST", {
InputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.LeftControl });
InputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonX });
InputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton("primary4") });
}, {
bindingName = "Boost";
rebindable = true;
}))
end)
local inputMap = serviceBag:GetService(inputMapProvider)
serviceBag:Init()
serviceBag:Start()
Functions
new
InputKeyMapListProvider.
new
(
providerName:
string
,
--
Name to use for global specification.
createDefaults:
callback
--
Callback to construct the default items on init
) →
InputKeyMapList
Constructs a new InputKeyMapListProvider. The name will be used for retrieval, for example, if the dialog system needs to get a general input hint to show to the user.
GetProviderName
InputKeyMapListProvider:
GetProviderName
(
) →
string
Gets this providers name
GetInputKeyMapList
Gets an input key map list for the given name. Errors if it is not defined.
FindInputKeyMapList
Finds an input key map list for the given name