| 82 | } |
| 83 | |
| 84 | void InputSystemImpl::update(float delta) SKR_NOEXCEPT |
| 85 | { |
| 86 | // 1. glob inputs |
| 87 | auto inputInst = skr::input::Input::GetInstance(); |
| 88 | for (auto& [kind, raw_inputs] : inputs) |
| 89 | { |
| 90 | // 1.1 clear history |
| 91 | raw_inputs.clear(); |
| 92 | |
| 93 | // 1.2 glob nearest readings |
| 94 | InputLayer* layer = nullptr; |
| 95 | InputReading* reading = nullptr; |
| 96 | auto r = inputInst->GetCurrentReading(kind, nullptr, &layer, &reading); |
| 97 | if (r == EInputResult::INPUT_RESULT_OK) |
| 98 | { |
| 99 | raw_inputs.add({ layer, reading, kind }); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // 2. update contexts |
| 104 | for (auto& action : actions) |
| 105 | { |
| 106 | action->clear_value(); |
| 107 | } |
| 108 | |
| 109 | for (auto& [priority, context] : contexts) |
| 110 | { |
| 111 | auto mappings = context->get_mappings(); |
| 112 | for (auto& [kind, raw_inputs] : inputs) |
| 113 | { |
| 114 | for (auto& raw_input : raw_inputs) |
| 115 | { |
| 116 | for (auto mapping : mappings) |
| 117 | { |
| 118 | // 2.1 update processing |
| 119 | bool dirty = mapping->process_input_reading(raw_input.layer, raw_input.reading, kind); |
| 120 | if (!dirty) continue; |
| 121 | |
| 122 | // 2.2 update modifiers |
| 123 | mapping->process_modifiers(delta); |
| 124 | // 2.3 update actions |
| 125 | mapping->process_actions(delta); |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | // 3. update actions |
| 132 | for (auto& action : actions) |
| 133 | { |
| 134 | action->process_modifiers(delta); |
| 135 | action->process_triggers(delta); |
| 136 | } |
| 137 | |
| 138 | // 3. free raw inputs |
| 139 | for (auto& [kind, raw_inputs] : inputs) |
| 140 | { |
| 141 | for (auto& raw_input : raw_inputs) |
nothing calls this directly
no test coverage detected