MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / parse_input_event

Method parse_input_event

core/input/input.cpp:1202–1241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1200}
1201
1202void Input::parse_input_event(const Ref<InputEvent> &p_event) {
1203 _THREAD_SAFE_METHOD_
1204
1205 ERR_FAIL_COND(p_event.is_null());
1206
1207#ifdef DEBUG_ENABLED
1208 uint64_t curr_frame = Engine::get_singleton()->get_process_frames();
1209 if (curr_frame != last_parsed_frame) {
1210 frame_parsed_events.clear();
1211 last_parsed_frame = curr_frame;
1212 frame_parsed_events.insert(p_event);
1213 } else if (frame_parsed_events.has(p_event)) {
1214 // It would be technically safe to send the same event in cases such as:
1215 // - After an explicit flush.
1216 // - In platforms using buffering when agile flushing is enabled, after one of the mid-frame flushes.
1217 // - If platform doesn't use buffering and event accumulation is disabled.
1218 // - If platform doesn't use buffering and the event type is not accumulable.
1219 // However, it wouldn't be reasonable to ask users to remember the full ruleset and be aware at all times
1220 // of the possibilities of the target platform, project settings and engine internals, which may change
1221 // without prior notice.
1222 // Therefore, the guideline is, "don't send the same event object more than once per frame".
1223 WARN_PRINT_ONCE(
1224 "An input event object is being parsed more than once in the same frame, which is unsafe.\n"
1225 "If you are generating events in a script, you have to instantiate a new event instead of sending the same one more than once, unless the original one was sent on an earlier frame.\n"
1226 "You can call duplicate() on the event to get a new instance with identical values.");
1227 } else {
1228 frame_parsed_events.insert(p_event);
1229 }
1230#endif
1231
1232 if (use_accumulated_input) {
1233 if (buffered_events.is_empty() || !buffered_events.back()->get()->accumulate(p_event)) {
1234 buffered_events.push_back(p_event);
1235 }
1236 } else if (agile_input_event_flushing) {
1237 buffered_events.push_back(p_event);
1238 } else {
1239 _parse_input_event_impl(p_event, false);
1240 }
1241}
1242
1243#ifdef DEBUG_ENABLED
1244void Input::flush_frame_parsed_events() {

Callers 15

_trigger_action_eventMethod · 0.80
_process_commandMethod · 0.80
_update_input_sourceMethod · 0.80
_on_input_eventMethod · 0.80
send_eventMethod · 0.80
_simulate_key_pressMethod · 0.80
window_start_dragMethod · 0.80
window_start_resizeMethod · 0.80
_touch_eventMethod · 0.80
_drag_eventMethod · 0.80
WndProcMethod · 0.80

Calls 10

is_nullMethod · 0.45
get_process_framesMethod · 0.45
clearMethod · 0.45
insertMethod · 0.45
hasMethod · 0.45
is_emptyMethod · 0.45
accumulateMethod · 0.45
getMethod · 0.45
backMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected