コード例 #1
0
ファイル: CMUCamera.cpp プロジェクト: cnxsoft/xibo4arm
CameraInfo* CMUCamera::getCameraInfos(int deviceNumber)
{
#ifdef AVG_ENABLE_CMU1394
    C1394Camera* pCamera = new C1394Camera();
    int err = pCamera->RefreshCameraList();
    if (err <= 0) {
        return 0;
    }

    err = pCamera->SelectCamera(deviceNumber);
    if (err != CAM_SUCCESS) {
        AVG_ASSERT(false);
    }
    pCamera->InitCamera(true);

    long long uniqueID;
    pCamera->GetCameraUniqueID((PLARGE_INTEGER)&uniqueID);
    stringstream deviceID;
    deviceID << uniqueID;

    CameraInfo* pCamInfo = new CameraInfo("Firewire", deviceID.str());
    getCameraImageFormats(pCamera, pCamInfo);
    getCameraControls(pCamera, pCamInfo);

    delete pCamera;
    return pCamInfo;
#endif
    return NULL;
}
コード例 #2
0
/**\brief Window procedure for the control dialog
 * \ingroup dialogs
 * \param hWnd The dialog window handle
 * \param message The message to process
 * \param wParam the window parameter
 * \param lParam the (often unused) generic long parameter
 * 
 * Duties:
 *  - menu items
 *     - load/save view settings to from/to registry
 *     - close the window
 *     - view menu toggles panes on and off
 *  - messages
 *     - paint: nothing (for now)
 *     - destroy: localfree the window extension structure
 *     - hscroll: scroll the panes back and forth
 */
LRESULT CALLBACK ControlDialogWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	int i;
	PAINTSTRUCT ps;
	HDC hdc;
	HKEY  hKey,hCSK;
	DWORD dwRet,dwDisposition,dwFoo,dwSize = sizeof(DWORD),dwType = REG_DWORD;
	SCROLLINFO si;
	PCONTROL_WINDOW_EXTENSION pExt = (PCONTROL_WINDOW_EXTENSION) GetWindowLongPtr(hWnd,GWLP_USERDATA);
	PCONTROL_PANE_EXTENSION pPaneExt;
	C1394Camera *pCam;
	C1394CameraControl *pControl;
	char buf[256];
	LRESULT lRetval = 0;
	HWND hWndChild;
	MSG msg;
	LARGE_INTEGER UniqueID;
	
	DllTrace(DLL_TRACE_ENTER,"ControlDialogProc(%08x,%08x,%08x,%08x)\n",
		hWnd,
		message,
		wParam,
		lParam);
	
	/* to maintain reasonable encapsulation, we need to translate our own accelerator messages */
	if(pExt)
	{
		msg.hwnd = hWnd;
		msg.message = message;
		msg.wParam = wParam;
		msg.lParam = lParam;
		TranslateAccelerator(hWnd,pExt->hAccel,&msg);
		message = msg.message;
		lParam = msg.lParam;
		wParam = msg.wParam;
	}
	
	switch (message) 
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 
		// Parse the menu selections:
		switch (wmId)
		{
		case ID_CONTROL_POLLALL:
			for(i=0; i<pExt->nPanes; i++)
			{
				if(pExt->PaneState[i])
					SendDlgItemMessage(hWnd,ID_FIRST_CONTROL_PANE + i,WM_COMMAND,MAKELONG(IDC_BUT_POLL,0),0);
			}
			break;
		case ID_FILE_LOADDEFAULTVIEW:
			pCam = pExt->pCamera;
			if(pCam)
			{
				if((hCSK = OpenCameraSettingsKey(NULL,0,KEY_ALL_ACCESS)) != NULL)
				{
					pCam->GetCameraUniqueID(&UniqueID);
					StringCbPrintf(buf,sizeof(buf),"%08x%08x\\ControlPanes\\DefaultView",UniqueID.HighPart,UniqueID.LowPart);
					dwRet = RegCreateKeyEx(hCSK,buf,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,&dwDisposition);
					if(dwRet == ERROR_SUCCESS)
					{
						if(dwDisposition == REG_CREATED_NEW_KEY)
						{
							// we made a new key, so we need to write the initial settings
							for(i=0; i<pExt->nPanes; i++)
							{
								hWndChild = GetDlgItem(hWnd,ID_FIRST_CONTROL_PANE + i);
								pPaneExt = (PCONTROL_PANE_EXTENSION) GetWindowLongPtr(hWndChild,GWLP_USERDATA);
								dwFoo = 1;
								dwRet = RegSetValueEx(hKey,pPaneExt->pane_name,0,REG_DWORD,(LPBYTE)&dwFoo,dwSize);
								if(dwRet != ERROR_SUCCESS)
									DllTrace(DLL_TRACE_ERROR,
									"ControlDialogProc: Load Default View: error %d setting registry key for %s\n",
									dwRet,pPaneExt->pane_name);
							}
						}
						
						
						for(i=0; i<pExt->nPanes; i++)
						{
							hWndChild = GetDlgItem(hWnd,ID_FIRST_CONTROL_PANE + i);
							pPaneExt = (PCONTROL_PANE_EXTENSION) GetWindowLongPtr(hWndChild,GWLP_USERDATA);
							dwFoo = pExt->PaneState[i];
							dwRet = RegQueryValueEx(hKey,pPaneExt->pane_name,0,&dwType,(LPBYTE)&(dwFoo),&dwSize);
							
							if(dwRet != ERROR_SUCCESS)
								DllTrace(DLL_TRACE_ERROR,
								"ControlDialogProc: Load Default View: error %d setting registry key for %s\n",
								dwRet,pPaneExt->pane_name);
							
							CheckMenuItem(
								GetMenu(hWnd),
								ID_VIEW_CONTROL_START + i,
								MF_BYCOMMAND | (dwFoo ? MF_CHECKED : MF_UNCHECKED));
							
							pExt->PaneState[i] = (BOOL)dwFoo;
							
						}
						
						ShowControlPanes(hWnd,TRUE);
						
						RegCloseKey(hKey);
					} else {
						DllTrace(DLL_TRACE_ERROR,"ControlPaneDlgProc: Load Default View: Error %08x on RegCreateKeyEx\n",dwRet);
					}
					RegCloseKey(hCSK);
				} else {
					DllTrace(DLL_TRACE_ERROR,"ControlPaneDlgProc: Failed to open camera settings key: %s",StrLastError());
				}
			} else {
				// no camera: nothing to do
			}
			break;
			
		case ID_FILE_SAVEDEFAULTVIEW:
			pCam = pExt->pCamera;
			if(pCam)
			{
				if((hCSK = OpenCameraSettingsKey(NULL,0,KEY_ALL_ACCESS)) != NULL)
				{
					pCam->GetCameraUniqueID(&UniqueID);
					StringCbPrintf(buf,sizeof(buf),"%08x%08x\\ControlPanes\\DefaultView",UniqueID.HighPart,UniqueID.LowPart);
					dwRet = RegCreateKeyEx(hCSK,buf,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,&dwDisposition);
					if(dwRet == ERROR_SUCCESS)
					{
						for(i=0; i<pExt->nPanes; i++)
						{
							hWndChild = GetDlgItem(hWnd,ID_FIRST_CONTROL_PANE + i);
							pPaneExt = (PCONTROL_PANE_EXTENSION) GetWindowLongPtr(hWndChild,GWLP_USERDATA);
							dwFoo = pExt->PaneState[i];
							dwRet = RegSetValueEx(hKey,pPaneExt->pane_name,0,REG_DWORD,(LPBYTE)&dwFoo,dwSize);
							if(dwRet != ERROR_SUCCESS)
								DllTrace(DLL_TRACE_ERROR,
								"ControlDialogProc: Save Default View: error %d setting registry key for %s\n",
								dwRet,pPaneExt->pane_name);
						}
						RegCloseKey(hKey);
					} else {
						DllTrace(DLL_TRACE_ERROR,"ControlDialogProc: Save Default View: Error %d opening key %s\n",dwRet,buf);
					}
					RegCloseKey(hCSK);
				} else {
					DllTrace(DLL_TRACE_ERROR,"ControlPaneDlgProc: Failed to open camera settings key: %s",StrLastError());
				}			
			} else {
				// no camera, nothing to do
			}
			break;
			
		case ID_FILE_CLOSE:
			DestroyWindow(hWnd);
			break;
		case ID_VIEW_ALLCONTROLS:
			for(i=0; i<pExt->nPanes; i++)
			{
				pExt->PaneState[i] = 1;
				CheckMenuItem(
					GetMenu(hWnd),
					ID_VIEW_CONTROL_START + i,
					MF_BYCOMMAND | MF_CHECKED);
			}
			ShowControlPanes(hWnd,TRUE);
			break;
		case ID_VIEW_STRICT_PRESENT:
			for(i=0; i<pExt->nPanes; i++)
			{
				HWND hWndPanel = GetDlgItem(hWnd,ID_FIRST_CONTROL_PANE + i);
				PCONTROL_PANE_EXTENSION pCPExt;
				pCPExt = (PCONTROL_PANE_EXTENSION)GetWindowLongPtr(hWndPanel,GWLP_USERDATA);
				pControl = pCPExt->pControl;
				pExt->PaneState[i] = 
					(((pCPExt->flags & PIF_STROBE) != 0) || pExt->pCamera->HasFeature(pControl->GetFeatureID()) &&
					pControl->HasPresence() &&
					pControl->StatusPresence());
				CheckMenuItem(
					GetMenu(hWnd),
					ID_VIEW_CONTROL_START + i,
					MF_BYCOMMAND | (pExt->PaneState[i] ? MF_CHECKED : MF_UNCHECKED));
			}
			ShowControlPanes(hWnd,TRUE);
			break;
		case ID_VIEW_LOOSE_PRESENT:
			for(i=0; i<pExt->nPanes; i++)
			{
				HWND hWndPanel = GetDlgItem(hWnd,ID_FIRST_CONTROL_PANE + i);
				PCONTROL_PANE_EXTENSION pCPExt;
				pCPExt = (PCONTROL_PANE_EXTENSION)GetWindowLongPtr(hWndPanel,GWLP_USERDATA);
				pControl = pCPExt->pControl;
				pExt->PaneState[i] = (pExt->pCamera->HasFeature(pControl->GetFeatureID()) ||
					pControl->HasPresence() ||
					pControl->StatusPresence());
				CheckMenuItem(
					GetMenu(hWnd),
					ID_VIEW_CONTROL_START + i,
					MF_BYCOMMAND | (pExt->PaneState[i] ? MF_CHECKED : MF_UNCHECKED));
			}
			ShowControlPanes(hWnd,TRUE);
			break;
		default:
			if(wmId >= ID_VIEW_CONTROL_START && wmId < ID_VIEW_CONTROL_END)
			{
				// toggle a pane
				i = wmId - ID_VIEW_CONTROL_START;
				pExt->PaneState[i] ^= 1;
				CheckMenuItem(
					GetMenu(hWnd),
					wmId,
					MF_BYCOMMAND | (pExt->PaneState[i] ? MF_CHECKED : MF_UNCHECKED));
				ShowControlPanes(hWnd,TRUE);
			} else {
				lRetval = DefWindowProc(hWnd, message, wParam, lParam);
			}
			
		} // switch(wmId)
		break;
		
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: Add any drawing code here...
		EndPaint(hWnd, &ps);
		break;
		
	case WM_DESTROY:
		DllTrace(DLL_TRACE_CHECK,"ControlDialogWndProc: WM_DESTROY: Freeing %08x\n",pExt);
		DestroyAcceleratorTable(pExt->hAccel);
		SetFocus(pExt->hWndParent);
		LocalFree(pExt);
		break;
		
	case WM_HSCROLL:
		si.cbSize = sizeof(SCROLLINFO);
		si.fMask = SIF_ALL;
		GetScrollInfo(hWnd,SB_HORZ,&si);
		switch(LOWORD(wParam))
		{
		case SB_THUMBPOSITION:
			si.nPos = si.nTrackPos;
			break;
		case SB_LEFT:
		case SB_LINELEFT:
			si.nPos -= 10;
			break;
		case SB_RIGHT:
		case SB_LINERIGHT:
			si.nPos += 10;
			break;
		case SB_PAGELEFT:
			si.nPos -= si.nPage;
			break;
		case SB_PAGERIGHT:
			si.nPos += si.nPage;
			break;
		}
		si.fMask = SIF_POS;
		pExt->trackpos = (LOWORD(wParam) == SB_THUMBTRACK ? si.nTrackPos : si.nPos);
		if(pExt->trackpos < 0)
			pExt->trackpos = 0;
		if(pExt->trackpos >= (si.nMax - (int)si.nPage))
			pExt->trackpos = si.nMax - si.nPage - 1;
		SetScrollInfo(hWnd,SB_HORZ,&si,TRUE);
		if(LOWORD(wParam) != SB_THUMBPOSITION)
			ShowControlPanes(hWnd,FALSE);
		break;
		
		default:
			lRetval = DefWindowProc(hWnd, message, wParam, lParam);
   }
   
   DllTrace(DLL_TRACE_EXIT,"EXIT ControlDialogWndProc (%d)\n",lRetval);
   return lRetval;
}