-
Notifications
You must be signed in to change notification settings - Fork 750
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
Updated sample for the issue Add sample for SimpleHapticsController #473 #13994
base: master
Are you sure you want to change the base?
Conversation
New functions of single and double clicks have been added in the code for better expreince
added the press, single click and double click features in the macOS file of the SimpleHapticsController
features been included for the android version as well iun the base code for the PR to egt merged
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.
Thank you for your contribution! I added a few comments, but it's looking good!
Make sure to use conventional commits for your commit message.
#nullable enable | ||
#pragma warning disable CS0618 // obsolete members | ||
#nullable enable | ||
#program warning disable CS0618 // obsolete members |
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.
#program warning disable CS0618 // obsolete members | |
#pragma warning disable CS0618 // obsolete members |
} | ||
else | ||
{ | ||
throw new NotSupportedException("Device does not support vibration"); |
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's probably best if we skip vibrating altogether. It may be common for simulators to not have this feature. We can probably log a debug message instead.
} | ||
else | ||
{ | ||
throw new NotSupportedException("Device does not support vibration"); |
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.
Same here, let's log instead.
{ | ||
long[] pattern = { 0, (long)feedback.Duration.TotalMilliseconds, 50, (long)feedback.Duration.TotalMilliseconds }; | ||
vibrator.Vibrate(VibrationEffect.CreateWaveform(pattern, -1)); | ||
} |
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.
We should be keeping this try/catch, in case there's an unexpected error. Failing haptics should not fail the app.
else if (feedback.Duration.TotalMilliseconds <= 200) | ||
{ | ||
// Potential Double Click - Check time interval with last click | ||
if (lastClickTime.HasValue && (DateTime.Now - lastClickTime.Value).TotalMilliseconds < 200) |
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.
@dr1rrb how do we determine that something is a double tap in gestures? We may want to align this.
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.
We are using this https://github.com/unoplatform/uno/blob/master/src/Uno.UWP/UI/Input/GestureRecognizer.cs#L27
But anyway, I'm not sure to understand the condition and why try to make distinction between simple click and double click. Here we end by doing impact.ImpactOccurred();
anyway. Is it expected ?
GitHub Issue (If applicable): closes #
PR Type
What kind of change does this PR introduce?
What is the current behavior?
What is the new behavior?
Copilot Summary
🤖 Generated by Copilot at a942ba2
This pull request improves the cross-platform support for haptic feedback in the Uno Platform. It fixes and enhances the
SimpleHapticsController
class for Android and macOS devices, using the native APIs to provide more feedback options. It also refactors the iOS implementation, moving the haptic logic to a separateHapticFeedbackManager
class.PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Run
results.Other information
Internal Issue (If applicable):