-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add amplitude
argument to Input.vibrate_handheld
#91143
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to register compatibility methods, I'll write a diff for you later today if needed, you can see this as a reference for how to do it:
Is it required if it just adds another argument with a default value? It will continue to do the same behavior as previously, but now it has another argument that can be tweaked if need be |
Yes, it's about binary compatibility, not general compatibility being broken, check the PR linked and this: |
eb6175d
to
66be41a
Compare
Please apply this diff, it provides the correct way to add compatibility (as seen in the PR linked above): diff --git a/core/input/input.compat.inc b/core/input/input.compat.inc
new file mode 100644
index 0000000000..46df255607
--- /dev/null
+++ b/core/input/input.compat.inc
@@ -0,0 +1,41 @@
+/**************************************************************************/
+/* input.compat.inc */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef DISABLE_DEPRECATED
+
+void Input::_vibrate_handheld_bind_compat_91143(int p_duration_ms = 500) {
+ vibrate_handheld(p_duration_ms, 1.0);
+}
+
+void Input::_bind_compatibility_methods() {
+ ClassDB::bind_compatibility_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::_vibrate_handheld_bind_compat_91143, DEFVAL(500));
+}
+
+#endif // DISABLE_DEPRECATED
diff --git a/core/input/input.cpp b/core/input/input.cpp
index 6a4efd555c..fa5a1881d4 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -29,6 +29,7 @@
/**************************************************************************/
#include "input.h"
+#include "input.compat.inc"
#include "core/config/project_settings.h"
#include "core/input/default_controller_mappings.h"
@@ -120,8 +121,7 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_joy_vibration_duration", "device"), &Input::get_joy_vibration_duration);
ClassDB::bind_method(D_METHOD("start_joy_vibration", "device", "weak_magnitude", "strong_magnitude", "duration"), &Input::start_joy_vibration, DEFVAL(0));
ClassDB::bind_method(D_METHOD("stop_joy_vibration", "device"), &Input::stop_joy_vibration);
- ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms"), &Input::vibrate_handheld, DEFVAL(500));
- ClassDB::bind_compatibility_method(D_METHOD("vibrate_handheld", "duration_ms", "amplitude"), &Input::vibrate_handheld_amp, DEFVAL(500), DEFVAL(1.0));
+ ClassDB::bind_method(D_METHOD("vibrate_handheld", "duration_ms", "amplitude"), &Input::vibrate_handheld, DEFVAL(500), DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("get_gravity"), &Input::get_gravity);
ClassDB::bind_method(D_METHOD("get_accelerometer"), &Input::get_accelerometer);
ClassDB::bind_method(D_METHOD("get_magnetometer"), &Input::get_magnetometer);
@@ -804,14 +804,10 @@ void Input::stop_joy_vibration(int p_device) {
joy_vibration[p_device] = vibration;
}
-void Input::vibrate_handheld_amp(int p_duration_ms, float p_amplitude) {
+void Input::vibrate_handheld(int p_duration_ms, float p_amplitude) {
OS::get_singleton()->vibrate_handheld(p_duration_ms, p_amplitude);
}
-void Input::vibrate_handheld(int p_duration_ms) {
- OS::get_singleton()->vibrate_handheld(p_duration_ms, 1.0);
-}
-
void Input::set_gravity(const Vector3 &p_gravity) {
_THREAD_SAFE_METHOD_
diff --git a/core/input/input.h b/core/input/input.h
index 43a8fee625..08b90645f0 100644
--- a/core/input/input.h
+++ b/core/input/input.h
@@ -267,6 +267,11 @@ private:
protected:
static void _bind_methods();
+#ifndef DISABLE_DEPRECATED
+ void _vibrate_handheld_bind_compat_91143(int p_duration_ms = 500);
+ static void _bind_compatibility_methods();
+#endif // DISABLE_DEPRECATED
+
public:
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
@@ -323,8 +328,7 @@ public:
void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
void stop_joy_vibration(int p_device);
- void vibrate_handheld(int p_duration_ms = 500);
- void vibrate_handheld_amp(int p_duration_ms = 500, float amplitude = 1.0);
+ void vibrate_handheld(int p_duration_ms = 500, float p_amplitude = 1.0);
void set_mouse_position(const Point2 &p_posf);
|
Strange, it should work as it's extracted directly from this PR, try applying it manually |
79582c1
to
ccc5d32
Compare
ebf5cf5
to
a4ed205
Compare
a4ed205
to
a4fbe4c
Compare
Fuck |
b15d71e
to
fac54c9
Compare
Technically my first time ever playing around with iOS documentation, i absolutely hate it 😊 |
fac54c9
to
0b80f73
Compare
Thank you for picking up on my proposal, I absolutely didn't expect someone else to implement it, and so quickly too! |
ebb21dc
to
bb92fe1
Compare
Can this be moved to the 4.4 milestone? |
bb92fe1
to
f38b195
Compare
bbcb57a
to
ae13e2f
Compare
ae13e2f
to
720d65e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Looks good! Could you squash the commits? See PR workflow for instructions. |
I'll definitely try to but it says there's 130 commits in VSC 😭 |
720d65e
to
0e8b7d4
Compare
Done! |
amplitude
to Input.vibrate_handheldamplitude
to Input.vibrate_handheld
0e8b7d4
to
34969e4
Compare
34969e4
to
44d1ab1
Compare
amplitude
to Input.vibrate_handheld
amplitude
argument to Input.vibrate_handheld
Looks good to me. Needs a rebase to solve a merge conflict. |
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: m4gr3d <m4gr3d@users.noreply.github.com>
44d1ab1
to
789c6eb
Compare
Thanks! |
Input.vibrate_handheld
godot-proposals#9582