1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

[3.x] Add raw strength value for internal use

This commit is contained in:
Aaron Franke
2021-07-22 20:28:08 -04:00
parent 6d58ea6ce7
commit afa89c9eea
7 changed files with 49 additions and 21 deletions

View File

@@ -145,6 +145,19 @@ float InputDefault::get_action_strength(const StringName &p_action) const {
return E->get().strength;
}
float InputDefault::get_action_raw_strength(const StringName &p_action) const {
#ifdef DEBUG_ENABLED
bool has_action = InputMap::get_singleton()->has_action(p_action);
ERR_FAIL_COND_V_MSG(!has_action, false, "Request for nonexistent InputMap action '" + String(p_action) + "'.");
#endif
const Map<StringName, Action>::Element *E = action_state.find(p_action);
if (!E) {
return 0.0f;
}
return E->get().raw_strength;
}
float InputDefault::get_joy_axis(int p_device, int p_axis) const {
_THREAD_SAFE_METHOD_
int c = _combine_device(p_axis, p_device);
@@ -424,10 +437,12 @@ void InputDefault::_parse_input_event_impl(const Ref<InputEvent> &p_event, bool
action.physics_frame = Engine::get_singleton()->get_physics_frames();
action.idle_frame = Engine::get_singleton()->get_idle_frames();
action.pressed = p_event->is_action_pressed(E->key());
action.strength = 0.f;
action.strength = 0.0f;
action.raw_strength = 0.0f;
action_state[E->key()] = action;
}
action_state[E->key()].strength = p_event->get_action_strength(E->key());
action_state[E->key()].raw_strength = p_event->get_action_raw_strength(E->key());
}
}