-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add iOS Android pen pressure / tilt support #735
Comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I would like to work on this for Android.
These would than need to be made availible for GdScript as well I would expect, but I'm not that experienced with the Godot Engine Development yet, so a direction what would need to be done for that would be great. |
@ModProg for iOS we are treating pen input as mouse motion events because mouse motion events already have pressure, tilt etc on desktop. I think it would be good to follow this pattern. |
@HEAVYPOLY So you would suggest use mouse for https://developer.android.com/reference/android/view/InputDevice#SOURCE_STYLUS ? I will try that, but we should make sure that that is correctly set on all devices. iOS had force touch for example, I don't know if any android Phones had/have something similar. Or should pressure on touch be a seperate issue? |
Yea I think stylus should be handled as mouse event because that's how it behaves on desktop and iOS, to keep consistency across all platforms. Also because mouse motion already has pressure / tilt properties. |
@HEAVYPOLY should |
I think so although I'm pretty new to cpp. @m4gr3d might know better. On iOS we did it like this: pencil events sends a regular mouse event with pressure like this: 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));
ev->set_tilt(p_tilt);
perform_event(ev);
}; - (void)touchesBegan:(NSSet *)touchesSet withEvent:(UIEvent *)event {
NSArray *tlist = [event.allTouches allObjects];
for (unsigned int i = 0; i < [tlist count]; i++) {
if ([touchesSet containsObject:[tlist objectAtIndex:i]]) {
UITouch *touch = [tlist objectAtIndex:i];
int tid = [self getTouchIDForTouch:touch];
ERR_FAIL_COND(tid == -1);
CGPoint touchPoint = [touch locationInView:self];
if (touch.type == UITouchTypeStylus) {
OSIPhone::get_singleton()->pencil_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1);
} else {
OSIPhone::get_singleton()->touch_press(tid, touchPoint.x * self.contentScaleFactor, touchPoint.y * self.contentScaleFactor, true, touch.tapCount > 1);
}
}
}
} |
cc @thebestnom for feedback. |
One way that I've found to differentiate between the input type is that |
Android support was implemented in godotengine/godot#80644 iOS would still be missing I suppose. Would be nice to have feature parity in 4.2 if we can (cc @bruvzg). |
Support for iOS is implemented in godotengine/godot#70482 |
Closing, as this is now implemented on both mobile platforms as requested in the proposal. (Pen pressure/tilt should be functional on desktop platforms in 4.1 already.) |
Describe the project you are working on:
HEAVYPAINT - Multiplatform graphic painting app www.heavypoly.com/heavypaint
Describe the problem or limitation you are having in your project:
pen pressure / tilt not working on Android or iOS
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
add pen pressure/tilt support for iOS/ (iPad pro) and Android (Samsung note 9 pen)
Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
same as how desktop versions work now
If this enhancement will not be used often, can it be worked around with a few lines of script?:
no
Is there a reason why this should be core and not an add-on in the asset library?:
should behave the same as desktop
The text was updated successfully, but these errors were encountered: