Implement amplitude to Input.vibrate_handheld
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> Co-authored-by: m4gr3d <m4gr3d@users.noreply.github.com>
This commit is contained in:
parent
4e9543d849
commit
789c6ebdfd
17 changed files with 132 additions and 35 deletions
41
core/input/input.compat.inc
Normal file
41
core/input/input.compat.inc
Normal file
|
|
@ -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) {
|
||||
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
|
||||
|
|
@ -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,7 +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_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);
|
||||
|
|
@ -803,8 +804,8 @@ void Input::stop_joy_vibration(int p_device) {
|
|||
joy_vibration[p_device] = vibration;
|
||||
}
|
||||
|
||||
void Input::vibrate_handheld(int p_duration_ms) {
|
||||
OS::get_singleton()->vibrate_handheld(p_duration_ms);
|
||||
void Input::vibrate_handheld(int p_duration_ms, float p_amplitude) {
|
||||
OS::get_singleton()->vibrate_handheld(p_duration_ms, p_amplitude);
|
||||
}
|
||||
|
||||
void Input::set_gravity(const Vector3 &p_gravity) {
|
||||
|
|
|
|||
|
|
@ -264,6 +264,11 @@ private:
|
|||
|
||||
EventDispatchFunc event_dispatch_function = nullptr;
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
void _vibrate_handheld_bind_compat_91143(int p_duration_ms = 500);
|
||||
static void _bind_compatibility_methods();
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
|
|
@ -323,7 +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(int p_duration_ms = 500, float p_amplitude = -1.0);
|
||||
|
||||
void set_mouse_position(const Point2 &p_posf);
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ public:
|
|||
virtual int get_process_id() const;
|
||||
virtual bool is_process_running(const ProcessID &p_pid) const = 0;
|
||||
virtual int get_process_exit_code(const ProcessID &p_pid) const = 0;
|
||||
virtual void vibrate_handheld(int p_duration_ms = 500) {}
|
||||
virtual void vibrate_handheld(int p_duration_ms = 500, float p_amplitude = -1.0) {}
|
||||
|
||||
virtual Error shell_open(const String &p_uri);
|
||||
virtual Error shell_show_in_file_manager(String p_path, bool p_open_folder = true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue