void MouseToolHandler::clearActiveMouseTool(const ui::MouseToolPtr& tool) { unsigned int previousPointerMode = tool->getPointerMode(); for (ActiveMouseTools::const_iterator i = _activeMouseTools.begin(); i != _activeMouseTools.end(); ++i) { if (i->second == tool) { _activeMouseTools.erase(i); break; } } // Check if any mouse tools still require capture mode unsigned int remainingPointerMode = ui::MouseTool::PointerMode::Normal; for (const ActiveMouseTools::value_type& pair : _activeMouseTools) { remainingPointerMode |= pair.second->getPointerMode(); } // If no more freezing mouse tools: release the mouse cursor again if (previousPointerMode & ui::MouseTool::PointerMode::Capture && !(remainingPointerMode & ui::MouseTool::PointerMode::Capture)) { endCapture(); } // Reset the escape listener if this was the last active tool if (_activeMouseTools.empty()) { _escapeListener.reset(); } }
void MouseToolHandler::clearActiveMouseTools() { // Reset the escape listener _escapeListener.reset(); if (_activeMouseTools.empty()) { return; } // Check the capture mode unsigned int pointerMode = ui::MouseTool::PointerMode::Normal; // Freezing mouse tools: release the mouse cursor again for (ActiveMouseTools::const_iterator i = _activeMouseTools.begin(); i != _activeMouseTools.end();) { pointerMode |= i->second->getPointerMode(); // Tool is done _activeMouseTools.erase(i++); } // If any of the active tools was capturing, end this now if (pointerMode & ui::MouseTool::PointerMode::Capture) { endCapture(); } }
WC3MouseCapture::WC3MouseCapture(QWidget *parent) : QWidget(parent), m_icon(QIcon(ICON_NAME), this), m_timer(this), m_menu(this), m_exitAction(EXIT_ACTION_TITLE, this), m_isDisabled(false) { // Set up trayicon m_icon.show(); // Hide widget //QTimer::singleShot(0, this, SLOT(hide())); // Set up menu m_menu.addAction(&m_exitAction); m_icon.setContextMenu(&m_menu); // Save default mouse rect GetClipCursor(&m_defaultRect); // Connect signals & slots QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(checkActiveWindow())); QObject::connect(this, SIGNAL(wc3Activated(HWND&)), this, SLOT(captureMouse(HWND&))); QObject::connect(this, SIGNAL(wc3Deactivated()), this, SLOT(endCapture())); QObject::connect(&m_exitAction, SIGNAL(activated()), this, SLOT(close())); // Start the timer m_timer.start(DEFAULT_TIMEOUT); // Register hotkey RegisterHotKey(QWidget::winId(), NULL, NULL, DEFAULT_HOTKEY); }
void testApp::processSample(int x, int y, int z){ const int samplesToAverage = 4; static int count = 0; static int totalX, totalY, totalZ = 0; totalX += x; totalY += y; totalZ += z; count++; if (count == samplesToAverage) { sampleData[sampleCount][0] = quantizeAccelData(totalX / samplesToAverage); sampleData[sampleCount][1] = quantizeAccelData(totalY / samplesToAverage); sampleData[sampleCount][2] = quantizeAccelData(totalZ / samplesToAverage); sampleCount++; totalX = totalY = totalZ = 0; count = 0; } if(sampleCount > (sampleDataLength - 1)){ endCapture(); int gesture = detectGesture(); cout << "Gesture: " << gesture << endl; } }
void V4L2VideoCaptureDevice::setCaptureSize(QSize size) { endCapture(); m_size = size; beginCapture(); }
bool WC3MouseCapture::winEvent(MSG *message, long *result) { if (message->message == WM_HOTKEY) { endCapture(); m_isDisabled = true; return false; } return QWidget::winEvent(message, result); }
WC3MouseCapture::~WC3MouseCapture() { // Stop the timer m_timer.stop(); // Reset mouse rect endCapture(); // Delete context menu m_menu.deleteLater(); }
void XUIObject::onLeftButtonUp(int x, int y) { m_trieddnd = false; eventSource_onLeftButtonUp(x, y); if (m_draggingWindow) { m_draggingWindow = 0; } if (m_dndlbuttondown) { endCapture(CAPTURETYPE_DND); m_dndlbuttondown = false; } }
int OSDockWnd::onLeftButtonUp(int x, int y) { OSDOCKWND_PARENT::onLeftButtonUp(x, y); POINT pt={x,y}; if (m_snap_bdown) { m_snap_bdown = 0; m_snap_inarea = 0; endCapture(); if (PtInRect(&m_snapbtn, pt)) { onSnapClick(); } } return 1; }
//-------------------------------------------------------------- void captureApp::keyPressed(int key) { if (key == '='){ serial.writeByte(255); // this will turn on led. } if (key == '-') { serial.writeByte(0); // this will turn off led. } if(key == 'f') { ofToggleFullscreen(); } if(key == '\t') { if( state < CAP_STATE_FADEIN ){ startFadeIn(); } else if( state == CAP_STATE_FADEIN ){ bNeedsToLeaveFrame = false; face.resetCounters(); state = CAP_STATE_WAITING; } else if( state == CAP_STATE_CAPTURE ){ endCapture(true); //force override and cancel - normally capture is timed. bNeedsToLeaveFrame = false; face.resetCounters(); }else if( state == CAP_STATE_DECODING ){ endDecode(true); bNeedsToLeaveFrame = false; face.resetCounters(); } } if( key == 'h' ){ if( debugState == CAP_DEBUG ){ debugState = CAP_NORMAL; }else if( debugState == CAP_NORMAL ){ debugState = CAP_DEBUG; } } if( debugState == CAP_DEBUG ){ if(panel.getValueB("frameByFrame") && key == OF_KEY_UP){ patternFrame--; } if(panel.getValueB("frameByFrame") && key == OF_KEY_DOWN){ patternFrame++; } } }
/** Codel execAcquire of activity Acquire. * * Triggered by bass_exec. * Yields to bass_exec, bass_stop. * Throws bass_e_nomem, bass_e_device, bass_e_hwparams, * bass_e_swparams. */ genom_event execAcquire(bass_ids *ids, const bass_Audio *Audio, genom_context self) { int err; /* Get the data */ if ((err = runCapture(ids->cap)) < 0) { endCapture(&(ids->cap)); return_bass_exception(err); } /* Publish the data on the Port */ publishPort(Audio, ids->cap, self); return bass_exec; }
void XUIObject::onMouseMove(int x, int y) { if (m_dndDragging) return; int _x = x; int _y = y; m_wnd->clientToScreen(&_x, &_y); if (pointInRegion(x, y)) { if (!m_mouseInArea) { m_mouseInArea = 1; beginCapture(CAPTURETYPE_AREA); onMouseEnter(); } } else { if (m_mouseInArea) { m_mouseInArea = 0; endCapture(CAPTURETYPE_AREA); onMouseLeave(); // prevent further mousemove event processing, because we would not have gotten here // had we not captured the mouse, and we only capture the mouse to implement the // mouseenter/mouseleave events, not to cause any more mousemove events than normal. return; } } eventSource_onMouseMove(x, y); if (m_draggingWindow) { int ox = _x - m_draganchor_x; int oy = _y - m_draganchor_y; RECT r; m_wnd->getRootParent()->getWindowRect(&r); m_wnd->getRootParent()->move(r.left + ox, r.top + oy); m_draganchor_x = _x; m_draganchor_y = _y; } if (m_dndlbuttondown && !m_trieddnd) { if (ABS(_x - m_draganchor_x) >= 4 || ABS(_y - m_draganchor_y) >= 4) { m_trieddnd = true; onBeginDrag(NULL); m_wnd->handleDrag(); } } }
void OSToolBarWnd::localMouseMove(int x, int y) { OSToolBarEntry *old = m_hilite; OSToolBarEntry *at = getEntryAt(x, y); if (!at) { if (m_hilite) { onLeaveIcon(m_hilite); m_hilite = NULL; } } else { if (at != m_hilite) { if (m_hilite) onLeaveIcon(m_hilite); m_hilite = at; onEnterIcon(m_hilite); } else { // repaint current in case its animated -BU invalidateIcon(m_hilite); } } if (!old && m_hilite) beginCapture(); else if (old && !m_hilite) endCapture(); }
/** Codel startAcquire of activity Acquire. * * Triggered by bass_start. * Yields to bass_exec, bass_ether. * Throws bass_e_nomem, bass_e_device, bass_e_hwparams, * bass_e_swparams. */ genom_event startAcquire(const char *device, uint32_t sampleRate, uint32_t nFramesPerChunk, uint32_t nChunksOnPort, bass_ids *ids, const bass_Audio *Audio, genom_context self) { int err; /* Prepare the Port */ if ((err = initPort(Audio, sampleRate, nFramesPerChunk, nChunksOnPort, self)) < 0) return_bass_exception(err); /* Start the capture */ initCapture(&(ids->cap), device, sampleRate, nFramesPerChunk); if ((err = createCapture(ids->cap)) < 0) { endCapture(&(ids->cap)); return_bass_exception(err); } return bass_exec; }
int OSToolBarWnd::onLeftButtonUp(int x, int y) { OSTOOLBARWND_PARENT::onLeftButtonUp(x, y); if (m_hilite) { OSToolBarEntry *at = getEntryAt(x, y); if (m_hilite == at) { endCapture(); // in case event loads up a dialog ... if (!at->isDisabled()) { onClickIcon(at); at->onClicked(); onLeaveIcon(at); // (for parity sake) beginCapture(); // ... we need to leave and restore icon states ... StdWnd::getMousePos(&x, &y); screenToClient(&x, &y); localMouseMove(x, y); // ... according to new mouse pos } } } m_down = 0; m_last_pushed = -1; return 1; }
void XUIObject::endMouseCapture() { endCapture(CAPTURETYPE_USER); }
/** Codel stopAcquire of activity Acquire. * * Triggered by bass_stop. * Yields to bass_ether. * Throws bass_e_nomem, bass_e_device, bass_e_hwparams, * bass_e_swparams. */ genom_event stopAcquire(bass_ids *ids, genom_context self) { endCapture(&(ids->cap)); return bass_ether; }
//----------------------------------------------- void captureApp::update(){ panel.update(); if( panel.getValueB("bRestart") ){ if( panel.getValueI("restartHour") == ofGetHours() ){ if( panel.getValueI("restartMinute") == ofGetMinutes() ){ printf("shutting down now!\n"); system(ofToDataPath("reboot.sh").c_str()); } } } char data[10]; memset(data, 0, 10); if (serial.available() > 0){ serial.readBytes((unsigned char*) data, 10); if(state == CAP_STATE_WAITING) startFadeIn(); } if( panel.hasValueChanged("bOverideLight") ){ if( panel.getValueB("bOverideLight") ){ light.lightOn(); }else{ light.lightOff(); } } bEnableOsc = panel.getValueB("use_osc"); if( panel.hasValueChanged("use_osc") ){ if( bEnableOsc && !bOscSetup ){ setupOsc(); printf("------------- setting up osc\n"); } } if( state == CAP_STATE_FADEIN || state == CAP_STATE_CAPTURE ){ panel.setValueB("frameByFrame", false); panel.setValueB("bSpotLight", true); } //the capture part happens in the camera callbacks at the top. //this just checks to make sure that the capture doesn't need to keep running. if( state == CAP_STATE_CAPTURE ){ panel.hidden = true; if( ofGetFrameNum() % 4 == 0 ){ printf("fps is %s\n", ofToString(camFps, 2).c_str()); } if( ofGetElapsedTimef() >= timeToEndCapture ){ printf("time is %f - time to end is %f\n", ofGetElapsedTimef(), timeToEndCapture); endCapture(); } }else if( debugState == CAP_DEBUG ){ panel.hidden = false; } if( debugState == CAP_NORMAL ){ ofHideCursor(); }else { ofShowCursor(); } if( state == CAP_STATE_CAPTURE && ofGetElapsedTimef() >= timeToEndCapture ){ printf("time is %f - time to end is %f\n", ofGetElapsedTimef(), timeToEndCapture); endCapture(); if( panel.getValueB("B_FACE_TRIGGER") ){ bNeedsToLeaveFrame = true; }else{ bNeedsToLeaveFrame = false; } } if( state == CAP_STATE_FADEIN && ofGetElapsedTimef() > fadeInStartTime + panel.getValueF("fadeInTime") ){ startCapture(); } if( state == CAP_STATE_DECODING ){ handleDecode(); }else{ handleProjection(); handleCamera(); handleFaceTrigger(); } panel.clearAllChanged(); }
VideoEncoder::~VideoEncoder() { endCapture(); }