Skip to content

Commit

Permalink
Merge pull request #53742 from DmitriySalnikov/exposed_sensor_setters
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Oct 18, 2021
2 parents 0fb135d + 5cf898b commit c743649
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/os/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ void Input::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_accelerometer"), &Input::get_accelerometer);
ClassDB::bind_method(D_METHOD("get_magnetometer"), &Input::get_magnetometer);
ClassDB::bind_method(D_METHOD("get_gyroscope"), &Input::get_gyroscope);
ClassDB::bind_method(D_METHOD("set_gravity", "value"), &Input::set_gravity);
ClassDB::bind_method(D_METHOD("set_accelerometer", "value"), &Input::set_accelerometer);
ClassDB::bind_method(D_METHOD("set_magnetometer", "value"), &Input::set_magnetometer);
ClassDB::bind_method(D_METHOD("set_gyroscope", "value"), &Input::set_gyroscope);
//ClassDB::bind_method(D_METHOD("get_mouse_position"),&Input::get_mouse_position); - this is not the function you want
ClassDB::bind_method(D_METHOD("get_last_mouse_speed"), &Input::get_last_mouse_speed);
ClassDB::bind_method(D_METHOD("get_mouse_button_mask"), &Input::get_mouse_button_mask);
Expand Down
4 changes: 4 additions & 0 deletions core/os/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ class Input : public Object {
virtual Vector3 get_accelerometer() const = 0;
virtual Vector3 get_magnetometer() const = 0;
virtual Vector3 get_gyroscope() const = 0;
virtual void set_gravity(const Vector3 &p_gravity) = 0;
virtual void set_accelerometer(const Vector3 &p_accel) = 0;
virtual void set_magnetometer(const Vector3 &p_magnetometer) = 0;
virtual void set_gyroscope(const Vector3 &p_gyroscope) = 0;

virtual void action_press(const StringName &p_action, float p_strength = 1.f) = 0;
virtual void action_release(const StringName &p_action) = 0;
Expand Down
32 changes: 32 additions & 0 deletions doc/classes/Input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,14 @@
Removes all mappings from the internal database that match the given GUID.
</description>
</method>
<method name="set_accelerometer">
<return type="void" />
<argument index="0" name="value" type="Vector3" />
<description>
Sets the acceleration value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
[b]Note:[/b] This value can be immediately overwritten by the hardware sensor value on Android and iOS.
</description>
</method>
<method name="set_custom_mouse_cursor">
<return type="void" />
<argument index="0" name="image" type="Resource" />
Expand All @@ -311,6 +319,30 @@
[b]Note:[/b] This method generates an [InputEventMouseMotion] to update cursor immediately.
</description>
</method>
<method name="set_gravity">
<return type="void" />
<argument index="0" name="value" type="Vector3" />
<description>
Sets the gravity value of the accelerometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
[b]Note:[/b] This value can be immediately overwritten by the hardware sensor value on Android and iOS.
</description>
</method>
<method name="set_gyroscope">
<return type="void" />
<argument index="0" name="value" type="Vector3" />
<description>
Sets the value of the rotation rate of the gyroscope sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
[b]Note:[/b] This value can be immediately overwritten by the hardware sensor value on Android and iOS.
</description>
</method>
<method name="set_magnetometer">
<return type="void" />
<argument index="0" name="value" type="Vector3" />
<description>
Sets the value of the magnetic field of the magnetometer sensor. Can be used for debugging on devices without a hardware sensor, for example in an editor on a PC.
[b]Note:[/b] This value can be immediately overwritten by the hardware sensor value on Android and iOS.
</description>
</method>
<method name="set_mouse_mode">
<return type="void" />
<argument index="0" name="mode" type="int" enum="Input.MouseMode" />
Expand Down
8 changes: 4 additions & 4 deletions main/input_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ class InputDefault : public Input {

virtual void parse_input_event(const Ref<InputEvent> &p_event);

void set_gravity(const Vector3 &p_gravity);
void set_accelerometer(const Vector3 &p_accel);
void set_magnetometer(const Vector3 &p_magnetometer);
void set_gyroscope(const Vector3 &p_gyroscope);
virtual void set_gravity(const Vector3 &p_gravity);
virtual void set_accelerometer(const Vector3 &p_accel);
virtual void set_magnetometer(const Vector3 &p_magnetometer);
virtual void set_gyroscope(const Vector3 &p_gyroscope);
void set_joy_axis(int p_device, int p_axis, float p_value);

virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0);
Expand Down

0 comments on commit c743649

Please sign in to comment.