Skip to content

Commit

Permalink
ios tilt initial try with pencil_press also
Browse files Browse the repository at this point in the history
  • Loading branch information
HEAVYPOLY committed Sep 5, 2024
1 parent 0b30c96 commit 72c3dfb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
4 changes: 2 additions & 2 deletions platform/iphone/os_iphone.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
44 changes: 23 additions & 21 deletions platform/iphone/os_iphone.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<InputEventMouseButton> 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<InputEventMouseMotion> 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<InputEventMouseButton> 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<InputEventMouseMotion> 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) {
Expand Down

0 comments on commit 72c3dfb

Please sign in to comment.