void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (hasTouch()) { UINT inputCount = LOWORD(wParam); HTOUCHINPUT touchInputData = (HTOUCHINPUT)lParam; TOUCHINPUT *inputs = new TOUCHINPUT[inputCount]; if (touchInfo(touchInputData, inputCount, inputs, sizeof(TOUCHINPUT))) { for (UINT i = 0; i < inputCount; i++) { float x, y; if (!GetTouchPoint(hWnd, inputs[i], x, y)) continue; if (inputs[i].dwFlags & TOUCHEVENTF_DOWN) { touchDown(ToTouchID(inputs[i].dwID), x, y); } if (inputs[i].dwFlags & TOUCHEVENTF_MOVE) { touchMove(ToTouchID(inputs[i].dwID), x, y); } if (inputs[i].dwFlags & TOUCHEVENTF_UP) { int id = ToTouchID(inputs[i].dwID, false); if (id >= 0) { touchUp(id, x, y); touchIds[id] = 0; } } } closeTouch(touchInputData); } else { WARN_LOG(SYSTEM, "Failed to read input data: %s", GetLastErrorMsg()); } delete [] inputs; } }
void CCDeviceControls::touch(CCPoint position, int action, int finger) { UITouch *touch; if( action == ACTION_DOWN || action == POINTER_DOWN ) { touch = &deviceTouches[finger]; touch->pos = position; touchBegin( touch ); } else if( action == ACTION_MOVE ) { touch = (UITouch*)screenTouches[finger].usingTouch; if( touch != NULL ) { touch->pos = position; touchMove( touch ); } } else if( action == ACTION_UP || action == POINTER_UP ) { touch = (UITouch*)screenTouches[finger].usingTouch; touchEnd( touch ); } }
bool controlGraph::viewportEvent(QEvent *event) { QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); switch (event->type()) { case QEvent::TouchBegin: { qDebug() << "touch TouchBegin"; return true; } case QEvent::TouchUpdate: { if(touchEvent->touchPoints().size() < 2) { // emit touchMove(0, 0); return(true); } qDebug() << "touch TouchUpdate"; const QTouchEvent::TouchPoint &touchPoint0 = touchEvent->touchPoints().first(); int s = 1; if(touchEvent->touchPoints().size() == 3)s = 10; float deltaX = touchPoint0.normalizedPos().x() - touchPoint0.startNormalizedPos().x(); float deltaY = touchPoint0.normalizedPos().y() - touchPoint0.startNormalizedPos().y(); // if(deltaX > -0.01 && deltaX < 0.01)deltaX=0; // if(deltaY > -0.01 && deltaY < 0.01)deltaY=0; emit touchMove(deltaX/s, deltaY/s); return true; } case QEvent::TouchEnd: { emit touchMove(0, 0); return true; } case QEvent::TouchCancel: { emit touchMove(0, 0); return true; } default: break; } return QGraphicsView::viewportEvent(event); }
void ejoy2d_win_touch(int x, int y,int touch) { switch (touch) { case TOUCH_BEGIN: touchBegin(x,y); break; case TOUCH_END: touchEnd(x, y); break; case TOUCH_MOVE: touchMove(x,y); break; } }
bool SwipeArea::event(QEvent *ev) { switch (ev->type()) { case QEvent::TouchBegin: case QEvent::TouchUpdate: break; default: return QDeclarativeItem::event(ev); } QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(ev)->touchPoints(); const QTouchEvent::TouchPoint &touchPoint = touchPoints.at(0); if (ev->type() == QEvent::TouchBegin) { this->touchBegin(touchPoint.pos()); return true; } return touchMove(touchPoint.pos()); }
void SwipeArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { touchMove(event->pos()); QDeclarativeItem::mouseMoveEvent(event); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->PixelDisplay1->setSize(DISPLAY_XSIZE, DISPLAY_YSIZE); ui->PixelDisplay1->setDataEncoding(PixelDisplay::MONOCHROME_3310_8bit); ui->PixelDisplay1->setScale(3.0); ui->PixelDisplay2->setSize(DISPLAY_XSIZE, DISPLAY_YSIZE); ui->PixelDisplay2->setDataEncoding(PixelDisplay::MONOCHROME_3310_8bit); ui->PixelDisplay2->setScale(3.0); StatusLabel_LCD0 = new QLabel(this); StatusLabel_LCD1 = new QLabel(this); ui->statusBar->addWidget(StatusLabel_LCD0); ui->statusBar->addWidget(StatusLabel_LCD1); keyDriver1 = new keyDriver(this, 10, 300, 50); // size of enum buttons ? // Signals and slots mapping // View viewSignalMapper = new QSignalMapper(this); viewSignalMapper->setMapping(ui->actionX1, 1); viewSignalMapper->setMapping(ui->actionX2, 2); viewSignalMapper->setMapping(ui->actionX3, 3); viewSignalMapper->setMapping(ui->actionX4, 4); viewSignalMapper->setMapping(ui->actionX5, 5); connect(ui->actionX1, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX2, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX3, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX4, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(ui->actionX5, SIGNAL(triggered()), viewSignalMapper, SLOT (map())); connect(viewSignalMapper, SIGNAL(mapped(const int &)), this, SLOT(on_viewScale_changed(const int &))); // Control buttons press btnPressSignalMapper = new QSignalMapper(this); btnPressSignalMapper->setMapping(ui->pushButton_esc, APP_KEY_ESC); btnPressSignalMapper->setMapping(ui->pushButton_left, APP_KEY_LEFT); btnPressSignalMapper->setMapping(ui->pushButton_right, APP_KEY_RIGHT); btnPressSignalMapper->setMapping(ui->pushButton_ok, APP_KEY_OK); btnPressSignalMapper->setMapping(ui->pushButton_encoder, APP_KEY_ENCODER); connect(ui->pushButton_esc, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_left, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_right, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_ok, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(ui->pushButton_encoder, SIGNAL(pressed()), btnPressSignalMapper, SLOT(map())); connect(btnPressSignalMapper, SIGNAL(mapped(const int &)), keyDriver1, SLOT(keyPress(const int &))); // Control buttons release btnReleaseSignalMapper = new QSignalMapper(this); btnReleaseSignalMapper->setMapping(ui->pushButton_esc, APP_KEY_ESC); btnReleaseSignalMapper->setMapping(ui->pushButton_left, APP_KEY_LEFT); btnReleaseSignalMapper->setMapping(ui->pushButton_right, APP_KEY_RIGHT); btnReleaseSignalMapper->setMapping(ui->pushButton_ok, APP_KEY_OK); btnReleaseSignalMapper->setMapping(ui->pushButton_encoder, APP_KEY_ENCODER); connect(ui->pushButton_esc, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_left, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_right, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_ok, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(ui->pushButton_encoder, SIGNAL(released()), btnReleaseSignalMapper, SLOT(map())); connect(btnReleaseSignalMapper, SIGNAL(mapped(const int &)), keyDriver1, SLOT(keyRelease(const int &))); connect(keyDriver1, SIGNAL(onKeyEvent(int,int)), this, SLOT(onKeyDriverEvent(int, int))); connect(ui->updateButton,SIGNAL(clicked()),this, SLOT(on_LCD_update())); connect(&updateTimer,SIGNAL(timeout()),this,SLOT(on_LCD_update())); connect(&secondsTimer,SIGNAL(timeout()),this,SLOT(on_secondsTimer())); connect(ui->PixelDisplay1, SIGNAL(touchMove()), this, SLOT(on_touchMove()) ); connect(ui->PixelDisplay1, SIGNAL(touchPress()), this, SLOT(on_touchPress()) ); connect(ui->PixelDisplay1, SIGNAL(touchRelease()), this, SLOT(on_touchRelease()) ); connect(ui->PixelDisplay2, SIGNAL(touchMove()), this, SLOT(on_touchMove()) ); connect(ui->PixelDisplay2, SIGNAL(touchPress()), this, SLOT(on_touchPress()) ); connect(ui->PixelDisplay2, SIGNAL(touchRelease()), this, SLOT(on_touchRelease()) ); qApp->installEventFilter( this ); // This does shrinking of a form when inner widgets are resized //layout()->setSizeConstraint(QLayout::SetFixedSize); pt2Myself = this; registerLogCallback((cbLogPtr)&MainWindow::addLogWrapper); registerLcdUpdateCallback((cbLcdUpdatePtr)&MainWindow::updateDisplayWrapper); guiInitialize(); // Start seconds timer //secondsTimer.start(1000); // Start update timer if (ui->updateCheckBox->checkState()) { updateTimer.start(ui->updateSpinBox->value()); } }
void DeviceAcquisitionDemo::run() { int step = 10; int minX = 200; int minY = 200; int maxX = 500; int maxY = 500; mTouchX = minX; mTouchY = minY; //mIsTouchPressed = true; emit touchPress(mTouchX, mTouchY); while(1){ switch (mMode) { case 0: if (mTouchX < maxX) { mTouchX += step; }else{ mMode = 1; } break; case 1: if (mTouchY < maxY){ mTouchY += step; }else{ mMode = 2; } break; case 2: if (mTouchX > minX) { mTouchX -= step; }else{ mMode = 3; } break; case 3: if (mTouchY > minY){ mTouchY -= step; }else{ mMode = 0; } break; } objects[0].x = mTouchX; objects[0].y = mTouchY; objects[1].x = (mTouchX + 300) / 4.0f; objects[1].y = (mTouchY) / 3.33f; objects[2].x = (mTouchX + 600) / 4.0f; objects[2].y = (mTouchY) / 3.33f; emit touchMove(mTouchX, mTouchY); emit newFrame(&objects); msleep(10); } }
void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { if (hasTouch()){ UINT inputCount = LOWORD(wParam); TOUCHINPUT *inputs = new TOUCHINPUT[inputCount]; if (touchInfo((HTOUCHINPUT) lParam, inputCount, inputs, sizeof(TOUCHINPUT))) { for (UINT i = 0; i < inputCount; i++) { int id = 0; //here we map the windows touch id to the ppsspp internal touch id //currently we ignore the fact that the mouse uses touch id 0, so that //the mouse could possibly interfere with the mapping so for safety //the maximum amount of touch points is MAX_POINTERS-1 std::map<int, int>::const_iterator it = touchTranslate.find(inputs[i].dwID); if (it != touchTranslate.end()) //check if we already mapped this touch id { id = it->second; } else { if (touchTranslate.size() + 1 >= MAX_POINTERS) //check if we're tracking too many points { touchUp(touchTranslate.begin()->second, 0, 0); touchTranslate.erase(touchTranslate.begin()); } //finding first free internal touch id and map this windows id to an internal id bool *first_free = std::find(input_state.pointer_down, input_state.pointer_down + MAX_POINTERS, false); id = (int)(first_free - input_state.pointer_down) / (int)sizeof(bool); touchTranslate[inputs[i].dwID] = id; } POINT point; point.x = TOUCH_COORD_TO_PIXEL(inputs[i].x); point.y = TOUCH_COORD_TO_PIXEL(inputs[i].y); if (ScreenToClient(hWnd, &point)){ if (inputs[i].dwFlags & TOUCHEVENTF_DOWN) { touchDown(id, point.x, point.y); } if (inputs[i].dwFlags & TOUCHEVENTF_MOVE) { touchMove(id, point.x, point.y); } if (inputs[i].dwFlags & TOUCHEVENTF_UP) { touchUp(id, point.x, point.y); touchTranslate.erase(touchTranslate.find(inputs[i].dwID)); } } } closeTouch((HTOUCHINPUT) lParam); } else { // GetLastError() and error handling. } delete [] inputs; } }
//-------------------------------------------------------------- void ofApp::mouseDragged(int x, int y, int button){ if (m_multitouch.isSetup()) return; touchMove(x,y,-1); }
MyMoveServer::MyMoveServer(QObject *parent) : QObject(parent), #ifndef ANN_TRAINING m_state(IDLE), #else m_state(COLLECTING_DATA), m_gestureFile(), #endif m_eh(this), m_gesture(), m_gesturesDouble(), m_gesturesTriple(), m_orientation(), m_portrait(true), m_gestureNN2(NULL), m_gestureNN3(NULL), m_featureVector(), m_featureMatrix(), m_diffMatrix(), m_f11(), m_f12(), m_f21(), m_f22() { m_orientation.start(); resetFeatureVector(); QOrientationReading* reading = m_orientation.reading(); if (reading->orientation() == QOrientationReading::TopUp) { m_portrait = true; } else if (reading->orientation() == QOrientationReading::RightUp) { m_portrait = false; } #ifndef ANN_TRAINING qDebug("MyMoveServer, portrait: %d", m_portrait); #else qDebug("Starting in the data collecting mode"); QString fname("/home/user/MyDocs/gesturedata"); fname.append(QVariant(m_gestureNum).toString()); m_gestureFile.setFileName(fname); m_gestureCount = 0; #endif connect(&m_orientation, SIGNAL(readingChanged()), this, SLOT(orientationChanged())); qRegisterMetaType<QPoint>("QPoint"); qRegisterMetaType<QList<QPoint> >("QList<QPoint>"); connect(&m_eh, SIGNAL(touchPress(QList<QPoint>)), this, SLOT(touchPress(QList<QPoint>))); connect(&m_eh, SIGNAL(touchMove(QList<QPoint>)), this, SLOT(touchMove(QList<QPoint>))); connect(&m_eh, SIGNAL(touchRelease(QList<QPoint>)), this, SLOT(touchRelease(QList<QPoint>))); QDBusConnection bus = QDBusConnection::sessionBus(); bus.registerObject("/sandst1/mymoves", this, QDBusConnection::ExportAllSlots); bus.registerService("org.sandst1.mymoves"); m_eh.start(); m_gestureNN2 = fann_create_from_file("/opt/mymoves/mymoves_nn2.net"); m_gestureNN3 = fann_create_from_file("/opt/mymoves/mymoves_nn3.net"); #ifndef ANN_TRAINING observeGestures(); #endif }