-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(VibrationDevice): Support for macOS
- Loading branch information
1 parent
6eb7666
commit 1838e46
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Uno.UWP/Devices/Haptics/SimpleHapticsController.macOS.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using AppKit; | ||
|
||
namespace Windows.Devices.Haptics | ||
{ | ||
public partial class SimpleHapticsController | ||
{ | ||
public IReadOnlyList<SimpleHapticsControllerFeedback> SupportedFeedback { get; } = new SimpleHapticsControllerFeedback[] | ||
{ | ||
new SimpleHapticsControllerFeedback(KnownSimpleHapticsControllerWaveforms.Press, TimeSpan.Zero) | ||
}; | ||
|
||
public void SendHapticFeedback(SimpleHapticsControllerFeedback feedback) | ||
{ | ||
if (feedback.Waveform != KnownSimpleHapticsControllerWaveforms.Press) | ||
{ | ||
throw new NotSupportedException("Unsupported feedback waveform"); | ||
} | ||
NSHapticFeedbackManager.DefaultPerformer.PerformFeedback( | ||
NSHapticFeedbackPattern.Generic, | ||
NSHapticFeedbackPerformanceTime.Default); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace Windows.Devices.Haptics | ||
{ | ||
public partial class VibrationDevice | ||
{ | ||
private static Task<VibrationAccessStatus> RequestAccessTaskAsync() => | ||
Task.FromResult(VibrationAccessStatus.Allowed); | ||
|
||
private static Task<VibrationDevice> GetDefaultTaskAsync() => | ||
Task.FromResult(new VibrationDevice()); | ||
} | ||
} |