summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
authorHansem Ro <hansemro@outlook.com>2022-06-19 02:58:24 -0700
committerHansem Ro <hansemro@outlook.com>2022-07-04 10:36:53 -0700
commit6dcc9d11319ddb59089fb54551f852249081e027 (patch)
treeea7e0cb977967dc95ef860d5e5d9237db87b265c /platform/osx
parentd572d3d2abf07ace216fd31f7ace97e4bfc76cc5 (diff)
[macOS, Windows, X11] Add stylus inverted/eraser support to
InputEventMouseMotion event
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/godot_content_view.h1
-rw-r--r--platform/osx/godot_content_view.mm9
2 files changed, 9 insertions, 1 deletions
diff --git a/platform/osx/godot_content_view.h b/platform/osx/godot_content_view.h
index 7942d716dc..353305aec1 100644
--- a/platform/osx/godot_content_view.h
+++ b/platform/osx/godot_content_view.h
@@ -52,6 +52,7 @@
bool ime_input_event_in_progress;
bool mouse_down_control;
bool ignore_momentum_scroll;
+ bool last_pen_inverted;
}
- (void)processScrollEvent:(NSEvent *)event button:(MouseButton)button factor:(double)factor;
diff --git a/platform/osx/godot_content_view.mm b/platform/osx/godot_content_view.mm
index e96f0a8098..018b90e629 100644
--- a/platform/osx/godot_content_view.mm
+++ b/platform/osx/godot_content_view.mm
@@ -42,6 +42,7 @@
ime_input_event_in_progress = false;
mouse_down_control = false;
ignore_momentum_scroll = false;
+ last_pen_inverted = false;
[self updateTrackingAreas];
if (@available(macOS 10.13, *)) {
@@ -377,9 +378,15 @@
ds->update_mouse_pos(wd, mpos);
mm->set_position(wd.mouse_pos);
mm->set_pressure([event pressure]);
- if ([event subtype] == NSEventSubtypeTabletPoint) {
+ NSEventSubtype subtype = [event subtype];
+ if (subtype == NSEventSubtypeTabletPoint) {
const NSPoint p = [event tilt];
mm->set_tilt(Vector2(p.x, p.y));
+ mm->set_pen_inverted(last_pen_inverted);
+ } else if (subtype == NSEventSubtypeTabletProximity) {
+ // Check if using the eraser end of pen only on proximity event.
+ last_pen_inverted = [event pointingDeviceType] == NSPointingDeviceTypeEraser;
+ mm->set_pen_inverted(last_pen_inverted);
}
mm->set_global_position(wd.mouse_pos);
mm->set_velocity(Input::get_singleton()->get_last_mouse_velocity());