void Canvas::mouseReleaseEvent ( QGraphicsSceneMouseEvent * mouseEvent ) { Q_UNUSED(mouseEvent); if(forwardEvent()) { if(!m_movingItems.isEmpty()) { if (m_movingItems.first() != nullptr && mouseEvent->button() == Qt::LeftButton) { if (m_oldPos.first() != m_movingItems.first()->pos()) { MoveFieldCommand* moveCmd = new MoveFieldCommand(m_movingItems,m_oldPos); m_undoStack->push(moveCmd); } m_movingItems.clear(); m_oldPos.clear(); } } QGraphicsScene::mouseReleaseEvent(mouseEvent); } else { adjustNewItem(m_currentItem); m_currentItem=nullptr; } }
void WindowImplAndroid::processPointerEvent(bool isDown, AInputEvent* _event, ActivityStates* states) { int32_t device = AInputEvent_getSource(_event); int32_t action = AMotionEvent_getAction(_event); int index = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; int id = AMotionEvent_getPointerId(_event, index); float x = AMotionEvent_getX(_event, index); float y = AMotionEvent_getY(_event, index); Event event; if (isDown) { if (device == AINPUT_SOURCE_MOUSE) { event.type = Event::MouseButtonPressed; event.mouseButton.button = static_cast<Mouse::Button>(id); event.mouseButton.x = x; event.mouseButton.y = y; if (id >= 0 && id < Mouse::ButtonCount) states->isButtonPressed[id] = true; } else if (device == AINPUT_SOURCE_TOUCHSCREEN) { event.type = Event::TouchBegan; event.touch.finger = id; event.touch.x = x; event.touch.y = y; states->touchEvents[id] = Vector2i(event.touch.x, event.touch.y); } } else { if (device == AINPUT_SOURCE_MOUSE) { event.type = Event::MouseButtonReleased; event.mouseButton.button = static_cast<Mouse::Button>(id); event.mouseButton.x = x; event.mouseButton.y = y; if (id >= 0 && id < Mouse::ButtonCount) states->isButtonPressed[id] = false; } else if (device == AINPUT_SOURCE_TOUCHSCREEN) { event.type = Event::TouchEnded; event.touch.finger = id; event.touch.x = x; event.touch.y = y; states->touchEvents.erase(id); } } forwardEvent(event); }
bool ZeroConfDiscoverEventHandler::handle(osgGA::Event* event, osg::Object* object, osg::NodeVisitor* nv) { if ((event->getName() == "/zeroconf/service-added") || (event->getName() == "/zeroconf/service-removed")) { std::string host(""), type(""); unsigned int port(0); event->getUserValue("host", host); event->getUserValue("port", port); event->getUserValue("type", type); host = IOSUtils::lookupHost(host); if (type == httpServiceType()) { std::ostringstream ss; ss << "http://" << host << ":" << port << "/interface.p3d"; if (event->getName() == "/zeroconf/service-added") { if (!P3DAppInterface::instance()->getRemoteFiles()->add(ss.str())) { OSG_WARN << "ZeroConfDiscoverEventHandler :: could not add " << ss.str() << " to remote files" << std::endl; } } else { if (!P3DAppInterface::instance()->getRemoteFiles()->remove(ss.str())) { OSG_WARN << "ZeroConfDiscoverEventHandler :: could not remove " << ss.str() << " to remote files" << std::endl; } } P3DAppInterface::instance()->refreshInterface(); return true; } else if (type == oscServiceType()) { if (event->getName() == "/zeroconf/service-added") { P3DAppInterface::instance()->getOscController()->addAutoDiscoveredHostAndPort(host, port); P3DAppInterface::instance()->getOscController()->checkConnection(); } else { P3DAppInterface::instance()->getOscController()->removeAutoDiscoveredHostAndPort(host, port); P3DAppInterface::instance()->getOscController()->checkConnection(); } P3DAppInterface::instance()->refreshInterface(); return true; } } if (!event->asGUIEventAdapter()) { forwardEvent(*event); return true; } return osgGA::GUIEventHandler::handle(event, object, nv); }
void EventHandler::customEvent(QEvent *e) { if (e->type() == 10001) { // Forward the event to the next in the chain forwardEvent(e); MClientEvent* me = static_cast<MClientEvent*>(e); if(me->dataTypes().contains("SendToSocketData")) { QByteArray ba = me->payload()->toByteArray(); sendData(ba); } else if (me->dataTypes().contains("ConnectToHost")) { connectDevice(me->payload()->toString()); } else if (me->dataTypes().contains("DisconnectFromHost")) { //QString arg = me->payload()->toString(); disconnectDevice(); } else if (me->dataTypes().contains("MUMEPromptGARequest")) { //do not allow server to suppress go-aheads (MUME is backwards) sendMUMEGARequest(); } else if (me->dataTypes().contains("DoneLoading")) { // auto connect on session start if (_autoConnect) connectDevice(); } } else qDebug() << "SocketManagerIO got a customEvent of type" << e->type(); }
EventViewer::EventViewer(QWidget *parent) : QWidget(parent) { EVLayout = new QVBoxLayout(this); m_data = 0; setMinimumHeight(500); titleLabel = new QLabel; setTitleLabel("DEMO"); EVLayout->addWidget(titleLabel); evt_plot = new Plot(this); rasterData = (SpectrogramData*) evt_plot->getSpectrogram()->data(); rasterData->resetData(); evt_plot->setMaximumSize(640,160); evt_plot->setMinimumSize(640,160); evt_plot->showContour(false); evt_plot->updateScale(); EVLayout->addWidget(evt_plot); btnLayout = new QHBoxLayout(); evtN_lab = new QLabel("Event N:",this); evtN_lcd = new QLCDNumber(6,this); integrate_chbx = new QCheckBox("Integrate",this); integrate_chbx->setProperty("isPixel",false); nextEvent_pbtn = new QPushButton(QIcon(":/images/next.png"),"Next",this); prevEvent_pbtn= new QPushButton(QIcon(":/images/prev.png"),"Prev",this);; rwd_pbtn = new QPushButton(QIcon(":/images/rew.png"),"RWD",this); fwd_pbtn = new QPushButton(QIcon(":/images/fwd.png"),"FWD",this); connect(nextEvent_pbtn, SIGNAL(clicked()), this, SLOT(nextEvent())); connect(prevEvent_pbtn, SIGNAL(clicked()), this, SLOT(prevEvent())); connect(rwd_pbtn, SIGNAL(clicked()), this, SLOT(rewindEvent())); connect(fwd_pbtn, SIGNAL(clicked()), this, SLOT(forwardEvent())); btnLayout->addWidget(evtN_lab); btnLayout->addWidget(evtN_lcd); btnLayout->addWidget(integrate_chbx); btnLayout->addWidget(prevEvent_pbtn); btnLayout->addWidget(nextEvent_pbtn); btnLayout->addWidget(rwd_pbtn); btnLayout->addWidget(fwd_pbtn); EVLayout->addLayout(btnLayout); evtView = new QTreeView(this); setupModel(); evtView->setColumnWidth(0 , 180); EVLayout->addWidget(evtView); }
void HTMLTextAreaElement::defaultEventHandler(Event* event) { if (layoutObject() && (event->isMouseEvent() || event->isDragEvent() || event->hasInterface(EventNames::WheelEvent) || event->type() == EventTypeNames::blur)) forwardEvent(event); else if (layoutObject() && event->isBeforeTextInsertedEvent()) handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(event)); HTMLTextFormControlElement::defaultEventHandler(event); }
void HTMLTextAreaElement::defaultEventHandler(Event* event) { if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->eventInterface() == WheelEventInterfaceType || event->type() == eventNames().blurEvent)) forwardEvent(event); else if (renderer() && is<BeforeTextInsertedEvent>(*event)) handleBeforeTextInsertedEvent(downcast<BeforeTextInsertedEvent>(event)); HTMLTextFormControlElement::defaultEventHandler(event); }
void HTMLTextAreaElement::defaultEventHandler(Event* event) { if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->hasInterface(eventNames().interfaceForWheelEvent) || event->type() == eventNames().blurEvent)) forwardEvent(event); else if (renderer() && event->isBeforeTextInsertedEvent()) handleBeforeTextInsertedEvent(static_cast<BeforeTextInsertedEvent*>(event)); HTMLTextFormControlElement::defaultEventHandler(event); }
void WindowImplAndroid::processScrollEvent(AInputEvent* _event, ActivityStates* states) { // Prepare the java virtual machine jint lResult; jint lFlags = 0; JavaVM* lJavaVM = states->activity->vm; JNIEnv* lJNIEnv = states->activity->env; JavaVMAttachArgs lJavaVMAttachArgs; lJavaVMAttachArgs.version = JNI_VERSION_1_6; lJavaVMAttachArgs.name = "NativeThread"; lJavaVMAttachArgs.group = NULL; lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs); if (lResult == JNI_ERR) err() << "Failed to initialize JNI, couldn't get the unicode value" << std::endl; // Retrieve everything we need to create this MotionEvent in java jlong downTime = AMotionEvent_getDownTime(_event); jlong eventTime = AMotionEvent_getEventTime(_event); jint action = AMotionEvent_getAction(_event); jfloat x = AMotionEvent_getX(_event, 0); jfloat y = AMotionEvent_getY(_event, 0); jfloat pressure = AMotionEvent_getPressure(_event, 0); jfloat size = AMotionEvent_getSize(_event, 0); jint metaState = AMotionEvent_getMetaState(_event); jfloat xPrecision = AMotionEvent_getXPrecision(_event); jfloat yPrecision = AMotionEvent_getYPrecision(_event); jint deviceId = AInputEvent_getDeviceId(_event); jint edgeFlags = AMotionEvent_getEdgeFlags(_event); // Create the MotionEvent object in java trough its static constructor obtain() jclass ClassMotionEvent = lJNIEnv->FindClass("android/view/MotionEvent"); jmethodID StaticMethodObtain = lJNIEnv->GetStaticMethodID(ClassMotionEvent, "obtain", "(JJIFFFFIFFII)Landroid/view/MotionEvent;"); jobject ObjectMotionEvent = lJNIEnv->CallStaticObjectMethod(ClassMotionEvent, StaticMethodObtain, downTime, eventTime, action, x, y, pressure, size, metaState, xPrecision, yPrecision, deviceId, edgeFlags); // Call its getAxisValue() method to get the delta value of our wheel move event jmethodID MethodGetAxisValue = lJNIEnv->GetMethodID(ClassMotionEvent, "getAxisValue", "(I)F"); jfloat delta = lJNIEnv->CallFloatMethod(ObjectMotionEvent, MethodGetAxisValue, 0x00000001); // Create and send our mouse wheel event Event event; event.type = Event::MouseWheelMoved; event.mouseWheel.delta = static_cast<double>(delta); event.mouseWheel.x = AMotionEvent_getX(_event, 0); event.mouseWheel.y = AMotionEvent_getY(_event, 0); forwardEvent(event); // Dettach this thread from the JVM lJavaVM->DetachCurrentThread(); }
void BaseMultipleFieldsDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* event) { if (m_pickerIndicatorIsVisible && ((event->keyIdentifier() == "Down" && event->getModifierState("Alt")) || (RenderTheme::theme().shouldOpenPickerWithF4Key() && event->keyIdentifier() == "F4"))) { if (PickerIndicatorElement* element = pickerIndicatorElement()) element->openPopup(); event->setDefaultHandled(); } else { forwardEvent(event); } }
bool ZeroConfDiscoverEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa, osg::Object*, osg::NodeVisitor*) { // forward all key + user-events to devices if ((ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN) || (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP) || (ea.getEventType() == osgGA::GUIEventAdapter::USER)) { forwardEvent(ea); } return false; }
void BaseMultipleFieldsDateAndTimeInputType::handleKeydownEvent(KeyboardEvent* event) { Document* document = element()->document(); RefPtr<RenderTheme> theme = document->page() ? document->page()->theme() : RenderTheme::defaultTheme(); if (m_pickerIndicatorIsVisible && ((event->keyIdentifier() == "Down" && event->getModifierState("Alt")) || (theme->shouldOpenPickerWithF4Key() && event->keyIdentifier() == "F4"))) { if (m_pickerIndicatorElement) m_pickerIndicatorElement->openPopup(); event->setDefaultHandled(); } else forwardEvent(event); }
void Canvas::mouseMoveEvent ( QGraphicsSceneMouseEvent * mouseEvent ) { if(forwardEvent()) { QGraphicsScene::mouseMoveEvent(mouseEvent); } else if(m_currentItem!=nullptr) { m_currentItem->setNewEnd(m_currentItem->mapFromScene(mouseEvent->scenePos())); update(); } }
// event handlers void PlayerWin::onWindowClose(EventCustom* event) { CCLOG("APP.WINDOW_CLOSE_EVENT"); // If script set event's result to "cancel", ignore window close event EventCustom forwardEvent("APP.EVENT"); stringstream buf; buf << "{\"name\":\"close\"}"; forwardEvent.setDataString(buf.str()); Director::getInstance()->getEventDispatcher()->dispatchEvent(&forwardEvent); if (forwardEvent.getResult().compare("cancel") != 0) { glfwSetWindowShouldClose(dynamic_cast<GLViewImpl*>(Director::getInstance()->getOpenGLView())->getWindow(), 1); } }
void MultipleFieldsTemporalInputTypeView::handleKeydownEvent( KeyboardEvent* event) { if (!element().isFocused()) return; if (m_pickerIndicatorIsVisible && ((event->key() == "ArrowDown" && event->getModifierState("Alt")) || (LayoutTheme::theme().shouldOpenPickerWithF4Key() && event->key() == "F4"))) { if (PickerIndicatorElement* element = pickerIndicatorElement()) element->openPopup(); event->setDefaultHandled(); } else { forwardEvent(event); } }
void HTMLTextAreaElement::defaultEventHandler(Event* event) { if (renderer() && (event->isMouseEvent() || event->isDragEvent() || event->eventInterface() == WheelEventInterfaceType || event->type() == eventNames().blurEvent)) forwardEvent(event); else if (renderer() && event->isBeforeTextInsertedEvent()) handleBeforeTextInsertedEvent(toBeforeTextInsertedEvent(event)); if (Frame* frame = document().frame()) { if (event->type() == eventNames().focusEvent) frame->editor().textFieldDidBeginEditing(this); else if (event->type() == eventNames().blurEvent) frame->editor().textFieldDidEndEditing(this); } HTMLTextFormControlElement::defaultEventHandler(event); }
void EventHandler::customEvent(QEvent *e) { if (e->type() == 10001) { // Forward the event to the next in the chain forwardEvent(e); MClientEvent* me = static_cast<MClientEvent*>(e); if(me->dataTypes().contains("XMLTell")) { QByteArray ba = me->payload()->toByteArray(); sendData(ba); } } else qDebug() << "TellMessenger got a customEvent of type" << e->type(); }
int WindowImplAndroid::processMotionEvent(AInputEvent* _event, ActivityStates* states) { int32_t device = AInputEvent_getSource(_event); int32_t action = AMotionEvent_getAction(_event); Event event; if (device == AINPUT_SOURCE_MOUSE) event.type = Event::MouseMoved; else if (device & AINPUT_SOURCE_TOUCHSCREEN) event.type = Event::TouchMoved; int pointerCount = AMotionEvent_getPointerCount(_event); for (int p = 0; p < pointerCount; p++) { int id = AMotionEvent_getPointerId(_event, p); float x = AMotionEvent_getX(_event, p); float y = AMotionEvent_getY(_event, p); if (device == AINPUT_SOURCE_MOUSE) { event.mouseMove.x = x; event.mouseMove.y = y; states->mousePosition = Vector2i(event.mouseMove.x, event.mouseMove.y); } else if (device & AINPUT_SOURCE_TOUCHSCREEN) { if (states->touchEvents[id].x == x && states->touchEvents[id].y == y) continue; event.touch.finger = id; event.touch.x = x; event.touch.y = y; states->touchEvents[id] = Vector2i(event.touch.x, event.touch.y); } forwardEvent(event); } return 1; }
void EventHandler::customEvent(QEvent *e) { // Forward the event to the next in the chain forwardEvent(e); MClientEvent* me = static_cast<MClientEvent*>(e); if (me->dataTypes().contains("DisplayData") || me->dataTypes().contains("DisplayPrompt")) { emit displayData(me->payload()->toString()); } else if (me->dataTypes().contains("UserInput")) { emit userInput(me->payload()->toString()); } else if (me->dataTypes().contains("DoneLoading")) { emit displayData(QString("Type \033[1m#help\033[0m for help.\r\n")); } }
static void glfwDropFunc(GLFWwindow *window, int count, const char **files) { EventCustom forwardEvent("APP.EVENT"); stringstream buf; buf << "{"; buf << "\"name\":\"drop\","; buf << "\"data\":["; for (int i = 0; i < count; i++) { buf << "\"" << files[i] << "\""; if (i < count - 1) buf << ","; } buf << "]"; buf << "}"; forwardEvent.setDataString(buf.str()); Director::getInstance()->getEventDispatcher()->dispatchEvent(&forwardEvent); }
void Canvas::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) { if(mouseEvent->button() == Qt::LeftButton) { if(forwardEvent()) { m_oldPos.clear(); QPointF mousePos(mouseEvent->buttonDownScenePos(Qt::LeftButton).x(), mouseEvent->buttonDownScenePos(Qt::LeftButton).y()); const QList<QGraphicsItem *> itemList = items(mousePos); m_movingItems.append(itemList.isEmpty() ? nullptr : itemList.first()); if (m_movingItems.first() != nullptr && mouseEvent->button() == Qt::LeftButton) { m_oldPos.append(m_movingItems.first()->pos()); } //clearSelection(); QGraphicsScene::mousePressEvent(mouseEvent); } if(m_currentTool==Canvas::DELETETOOL) { QList<QGraphicsItem *> itemList = items(mouseEvent->scenePos()); for(QGraphicsItem* item : itemList) { if(item!=m_bg) { deleteItem(item); } } } else if((m_currentTool<=Canvas::ADDCHECKBOX)||(m_currentTool==Canvas::BUTTON)) { AddFieldCommand* addCommand = new AddFieldCommand(m_currentTool,this,m_model,m_currentPage,m_imageModel, mouseEvent->scenePos()); m_currentItem = addCommand->getField(); m_undoStack->push(addCommand); } } else { QGraphicsScene::mousePressEvent(mouseEvent); } }
LRESULT CALLBACK SimulatorWin::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (!_instance) return 0; switch (uMsg) { case WM_COMMAND: { if (HIWORD(wParam) == 0) { // menu WORD menuId = LOWORD(wParam); PlayerMenuItemWin *menuItem = _instance->_menuService->getItemByCommandId(menuId); if (menuItem) { AppEvent event("APP.EVENT", APP_EVENT_MENU); std::stringstream buf; buf << "{\"data\":\"" << menuItem->getMenuId().c_str() << "\""; buf << ",\"name\":" << "\"menuClicked\"" << "}"; event.setDataString(buf.str()); event.setUserData(menuItem); Director::getInstance()->getEventDispatcher()->dispatchEvent(&event); } if (menuId == ID_HELP_ABOUT) { onHelpAbout(); } } break; } case WM_KEYDOWN: { if (wParam == VK_F5) { PlayerProtocol::getInstance()->relaunch(); } break; } case WM_COPYDATA: { PCOPYDATASTRUCT pMyCDS = (PCOPYDATASTRUCT) lParam; if (pMyCDS->dwData == 1) { const char *szBuf = (const char*)(pMyCDS->lpData); SimulatorWin::getInstance()->writeDebugLog(szBuf); break; } } case WM_DESTROY: { DragAcceptFiles(hWnd, FALSE); break; } case WM_DROPFILES: { HDROP hDrop = (HDROP)wParam; const int count = DragQueryFileW(hDrop, 0xffffffff, NULL, 0); if (count > 0) { int fileIndex = 0; const UINT length = DragQueryFileW(hDrop, fileIndex, NULL, 0); WCHAR* buffer = (WCHAR*)calloc(length + 1, sizeof(WCHAR)); DragQueryFileW(hDrop, fileIndex, buffer, length + 1); char *utf8 = SimulatorWin::convertTCharToUtf8(buffer); std::string firstFile(utf8); CC_SAFE_FREE(utf8); DragFinish(hDrop); // broadcast drop event AppEvent forwardEvent("APP.EVENT.DROP", APP_EVENT_DROP); forwardEvent.setDataString(firstFile); Director::getInstance()->getEventDispatcher()->dispatchEvent(&forwardEvent); } } // WM_DROPFILES } return g_oldWindowProc(hWnd, uMsg, wParam, lParam); }
int WindowImplAndroid::processKeyEvent(AInputEvent* _event, ActivityStates* states) { int32_t device = AInputEvent_getSource(_event); int32_t action = AKeyEvent_getAction(_event); int32_t key = AKeyEvent_getKeyCode(_event); int32_t metakey = AKeyEvent_getMetaState(_event); Event event; event.key.code = androidKeyToSF(key); event.key.alt = metakey & AMETA_ALT_ON; event.key.control = false; event.key.shift = metakey & AMETA_SHIFT_ON; switch (action) { case AKEY_EVENT_ACTION_DOWN: event.type = Event::KeyPressed; forwardEvent(event); return 1; case AKEY_EVENT_ACTION_UP: event.type = Event::KeyReleased; forwardEvent(event); if (int unicode = getUnicode(_event)) { event.type = Event::TextEntered; event.text.unicode = unicode; forwardEvent(event); } return 1; case AKEY_EVENT_ACTION_MULTIPLE: // Since complex inputs don't get separate key down/up events // both have to be faked at once event.type = Event::KeyPressed; forwardEvent(event); event.type = Event::KeyReleased; forwardEvent(event); // This requires some special treatment, since this might represent // a repetition of key presses or a complete sequence if (key == AKEYCODE_UNKNOWN) { // This is a unique sequence, which is not yet exposed in the NDK // http://code.google.com/p/android/issues/detail?id=33998 return 0; } else if (int unicode = getUnicode(_event)) // This is a repeated sequence { event.type = Event::TextEntered; event.text.unicode = unicode; int32_t repeats = AKeyEvent_getRepeatCount(_event); for (int32_t i = 0; i < repeats; ++i) forwardEvent(event); return 1; } break; } return 0; }
void EventHandler::customEvent(QEvent *e) { if (e->type() == 10001) { // Forward the event to the next in the chain forwardEvent(e); MClientEvent* me = static_cast<MClientEvent*>(e); if (me->dataTypes().contains("XMLEdit")) { if (_state != NORMAL) qWarning() << "! Remote editing protocol somehow received a key"; _key = me->payload()->toInt(); _state = RECEIVED_KEY; qDebug() << "* Remote editing protocol got edit key" << _key; } else if (me->dataTypes().contains("XMLEditTitle")) { if (_state == RECEIVED_KEY) { _title = me->payload()->toByteArray(); _state = RECEIVED_TITLE; qDebug() << "* Remote editing protocol got edit title" << _title; } else { qWarning() << "! Remote editing protocol never got a key" << "; discarding title"; _state = NORMAL; } } else if (me->dataTypes().contains("XMLEditBody")) { if (_state == RECEIVED_TITLE) { _body = me->payload()->toByteArray(); qDebug() << "* Remote editing protocol got edit body" << _body; editSession(_key, _title, _body); } else if (_state == RECEIVED_KEY) qWarning() << "! Remote editing protocol never got a title" << "; discarding body"; else qWarning() << "! Remote editing protocol never got a key" << "; discarding body"; _state = NORMAL; } else if (me->dataTypes().contains("XMLViewTitle")) { if (_state == NORMAL) { _key = -1; _title = me->payload()->toByteArray(); _state = RECEIVED_TITLE; qDebug() << "* Remote editing protocol got view title" << _title; } } else if (me->dataTypes().contains("XMLViewBody")) { if (_state == RECEIVED_TITLE) { _body = me->payload()->toByteArray(); qDebug() << "* Remote editing protocol got view body" << _body; viewSession(_key, _title, _body); } else if (_state == RECEIVED_KEY) qWarning() << "! Remote editing protocol never got a title" << "; discarding body"; else qWarning() << "! Remote editing protocol never got a key" << "; discarding body"; _state = NORMAL; } else if (me->dataTypes().contains("MUMEIdentifyRequest")) { sendMUMEIdentifyRequest(); } else if (me->dataTypes().contains("SocketConnected")) { if (_pluginSession->isMUME()) sendMUMEIdentifyRequest(); } } else { qDebug() << "! RemoteEdit somehow received the wrong kind of event..."; } }
void InputController::run() { bool ticking = false; while(true) { usleep(10000); if(ticking) { if(buttons[MODE_BUTTON_IN] && !buttons[START_STOP_BUTTON_IN] && !buttons[SET_BUTTON_IN]) { forwardEvent(MODE_TICK); usleep(1000000); continue; } else { ticking = false; continue; } } // if any buttons are down if(buttons[SET_BUTTON_IN] || buttons[MODE_BUTTON_IN] || buttons[START_STOP_BUTTON_IN]) { // wait for a moderate amount of time for inputs to settle usleep(200000); } // what event is this // ALL THREE if(buttons[SET_BUTTON_IN] && buttons[MODE_BUTTON_IN] && buttons[START_STOP_BUTTON_IN]) { if(waitTwoValidate(true, true, true)) { forwardEvent(FULL_RESET); waitForClear(); } continue; } // MODE AND START STOP if(buttons[MODE_BUTTON_IN] && buttons[START_STOP_BUTTON_IN]) { if(waitTwoValidate(false, true, true)) { forwardEvent(RESET_TRIP); waitForClear(); } continue; } // ONLY MODE if(buttons[MODE_BUTTON_IN] && !buttons[START_STOP_BUTTON_IN] && !buttons[SET_BUTTON_IN]) { if(waitTwoValidate(false, true, false)) { ticking = true; } else { forwardEvent(MODE_BUTTON); std::cout << "MODE BUTTON" << std::endl; } continue; } // ONLY SET if(buttons[SET_BUTTON_IN] && !buttons[START_STOP_BUTTON_IN] && !buttons[MODE_BUTTON_IN]) { forwardEvent(SET_BUTTON); waitForClear(); continue; } // ONLY START STOP if(buttons[START_STOP_BUTTON_IN] && !buttons[SET_BUTTON_IN] && !buttons[MODE_BUTTON_IN]) { forwardEvent(START_STOP_BUTTON); waitForClear(); continue; } } }