Skip to content

Commit

Permalink
feat(VibrationDevice): Support for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Oct 14, 2020
1 parent 6eb7666 commit 1838e46
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Uno.UWP/Devices/Haptics/SimpleHapticsController.macOS.cs
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);
}
}
}
13 changes: 13 additions & 0 deletions src/Uno.UWP/Devices/Haptics/VibrationDevice.macOS.cs
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());
}
}

0 comments on commit 1838e46

Please sign in to comment.