How to vibrate a PocketPC WM5.0 or 2003 device?
In smartphone platforms there is a
Vibrate API which you can use.
Although MSDN mentioned that it exist in WM5.0,it isn't.
There was a mistake in MSDN documentations.
Searching all over internet I find that there are 2 ways to achieve this.
One way is to use Notify functions like
CeSetUserNotificationEx,and setting trigger time to now.
But unless you display a dialog(using
PUN_DIALOG),you can't use it and also it seems user settings override your program settings!
Another way is using
NLed functions.
Although all people in Google groups and also
Microsoft MVPs,mentioned there is no way to know the led number of vibrator,I find out when you use
NLedGetDeviceInfo on a Led slot,and the
lCycleAdjust is -1, it is your device vibrator's led number!
Here is the code I've written to use vibrate of my device!
I also checked it on some other devices and they all worked!
void LedOn(int id)
{
NLED_SETTINGS_INFO settings;
if (id < 0)
return;
settings.LedNum= id;
settings.OffOnBlink= 1;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &settings);
}
void LedOff(int id)
{
NLED_SETTINGS_INFO settings;
if (id < 0)
return;
settings.LedNum= id;
settings.OffOnBlink= 0;
NLedSetDevice(NLED_SETTINGS_INFO_ID, &settings);
}
int GetVibratorLedNum(void)
{
NLED_COUNT_INFO nci;
int wCount = 0,VibrLed = -1;
NLED_SUPPORTS_INFO sup;
if(NLedGetDeviceInfo(NLED_COUNT_INFO_ID, (PVOID) &nci))
wCount = (int) nci.cLeds;
for (int i=0;i<wCount;i++)
{
sup.LedNum = i;
NLedGetDeviceInfo(NLED_SUPPORTS_INFO_ID,&sup);
if (sup.lCycleAdjust == -1)
{
VibrLed = i;
break;
}
}
return VibrLed;
}- param1 + 1
You also need to add these to your source files!
#include
extern "C" {
BOOL WINAPI NLedGetDeviceInfo( UINT nInfoId, void *pOutput );
BOOL WINAPI NLedSetDevice( UINT nDeviceId, void *pInput );
};
Also note that most PocketPcs do not support vibrators,mostly PocketPc Phone editions do.