From 72c3dfb26d6e52b442e08163b03884207968f079 Mon Sep 17 00:00:00 2001 From: HEAVYPOLY Date: Thu, 5 Sep 2024 08:42:48 -0700 Subject: [PATCH] ios tilt initial try with pencil_press also --- platform/iphone/os_iphone.h | 4 ++-- platform/iphone/os_iphone.mm | 44 +++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 3c18578b0a23..e46309d30f39 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -143,9 +143,9 @@ class OSIPhone : public OS_Unix { virtual int get_screen_dpi(int p_screen = -1) const; virtual float get_screen_refresh_rate(int p_screen = -1) const; - void pencil_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick); + void pencil_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick, float p_tilt_x, float p_tilt_y); void touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick); - void pencil_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_force); + void pencil_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_force, float p_tilt_x, float p_tilt_y); void touch_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y); void touches_cancelled(int p_idx); void pencil_cancelled(int p_idx); diff --git a/platform/iphone/os_iphone.mm b/platform/iphone/os_iphone.mm index 85c246618de2..2a522eec1ef9 100644 --- a/platform/iphone/os_iphone.mm +++ b/platform/iphone/os_iphone.mm @@ -269,29 +269,31 @@ perform_event(ev); }; -void OSIPhone::pencil_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick) { - Ref ev; - ev.instance(); - ev->set_button_index(1); - ev->set_pressed(p_pressed); - ev->set_position(Vector2(p_x, p_y)); - ev->set_global_position(Vector2(p_x, p_y)); - ev->set_doubleclick(p_doubleclick); - perform_event(ev); -}; - -void OSIPhone::pencil_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_force) { - Ref ev; - ev.instance(); - ev->set_pressure(p_force); - ev->set_position(Vector2(p_x, p_y)); - ev->set_global_position(Vector2(p_x, p_y)); - ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y)); - perform_event(ev); -}; +void OSIPhone::pencil_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick, float p_tilt_x, float p_tilt_y) { + Ref ev; + ev.instance(); + ev->set_button_index(1); + ev->set_pressed(p_pressed); + ev->set_position(Vector2(p_x, p_y)); + ev->set_global_position(Vector2(p_x, p_y)); + ev->set_doubleclick(p_doubleclick); + ev->set_tilt(Vector2(p_tilt_x, p_tilt_y)); + perform_event(ev); +} + +void OSIPhone::pencil_drag(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, float p_force, float p_tilt_x, float p_tilt_y) { + Ref ev; + ev.instance(); + ev->set_pressure(p_force); + ev->set_tilt(Vector2(p_tilt_x, p_tilt_y)); + ev->set_position(Vector2(p_x, p_y)); + ev->set_global_position(Vector2(p_x, p_y)); + ev->set_relative(Vector2(p_x - p_prev_x, p_y - p_prev_y)); + perform_event(ev); +} void OSIPhone::pencil_cancelled(int p_idx) { - pencil_press(p_idx, -1, -1, false, false); + pencil_press(p_idx, -1, -1, false, false, 0, 0); } void OSIPhone::touch_press(int p_idx, int p_x, int p_y, bool p_pressed, bool p_doubleclick) {