-
Notifications
You must be signed in to change notification settings - Fork 326
NEW: MouseEvents for InputSystem - Sending data from package & Samples and Tests #2207
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
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop #2207 +/- ##
===========================================
- Coverage 68.15% 68.15% -0.01%
===========================================
Files 367 367
Lines 53662 53586 -76
===========================================
- Hits 36576 36521 -55
+ Misses 17086 17065 -21
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 19 files with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @ritamerkl ! I like the approach and the sample is of reasonable size to test the main functionality. Also really nice to have plenty of tests.
However:
- This functionality needs to be guarded with defines in asmdef, as this will only be available from 6.3 forward AFAIK. So if I try this PR without the trunk PR, I'll get compilation errors.
- I would like to see at least 1 test with Touch as well, particularly with more than 1 touch. Mouse and Pen are pretty similar as they are a single pointer.
Also there's some CI failures that will need to be addressed. Not sure if it's only because of the lack of defines or if there's any impact on pointer devices functionality. |
WIP: working on adding touch samples (multi-touch) & parallel pointers (eg. touch&pen). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great!
I'm happy to see us improving our feature parity! Also thanks for investing the time on the tests!
I've left a few comments, but I'll leave it up to you to decide which ones to address
x = Pointer.current.position.x.value; | ||
y = Pointer.current.position.y.value; | ||
} | ||
else // Fallback to InputManager if InputSystem is not available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to support InputManager on this tests? I would assume they are covered by their original tests in trunk...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no reason why this would use InputManager similar to Leo, I would additionally recommend to rename this script to OnMouseEvents
, or MouseEvents
or similar. The Test
suffix got me thinking I was going to see a NUnit test file or similar
[Category("MouseEvents")] | ||
public IEnumerator PenEvents_CanReceiveOnMouseDown() | ||
{ | ||
var pen = InputSystem.AddDevice<Pen>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we are duplicating the exact same tests for both mouse and pen, I'm wondering if we can parameterize that and just have a single test...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree to previous comment, this isn't necessarily the case any longer either right? "That we have to queue into NativeInputRuntime"?
@@ -0,0 +1,4215 @@ | |||
{ "pid": 11157, "tid": -1, "ph": "M", "name": "process_name", "args": { "name": "il2cpp-compile" } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the untitled folder doesn't need to be included?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see 3 files under "untitled folder", the folder including those files should be removed from this PR right?
@@ -3646,6 +3647,9 @@ private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer ev | |||
//// mess in the event buffer | |||
//// same goes for events that someone may queue from a change monitor callback | |||
InvokeAfterUpdateCallback(updateType); | |||
//send pointer data to backend for OnMouseEvents | |||
if (Pointer.current != null && gameIsPlaying) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ritamerkl Have you checked if Input Manager supports OnMouseXXX events from a script that is marked with [ExecuteInEditorMode]? That could be relevant here...
@@ -3646,6 +3647,9 @@ private unsafe void OnUpdate(InputUpdateType updateType, ref InputEventBuffer ev | |||
//// mess in the event buffer | |||
//// same goes for events that someone may queue from a change monitor callback | |||
InvokeAfterUpdateCallback(updateType); | |||
//send pointer data to backend for OnMouseEvents | |||
if (Pointer.current != null && gameIsPlaying) | |||
NativeInputSystem.SetMouseEventsData(Pointer.current.press.isPressed, Pointer.current.press.wasPressedThisFrame, Pointer.current.position.x.value, Pointer.current.position.y.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be routed via INativeInputRuntime interface and its NativeInputRuntime and TestInputRuntime implementations?
Description
This PR introduces sending pointer data (e.g. mouse, pen, touch...) to native for the OnMouse events driven by the InputSystem. It also adds tests and samples for the OnMouse events working with the InputSystem. The behaviour on native side is introduced with this PR and both PR's should land together, or one (shortly) after the other.
Testing status & QA
Only manual testing for the sample.
Overall Product Risks
Comments to reviewers
Please review together with https://github.cds.internal.unity3d.com/unity/unity/pull/73198.
Checklist
Before review:
Changed
,Fixed
,Added
sections.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.After merge: