diff options
author | BastiaanOlij <mux213@gmail.com> | 2016-11-23 23:32:44 +1100 |
---|---|---|
committer | BastiaanOlij <mux213@gmail.com> | 2017-01-12 16:37:27 +1100 |
commit | 5e4dcb3b7f93cfe19a5c12700df5a7c82045f37c (patch) | |
tree | ef8522125e50a60f467750daa6243ad3decaea24 /main | |
parent | efa9ded5f9d0f8176dcdd17c09de6fa9df926f45 (diff) |
Added support for getting gravity vector from iOS
Diffstat (limited to 'main')
-rw-r--r-- | main/input_default.cpp | 14 | ||||
-rw-r--r-- | main/input_default.h | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index 6f27bcdc5a..c2c4e28854 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -277,6 +277,12 @@ void InputDefault::joy_connection_changed(int p_idx, bool p_connected, String p_ emit_signal("joy_connection_changed", p_idx, p_connected); }; +Vector3 InputDefault::get_gravity() const{ + + _THREAD_SAFE_METHOD_ + return gravity; +} + Vector3 InputDefault::get_accelerometer() const{ _THREAD_SAFE_METHOD_ @@ -423,6 +429,14 @@ void InputDefault::stop_joy_vibration(int p_device) { joy_vibration[p_device] = vibration; } +void InputDefault::set_gravity(const Vector3& p_gravity) { + + _THREAD_SAFE_METHOD_ + + gravity=p_gravity; + +} + void InputDefault::set_accelerometer(const Vector3& p_accel) { _THREAD_SAFE_METHOD_ diff --git a/main/input_default.h b/main/input_default.h index 33a852ab10..fe7e89d771 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -44,6 +44,7 @@ class InputDefault : public Input { Set<int> joy_buttons_pressed; Map<int,float> _joy_axis; //Map<StringName,int> custom_action_press; + Vector3 gravity; Vector3 accelerometer; Vector3 magnetometer; Vector3 gyroscope; @@ -191,6 +192,7 @@ public: void joy_connection_changed(int p_idx, bool p_connected, String p_name, String p_guid = ""); void parse_joypad_mapping(String p_mapping, bool p_update_existing); + virtual Vector3 get_gravity() const; virtual Vector3 get_accelerometer() const; virtual Vector3 get_magnetometer() const; virtual Vector3 get_gyroscope() const; @@ -203,6 +205,7 @@ public: void parse_input_event(const 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); |