Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wp7 Haptic Feedback

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.

like image 911
BigPete Avatar asked Nov 19 '10 14:11

BigPete


3 Answers

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.

like image 130
Francesco De Vittori Avatar answered Nov 09 '22 11:11

Francesco De Vittori


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();
        }
    }
like image 24
Evan Larsen Avatar answered Nov 09 '22 11:11

Evan Larsen


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 :-)

like image 2
Joel Martinez Avatar answered Nov 09 '22 12:11

Joel Martinez