Bug 679966, part 2: Add mozVibrator() for "playing" a vibration pattern. r=bz
This commit is contained in:
@@ -50,16 +50,28 @@ Vibrate(const nsTArray<uint32> &pattern, const WindowIdentifier &)
|
||||
// hal_sandbox::Vibrate, and hal_impl::Vibrate all must have the same
|
||||
// signature.
|
||||
|
||||
// Strangely enough, the Android Java API seems to treat vibrate([0]) as a
|
||||
// nop. But we want to treat vibrate([0]) like CancelVibrate! (Note that we
|
||||
// also need to treat vibrate([]) as a call to CancelVibrate.)
|
||||
bool allZero = true;
|
||||
for (uint32 i = 0; i < pattern.Length(); i++) {
|
||||
if (pattern[i] != 0) {
|
||||
allZero = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (allZero) {
|
||||
hal_impl::CancelVibrate(WindowIdentifier());
|
||||
return;
|
||||
}
|
||||
|
||||
AndroidBridge* b = AndroidBridge::Bridge();
|
||||
if (!b) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pattern.Length() == 0) {
|
||||
b->CancelVibrate();
|
||||
} else {
|
||||
b->Vibrate(pattern);
|
||||
}
|
||||
b->Vibrate(pattern);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user