void Vibrate(const nsTArray<uint32_t>& pattern, const WindowIdentifier &id) { AssertMainThread(); // Only active windows may start vibrations. If |id| hasn't gone // through the IPC layer -- that is, if our caller is the outside // world, not hal_proxy -- check whether the window is active. If // |id| has gone through IPC, don't check the window's visibility; // only the window corresponding to the bottommost process has its // visibility state set correctly. if (!id.HasTraveledThroughIPC() && !WindowIsActive(id.GetWindow())) { HAL_LOG(("Vibrate: Window is inactive, dropping vibrate.")); return; } if (!InSandbox()) { if (!gLastIDToVibrate) { InitLastIDToVibrate(); } *gLastIDToVibrate = id.AsArray(); } // Don't forward our ID if we are not in the sandbox, because hal_impl // doesn't need it, and we don't want it to be tempted to read it. The // empty identifier will assert if it's used. PROXY_IF_SANDBOXED(Vibrate(pattern, InSandbox() ? id : WindowIdentifier())); }
void InputGamePad::StopVibrate() { // Call the vibrate function with no vibrations on each motor Vibrate(0.0f, 0.0f); m_vibrating = false; }
void doSmartPhoneVibra() { HINSTANCE hInst = LoadLibrary(_T("aygshell.dll")); if (hInst) { HRESULT (*Vibrate)(DWORD cvn, const VIBRATENOTE * rgvn, BOOL fRepeat, DWORD dwTimeout); (FARPROC&)Vibrate = GetProcAddress(hInst, _T("Vibrate")); if (Vibrate) { HRESULT retval=Vibrate(0, NULL, true, 2000); retval++; } FreeLibrary(hInst); } }
void SeparateConference::addMessage(const QString &from, const QString &message, const QString &date, bool history) { if ( !history ) checkForActive(message); if ( m_text_browser ) { quint64 tmp_position = m_text_browser->textCursor().position(); QString add_text; add_text.append(m_mine_nick != from ?QString("<b><font color=#0000FF>"):QString("<b><font color=#FF0000>")); if (message.contains(m_mine_nick)) qDebug() << "message.contains(m_mine_nick)"; if (m_mine_nick != from) qDebug() << "m_mine_nick != from"; if ((message.contains(m_mine_nick)) && (m_mine_nick != from)) Vibrate(); add_text.append(QString("[%1]").arg(date)); /* if ( m_show_names )*/ { add_text.append(QString(" %1").arg(Qt::escape(from))); } add_text.append(": </font></b>"); add_text.append(QString("%1<br>").arg(checkForEmoticons(message))); m_current_scroll_position = m_text_browser->verticalScrollBar()->value(); m_scroll_at_max = m_text_browser->verticalScrollBar()->maximum() == m_current_scroll_position; m_text_browser->moveCursor(QTextCursor::End); m_text_browser->insertHtml(add_text); moveCursorToEnd(); if ( m_remove_message_after ) { if ( m_message_positions.count() >= m_remove_count ) { int message_length = m_message_positions.at(0); QTextCursor cursor = m_text_browser->textCursor(); cursor.clearSelection(); cursor.setPosition(0, QTextCursor::MoveAnchor); cursor.setPosition(message_length, QTextCursor::KeepAnchor); cursor.removeSelectedText(); m_message_positions.removeAt(0); } m_message_positions.append(m_text_browser->textCursor().position() - tmp_position); } } /* if (m_mine_nick != from && message.contains(m_mine_nick)) { m_tab_compl->setLastReferrer(from); }*/ }
void Notification::Run(const String& command) { if(!command.IsEmpty()) { Uri commandUri; commandUri.SetUri(command); String method = commandUri.GetHost(); StringTokenizer strTok(commandUri.GetPath(), L"/"); if(strTok.GetTokenCount() < 1) { AppLogException("Not enough params"); return; } if((method == L"com.phonegap.Notification.alert" || method == L"com.phonegap.Notification.confirm")) { strTok.GetNextToken(callbackId); AppLogDebug("%S %S", method.GetPointer(), callbackId.GetPointer()); if(!callbackId.IsEmpty()) { Dialog(); } } else if(method == L"com.phonegap.Notification.vibrate") { long duration; String durationStr; strTok.GetNextToken(durationStr); AppLogDebug("%S %S", method.GetPointer(), durationStr.GetPointer()); // Parsing duration result r = Long::Parse(durationStr, duration); if(IsFailed(r)) { AppLogException("Could not parse duration"); return; } Vibrate(duration); } else if(method == L"com.phonegap.Notification.beep") { int count; String countStr; strTok.GetNextToken(countStr); AppLogDebug("%S %S", method.GetPointer(), countStr.GetPointer()); // Parsing count result r = Integer::Parse(countStr, count); if(IsFailed(r)) { AppLogException("Could not parse count"); return; } Beep(count); } } }
void Vibrate(const nsTArray<uint32>& pattern, nsIDOMWindow* window) { Vibrate(pattern, WindowIdentifier(window)); }
//return 0 to stop static int HandleEvents() { int i, j, k, m; FD_ZERO(&rfds); for (i=0; i<=MAX_INPUT_FILE_ID; i++) { if (inputEvents[i] > 0) { FD_SET(inputEvents[i], &rfds); } } if (exitFlag) return 0; int retval = select(maxEventPlusOne, &rfds, NULL, NULL, NULL); if (exitFlag) return 0; if (retval == 0) { return 1; } else if (retval == -1) { printf("Error: Select() fails\n"); exit(0); } for (i=0; i<=MAX_INPUT_FILE_ID; i++) { if (inputEvents[i] == -1) continue; if (!(FD_ISSET(inputEvents[i], &rfds))) continue; int rd = read(inputEvents[i], events, sizeof(struct input_event) * N_EVENTS); int nEvents = rd / sizeof(struct input_event); m = nKeyEntries[i]; for (j=0; j<nEvents; j++) { int arg1 = events[j].type; int arg2 = events[j].code; int arg3 = events[j].value; double tm = GetTimestamp(&events[j].time); for (k=0; k<m; k++) { //a "-1" entry for arg3 means anything positive //a "-2" entry for arg3 means anything (positive or zero) if (keyEntries[i][k].arg1 == arg1 && keyEntries[i][k].arg2 == arg2 && (keyEntries[i][k].arg3 == arg3 || (keyEntries[i][k].arg3 == -1 && arg3>0) || keyEntries[i][k].arg3 == -2) ) { int e = keyEntries[i][k].event; #ifdef TEST_INPUT printf("%.6lf %s %s", tm, event_str[keyEntries[i][k].event], action_str[keyEntries[i][k].action] ); if (e == EVENT_HORIZONTAL || e == EVENT_VERTICAL) { printf(" %d\n", arg3); } else { printf("\n"); } #endif fprintf(ofsEvents, "%.6lf %s %s", tm, event_str[keyEntries[i][k].event], action_str[keyEntries[i][k].action] ); if (e == EVENT_HORIZONTAL || e == EVENT_VERTICAL) { fprintf(ofsEvents, " %d\n", arg3); } else { fprintf(ofsEvents, "\n"); } if (++flushCount % FLUSH_INTERVAL == 0) fflush(ofsEvents); //rapid push if (e == EVENT_VERTICAL) { if (arg3 >= COMPLAIN_VERTICAL_RANGE) bValidVertPos = 0; } if (e == EVENT_SCREEN && keyEntries[i][k].action == ACTION_RELEASE) { if (bValidVertPos) { if (tm - lastReleaseTime < RAPID_PUSH_INTERVAL) { if (++rapidPushCount >= PUSH_COUNT_TO_COMPLAIN) { #ifdef TEST_INPUT printf("%.6lf %.6lf complain\n", firstReleaseTime, tm); #endif fprintf(ofsEvents, "%.6lf %.6lf complain\n", firstReleaseTime, tm); Vibrate(); rapidPushCount = 0; lastReleaseTime = -100.0f; } else { rapidPushCount++; lastReleaseTime = tm; if (rapidPushCount == 1) firstReleaseTime = tm; } } else { rapidPushCount = 1; lastReleaseTime = tm; firstReleaseTime = tm; } } else { rapidPushCount = 0; lastReleaseTime = -100.0f; } bValidVertPos = 1; } } } } } return 1; }
void Vibrate(const nsTArray<uint32>& pattern) { AssertMainThread(); PROXY_IF_SANDBOXED(Vibrate(pattern)); }