| 227 | } |
| 228 | |
| 229 | void Input::fireBindings() |
| 230 | { |
| 231 | for (const auto itBindingToKey : actionBindingToKeyMap) |
| 232 | { |
| 233 | // is key currently pressed AND ( is continuous OR key has just been triggered ) |
| 234 | bool triggerAction = keyState.test(itBindingToKey.second) && (itBindingToKey.first.isContinuous || keyTriggered.test(itBindingToKey.second)); |
| 235 | // Key causes a constant intensity of 1.0, when pressed. |
| 236 | float intensity = triggerAction ? 1.0f : 0.0f; |
| 237 | // Invert intensity if isInverted is true |
| 238 | intensity = itBindingToKey.first.isInverted ? -intensity : intensity; |
| 239 | |
| 240 | for (const auto& action : actionTypeToActionMap) |
| 241 | { |
| 242 | if (action.first == itBindingToKey.first.actionType && action.second.isEnabled) |
| 243 | { |
| 244 | action.second.function(triggerAction, intensity); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | /*auto rangeIterators = actionTypeToActionMap.equal_range(itBindingToKey.first.actionType); |
| 249 | for(auto itAction = rangeIterators.first; itAction != rangeIterators.second; ++itAction) |
| 250 | if(itAction->second.isEnabled) |
| 251 | { |
| 252 | itAction->second.function(triggerAction, intensity); |
| 253 | }*/ |
| 254 | } |
| 255 | |
| 256 | clearTriggered(); |
| 257 | |
| 258 | bool enableMouse = !Flags::disableMouse.isSet(); |
| 259 | |
| 260 | for (const auto itBindingToButton : actionBindingToMouseButtonMap) |
| 261 | { |
| 262 | bool triggerAction = mouseButtonState.test(itBindingToButton.second) && (itBindingToButton.first.isContinuous || mouseButtonTriggered.test(itBindingToButton.second)); |
| 263 | // Button causes a constant intensity of 1.0 when pressed |
| 264 | float intensity = triggerAction ? 1.0f : 0.0f; |
| 265 | // Invert intensity if isInverted is true |
| 266 | intensity = itBindingToButton.first.isInverted ? -intensity : intensity; |
| 267 | |
| 268 | auto rangeIterators = actionTypeToActionMap.equal_range(itBindingToButton.first.actionType); |
| 269 | for (auto itAction = rangeIterators.first; itAction != rangeIterators.second; ++itAction) |
| 270 | if (itAction->second.isEnabled && enableMouse) |
| 271 | itAction->second.function(triggerAction, intensity); |
| 272 | |
| 273 | } |
| 274 | // This must be done after the loop, because multiple bindings to the same button may occur |
| 275 | mouseButtonTriggered.reset(); |
| 276 | |
| 277 | float deltaMouse[2] = { |
| 278 | axisPosition[static_cast<std::size_t>(MouseAxis::CursorX)] - mousePosition.x, |
| 279 | axisPosition[static_cast<std::size_t>(MouseAxis::CursorY)] - mousePosition.y}; |
| 280 | |
| 281 | mousePosition.x = axisPosition[static_cast<std::size_t>(MouseAxis::CursorX)]; |
| 282 | mousePosition.y = axisPosition[static_cast<std::size_t>(MouseAxis::CursorY)]; |
| 283 | |
| 284 | for (const auto itBindingToAxis : actionBindingToMouseAxisMap) |
| 285 | { |
| 286 | const size_t& mouseAxisIndex = static_cast<std::size_t>(itBindingToAxis.second); |