Where could I find documentation on how to implement haptic feedback for windows phone 7? I want the phone to give short vibrations when a button is pressed.
Basically all you need to make the phone vibrate is this:
VibrateController.Default.Start(TimeSpan.FromMilliseconds(200));
I suggest to read this blog as it explains it quite well. The other chapters are interesting too if you haven't already seen them.
I created a vibration class for my buttons so that its easy to call. Here is my code. Please give me +1 if you like.
public class Vibration
{
public static void VibrateOnButtonPress()
{
Microsoft.Devices.VibrateController.Default.Start(TimeSpan.FromMilliseconds(50));
System.Windows.Threading.DispatcherTimer timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 0, 0, 200);
timer.Tick += (tsender, tevt) =>
{
var t = tsender as System.Windows.Threading.DispatcherTimer;
t.Stop();
Microsoft.Devices.VibrateController.Default.Stop();
};
timer.Start();
}
}
Perhaps you can use the XNA API to set the vibration of the "GamePad"
http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.input.gamepad.setvibration.aspx
I'd be curious to know if you get it to work in silverlight, please comment after you try it :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With