mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix some issues found by cppcheck.
This commit is contained in:
parent
72407a9cfb
commit
f851c4aa33
163 changed files with 776 additions and 767 deletions
|
@ -47,30 +47,30 @@ int InputEvent::get_device() const {
|
|||
}
|
||||
|
||||
bool InputEvent::is_action(const StringName &p_action, bool p_exact_match) const {
|
||||
return InputMap::get_singleton()->event_is_action(Ref<InputEvent>((InputEvent *)this), p_action, p_exact_match);
|
||||
return InputMap::get_singleton()->event_is_action(Ref<InputEvent>(const_cast<InputEvent *>(this)), p_action, p_exact_match);
|
||||
}
|
||||
|
||||
bool InputEvent::is_action_pressed(const StringName &p_action, bool p_allow_echo, bool p_exact_match) const {
|
||||
bool pressed;
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, p_exact_match, &pressed, nullptr, nullptr);
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>(const_cast<InputEvent *>(this)), p_action, p_exact_match, &pressed, nullptr, nullptr);
|
||||
return valid && pressed && (p_allow_echo || !is_echo());
|
||||
}
|
||||
|
||||
bool InputEvent::is_action_released(const StringName &p_action, bool p_exact_match) const {
|
||||
bool pressed;
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, p_exact_match, &pressed, nullptr, nullptr);
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>(const_cast<InputEvent *>(this)), p_action, p_exact_match, &pressed, nullptr, nullptr);
|
||||
return valid && !pressed;
|
||||
}
|
||||
|
||||
float InputEvent::get_action_strength(const StringName &p_action, bool p_exact_match) const {
|
||||
float strength;
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, p_exact_match, nullptr, &strength, nullptr);
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>(const_cast<InputEvent *>(this)), p_action, p_exact_match, nullptr, &strength, nullptr);
|
||||
return valid ? strength : 0.0f;
|
||||
}
|
||||
|
||||
float InputEvent::get_action_raw_strength(const StringName &p_action, bool p_exact_match) const {
|
||||
float raw_strength;
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>((InputEvent *)this), p_action, p_exact_match, nullptr, nullptr, &raw_strength);
|
||||
bool valid = InputMap::get_singleton()->event_get_action_status(Ref<InputEvent>(const_cast<InputEvent *>(this)), p_action, p_exact_match, nullptr, nullptr, &raw_strength);
|
||||
return valid ? raw_strength : 0.0f;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ bool InputEvent::is_echo() const {
|
|||
}
|
||||
|
||||
Ref<InputEvent> InputEvent::xformed_by(const Transform2D &p_xform, const Vector2 &p_local_ofs) const {
|
||||
return Ref<InputEvent>((InputEvent *)this);
|
||||
return Ref<InputEvent>(const_cast<InputEvent *>(this));
|
||||
}
|
||||
|
||||
bool InputEvent::action_match(const Ref<InputEvent> &p_event, bool p_exact_match, float p_deadzone, bool *r_pressed, float *r_strength, float *r_raw_strength) const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue