Skip to main content

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(
providerNamestring,--

Name to use for global specification.

createDefaultscallback--

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

InputKeyMapListProvider:GetInputKeyMapList(keyMapListNamestring) → InputKeyMapList

Gets an input key map list for the given name. Errors if it is not defined.

FindInputKeyMapList

InputKeyMapListProvider:FindInputKeyMapList(keyMapListNamestring) → InputKeyMapList

Finds an input key map list for the given name

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new InputKeyMapListProvider. The name will be used for retrieval,\nfor example, if the dialog system needs to get a general input hint to show\nto the user.",
            "params": [
                {
                    "name": "providerName",
                    "desc": "Name to use for global specification.",
                    "lua_type": "string"
                },
                {
                    "name": "createDefaults",
                    "desc": "Callback to construct the default items on init",
                    "lua_type": "callback"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "InputKeyMapList"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 65,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapListProvider.lua"
            }
        },
        {
            "name": "GetProviderName",
            "desc": "Gets this providers name",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 95,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapListProvider.lua"
            }
        },
        {
            "name": "GetInputKeyMapList",
            "desc": "Gets an input key map list for the given name. Errors if it is not\ndefined.",
            "params": [
                {
                    "name": "keyMapListName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "InputKeyMapList"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 106,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapListProvider.lua"
            }
        },
        {
            "name": "FindInputKeyMapList",
            "desc": "Finds an input key map list for the given name",
            "params": [
                {
                    "name": "keyMapListName",
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "InputKeyMapList"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 120,
                "path": "src/inputkeymaputils/src/Shared/InputKeyMapListProvider.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "InputKeyMapListProvider",
    "desc": "Centralizes input of keys. You can construct a new provider in a\npackage and key bindings can be recovered from it. This is designed\nfor user configuration/rebindings.\n\n```lua\nlocal inputMapProvider = InputKeyMapListProvider.new(\"General\", function(self)\n\tself:Add(InputKeyMapList.new(\"JUMP\", {\n\t\tInputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.Space });\n\t\tInputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonA });\n\t\tInputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton(\"primary3\") });\n\t}, {\n\t\tbindingName = \"Jump\";\n\t\trebindable = true;\n\t}))\n\tself:Add(InputKeyMapList.new(\"HONK\", {\n\t\tInputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.H });\n\t\tInputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.DPadUp });\n\t\tInputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton(\"primary2\") });\n\t}, {\n\t\tbindingName = \"Honk\";\n\t\trebindable = true;\n\t}))\n\tself:Add(InputKeyMapList.new(\"BOOST\", {\n\t\tInputKeyMap.new(InputModeTypes.KeyboardAndMouse, { Enum.KeyCode.LeftControl });\n\t\tInputKeyMap.new(InputModeTypes.Gamepads, { Enum.KeyCode.ButtonX });\n\t\tInputKeyMap.new(InputModeTypes.Touch, { SlottedTouchButtonUtils.createSlottedTouchButton(\"primary4\") });\n\t}, {\n\t\tbindingName = \"Boost\";\n\t\trebindable = true;\n\t}))\nend)\n\nlocal inputMap = serviceBag:GetService(inputMapProvider)\n\nserviceBag:Init()\nserviceBag:Start()\n```",
    "source": {
        "line": 42,
        "path": "src/inputkeymaputils/src/Shared/InputKeyMapListProvider.lua"
    }
}