Merge branch 'lua_missing_key_codes' into 'master'

Lua binding for SDL_GetKeyName, two missing scan codes

See merge request OpenMW/openmw!1450

(cherry picked from commit d86e7d4c9a28bc96af0a5638b26879fa49b8a847)

9a073baa Add Apostrophe and Period scan codes
d66f3a35 Add getKeyName to Lua input API
ed64add9 Replace mentions of KeyEvent with KEY
switch-to-ppa
Petr Mikheev 3 years ago committed by psi29a
parent e2c896e4ce
commit 620748480b

@ -71,6 +71,10 @@ namespace MWLua
api["getControlSwitch"] = [input](std::string_view key) { return input->getControlSwitch(key); }; api["getControlSwitch"] = [input](std::string_view key) { return input->getControlSwitch(key); };
api["setControlSwitch"] = [input](std::string_view key, bool v) { input->toggleControlSwitch(key, v); }; api["setControlSwitch"] = [input](std::string_view key, bool v) { input->toggleControlSwitch(key, v); };
api["getKeyName"] = [](SDL_Scancode code) {
return SDL_GetKeyName(SDL_GetKeyFromScancode(code));
};
api["ACTION"] = LuaUtil::makeReadOnly(context.mLua->tableFromPairs<std::string_view, MWInput::Actions>({ api["ACTION"] = LuaUtil::makeReadOnly(context.mLua->tableFromPairs<std::string_view, MWInput::Actions>({
{"GameMenu", MWInput::A_GameMenu}, {"GameMenu", MWInput::A_GameMenu},
{"Screenshot", MWInput::A_Screenshot}, {"Screenshot", MWInput::A_Screenshot},
@ -252,6 +256,7 @@ namespace MWLua
{"RightBracket", SDL_SCANCODE_RIGHTBRACKET}, {"RightBracket", SDL_SCANCODE_RIGHTBRACKET},
{"RightShift", SDL_SCANCODE_RSHIFT}, {"RightShift", SDL_SCANCODE_RSHIFT},
{"Apostrophe", SDL_SCANCODE_APOSTROPHE},
{"BackSlash", SDL_SCANCODE_BACKSLASH}, {"BackSlash", SDL_SCANCODE_BACKSLASH},
{"Backspace", SDL_SCANCODE_BACKSPACE}, {"Backspace", SDL_SCANCODE_BACKSPACE},
{"CapsLock", SDL_SCANCODE_CAPSLOCK}, {"CapsLock", SDL_SCANCODE_CAPSLOCK},
@ -267,6 +272,7 @@ namespace MWLua
{"NumLock", SDL_SCANCODE_NUMLOCKCLEAR}, {"NumLock", SDL_SCANCODE_NUMLOCKCLEAR},
{"PageDown", SDL_SCANCODE_PAGEDOWN}, {"PageDown", SDL_SCANCODE_PAGEDOWN},
{"PageUp", SDL_SCANCODE_PAGEUP}, {"PageUp", SDL_SCANCODE_PAGEUP},
{"Period", SDL_SCANCODE_PERIOD},
{"Pause", SDL_SCANCODE_PAUSE}, {"Pause", SDL_SCANCODE_PAUSE},
{"PrintScreen", SDL_SCANCODE_PRINTSCREEN}, {"PrintScreen", SDL_SCANCODE_PRINTSCREEN},
{"ScrollLock", SDL_SCANCODE_SCROLLLOCK}, {"ScrollLock", SDL_SCANCODE_SCROLLLOCK},

@ -20,7 +20,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- Is a keyboard button currently pressed. -- Is a keyboard button currently pressed.
-- @function [parent=#input] isKeyPressed -- @function [parent=#input] isKeyPressed
-- @param #number keyCode Key code (the same code that is used in @{openmw.input#KeyEvent}) -- @param #number keyCode Key code (see @{openmw.input#KEY})
-- @return #boolean -- @return #boolean
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
@ -83,6 +83,12 @@
-- @param #string key Control type (see @{openmw.input#CONTROL_SWITCH}) -- @param #string key Control type (see @{openmw.input#CONTROL_SWITCH})
-- @param #boolean value -- @param #boolean value
-------------------------------------------------------------------------------
-- Returns a human readable name for the given key code
-- @function [parent=#input] getKeyName
-- @param #number code A key code (see @{openmw.input#KEY})
-- @return #string
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- @type CONTROL_SWITCH -- @type CONTROL_SWITCH
-- @field [parent=#CONTROL_SWITCH] #string Controls Ability to move -- @field [parent=#CONTROL_SWITCH] #string Controls Ability to move
@ -268,6 +274,7 @@
-- @field #number RightBracket -- @field #number RightBracket
-- @field #number RightSuper -- @field #number RightSuper
-- @field #number RightShift -- @field #number RightShift
-- @field #number Apostrophe
-- @field #number BackSlash -- @field #number BackSlash
-- @field #number Backspace -- @field #number Backspace
-- @field #number CapsLock -- @field #number CapsLock
@ -284,6 +291,7 @@
-- @field #number PageDown -- @field #number PageDown
-- @field #number PageUp -- @field #number PageUp
-- @field #number Pause -- @field #number Pause
-- @field #number Period
-- @field #number PrintScreen -- @field #number PrintScreen
-- @field #number ScrollLock -- @field #number ScrollLock
-- @field #number Semicolon -- @field #number Semicolon

Loading…
Cancel
Save