1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
return mod1 == modifierKeyToMatch
or mod2 == modifierKeyToMatch
or mod3 == modifierKeyToMatch
or mod4 == modifierKeyToMatch
end
if key == KEY_CTRL and ctrl then ctrl = false end
if key == KEY_ALT and alt then alt = false end
if key == KEY_SHIFT and shift then shift = false end
if key == KEY_COMMAND and command then command = false end
return keyId == key and bindingCtrl == ctrl and bindingAlt == alt and bindingShift == shift and bindingCommand == command
end
--[[
This function performs binding matching based on key inputs.
The checks are a little convoluted:
1. Base keys need to match
2. mod1, 2, 3 and 4 come in in some arbitrary order, so they have to get mapped properly to match the arguments that are passed to OnKeyDown
3. If the base keypress is a modifier key, the appropriate modifier needs to be turned off for this keypress; because bindings like Ctrl+Ctrl make no sense.
--]]
if layerIndex then
local keyId1 , mod1 , mod2 , mod3 , mod4 = GetActionBindingInfo ( layerIndex , categoryIndex , actionIndex , 1 )
local keyId2 , mod21 , mod22 , mod23 , mod24 = GetActionBindingInfo ( layerIndex , categoryIndex , actionIndex , 2 )
end
return false
end
if disabled == nil then
disabled = false
end
if mouseIcon then
return mouseIcon , mouseWidth , mouseHeight
end
local keyboardIcon , keyboardWidth , keyboardHeight = GetKeyboardIconPathForKeyCode ( keyCode , disabled )
if keyboardIcon then
return keyboardIcon , keyboardWidth , keyboardHeight
end
end
KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME = 1
KEYBIND_TEXT_OPTIONS_FULL_NAME = 2
KEYBIND_TEXT_OPTIONS_FULL_NAME_SEPARATE_MODS = 3
KEYBIND_TEXTURE_OPTIONS_NONE = 1
KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP = 2
end
end
--Gamepad and mouse keys use icons instead of text (with the exception of mouse button 4 and 5)
end
local scale = scalePercent or 100
end
do
local keyNameTable = { }
local DEFAULT_SCALE_PERCENT = 180
if textureOptions == KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP then
return ZO_Keybindings_GenerateIconKeyMarkup ( keyCode , scalePercent or DEFAULT_SCALE_PERCENT , useDisabledIcon )
end
else
end
end
if key ~= KEY_INVALID then
end
end
local function TranslateKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , scalePercent , useDisabledIcon )
if key ~= KEY_INVALID then
textOptions = textOptions or KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME
textureOptions = textureOptions or KEYBIND_TEXTURE_OPTIONS_NONE
if mod1 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod1 , textureOptions , scalePercent , useDisabledIcon ) ) end
if mod2 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod2 , textureOptions , scalePercent , useDisabledIcon ) ) end
if mod3 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod3 , textureOptions , scalePercent , useDisabledIcon ) ) end
if mod4 ~= KEY_INVALID then table . insert ( keyNameTable , GetKeyOrTexture ( mod4 , textureOptions , scalePercent , useDisabledIcon ) ) end
if textOptions == KEYBIND_TEXT_OPTIONS_ABBREVIATED_NAME and # keyNameTable > 0 then
end
if textOptions == KEYBIND_TEXT_OPTIONS_FULL_NAME_SEPARATE_MODS then
elseif textOptions == KEYBIND_TEXT_OPTIONS_FULL_NAME then
else
end
end
end
function ZO_Keybindings_GetBindingStringFromKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , textureWidthPercent , textureHeightPercent , useDisabledIcon )
return TranslateKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , textureWidthPercent , useDisabledIcon )
end
end
function ZO_Keybindings_GetBindingStringFromAction ( actionName , textOptions , textureOptions , bindingIndex , textureWidthPercent , textureHeightPercent , useDisabledIcon )
if layerIndex then
local key , mod1 , mod2 , mod3 , mod4 = GetActionBindingInfo ( layerIndex , categoryIndex , actionIndex , bindingIndex or 1 )
return ZO_Keybindings_GetBindingStringFromKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , textureWidthPercent , textureHeightPercent , useDisabledIcon )
end
return ""
end
if layerIndex then
local key , mod1 , mod2 , mod3 , mod4 = GetActionBindingInfo ( layerIndex , categoryIndex , actionIndex , bindingIndex or 1 )
end
return ""
end
-- Doesn't return the GetString(SI_ACTION_IS_NOT_BOUND) automatically, just nil if theres no binds
function ZO_Keybindings_GetHighestPriorityBindingStringFromAction ( actionName , textOptions , textureOptions , alwaysPreferGamepadMode , showAsHold , scalePercent , useDisabledIcon )
local key , mod1 , mod2 , mod3 , mod4 = GetHighestPriorityActionBindingInfoFromNameAndInputDevice ( actionName , preferredKeybindType )
if key == KEY_INVALID then
return nil
end
if showAsHold then
if holdKey ~= KEY_INVALID then
key = holdKey
end
end
return ZO_Keybindings_GetBindingStringFromKeys ( key , mod1 , mod2 , mod3 , mod4 , textOptions , textureOptions , scalePercent , scalePercent , useDisabledIcon ) , key , mod1 , mod2 , mod3 , mod4
end
-- Doesn't return the GetString(SI_ACTION_IS_NOT_BOUND) automatically, just nil if theres no binds
function ZO_Keybindings_GetHighestPriorityNarrationStringFromAction ( actionName , alwaysPreferGamepadMode , showAsHold )
local key , mod1 , mod2 , mod3 , mod4 = GetHighestPriorityActionBindingInfoFromNameAndInputDevice ( actionName , preferredKeybindType )
if key == KEY_INVALID then
return nil
end
if showAsHold then
if holdKey ~= KEY_INVALID then
key = holdKey
end
end
end
-- Doesn't return the GetString(SI_ACTION_IS_NOT_BOUND) automatically, just nil if there's no binds
-- Returns the highest priority narration string from either the keyboard or gamepad action, depending on preferred key type
function ZO_Keybindings_GetPreferredHighestPriorityNarrationStringFromActions ( keyboardActionName , gamepadActionName , showAsHold )
local actionName = preferredKeybindType == PREFERRED_INPUT_DEVICE_TYPE_GAMEPAD and gamepadActionName or keyboardActionName
local key , mod1 , mod2 , mod3 , mod4 = GetHighestPriorityActionBindingInfoFromNameAndInputDevice ( actionName , preferredKeybindType )
if key == KEY_INVALID then
return nil
end
if showAsHold then
if holdKey ~= KEY_INVALID then
key = holdKey
end
end
end
end
local function RegisterLabelForBindingUpdate ( label , actionName , showUnbound , gamepadActionName , onBindingUpdateCallback , alwaysPreferGamepadMode , showAsHold , scalePercent , useDisabledIcon )
end
local bindingText , key , mod1 , mod2 , mod3 , mod4
bindingText , key , mod1 , mod2 , mod3 , mod4 = ZO_Keybindings_GetHighestPriorityBindingStringFromAction ( gamepadActionName , KEYBIND_TEXT_OPTIONS_FULL_NAME , KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP , alwaysPreferGamepadMode , showAsHold , scalePercent , disableIcon )
end
if not bindingText or # bindingText == 0 then
bindingText , key , mod1 , mod2 , mod3 , mod4 = ZO_Keybindings_GetHighestPriorityBindingStringFromAction ( actionName , KEYBIND_TEXT_OPTIONS_FULL_NAME , KEYBIND_TEXTURE_OPTIONS_EMBED_MARKUP , alwaysPreferGamepadMode , showAsHold , scalePercent , disableIcon )
end
if showUnbound or showUnbound == nil then
bindingText = bindingText or ZO_Keybindings_GenerateTextKeyMarkup ( GetString ( SI_ACTION_IS_NOT_BOUND ) )
else
bindingText = bindingText or ""
end
end
end
end
end
end
function ZO_Keybindings_RegisterLabelForBindingUpdate ( label , actionName , showUnbound , gamepadActionName , onChangedCallback , alwaysPreferGamepadMode , showAsHold , scalePercent , useDisabledIcon )
end
end
RegisterLabelForBindingUpdate ( label , actionName , showUnbound , gamepadActionName , OnKeybindUpdate , alwaysPreferGamepadMode , showAsHold , scalePercent , useDisabledIcon )
end
--This function is identical to the more general ZO_Keybdinging_RegisterLabelForBindingUpdate with the exception that it does
--not call SetText for the case that the keybind is embedded in a larger line of text. In such a case, it's up to whatever is
--handling that line to call SetText appropriately.
function ZO_Keybindings_RegisterLabelForInLineBindingUpdate ( label , actionName , showUnbound , gamepadActionName , onChangedCallback , alwaysPreferGamepadMode , showAsHold , scalePercent , useDisabledIcon )
end
end
RegisterLabelForBindingUpdate ( label , actionName , showUnbound , gamepadActionName , OnKeybindUpdate , alwaysPreferGamepadMode , showAsHold , scalePercent , useDisabledIcon )
end
end
local localizedConsoleActionName = ""
end
if localizedConsoleActionName ~= "" then
return localizedConsoleActionName
elseif localizedGamepadActionName ~= "" then
return localizedGamepadActionName
else
return localizedActionName
end
end
end
if alwaysPreferGamepadMode then
return true
end
local keybindDisplayMode = tonumber ( GetSetting ( SETTING_TYPE_GAMEPAD , GAMEPAD_SETTING_KEYBIND_DISPLAY_MODE ) )
if keybindDisplayMode == KEYBIND_DISPLAY_MODE_ALWAYS_KEYBOARD then
return false
elseif keybindDisplayMode == KEYBIND_DISPLAY_MODE_ALWAYS_GAMEPAD then
return true
else -- keybindDisplayMode == KEYBIND_DISPLAY_MODE_AUTOMATIC
else
return true
end
end
end
return false
end
if alwaysPreferGamepadMode then
return PREFERRED_INPUT_DEVICE_TYPE_GAMEPAD
end
local keybindDisplayMode = tonumber ( GetSetting ( SETTING_TYPE_GAMEPAD , GAMEPAD_SETTING_KEYBIND_DISPLAY_MODE ) )
if keybindDisplayMode == KEYBIND_DISPLAY_MODE_ALWAYS_KEYBOARD then
return PREFERRED_INPUT_DEVICE_TYPE_KEYBOARD
elseif keybindDisplayMode == KEYBIND_DISPLAY_MODE_ALWAYS_GAMEPAD then
return PREFERRED_INPUT_DEVICE_TYPE_GAMEPAD
else -- keybindDisplayMode == KEYBIND_DISPLAY_MODE_AUTOMATIC
return PREFERRED_INPUT_DEVICE_TYPE_GAMEPAD
else
return PREFERRED_INPUT_DEVICE_TYPE_KEYBOARD
end
else
return PREFERRED_INPUT_DEVICE_TYPE_GAMEPAD
end
end
end
return PREFERRED_INPUT_DEVICE_TYPE_KEYBOARD_OR_MOUSE
end |