virtual void Stat( const SCXCoreLib::SCXFilePath & path, SCXCoreLib::SCXFileSystem::SCXStatStruct * pStat) { // warnings as errors, so deal with the unused params (void) path; switch (m_slaveIndex) { case 0: // plausible /hda5 devid SetupDevice(pStat, 3, 5); break; case 1: // plausible /hdb2 devid SetupDevice(pStat, 4, 2); break; default: // there is no longer a system path for /dev/hdd2 ThrowFileNotFound(path.Get()); break; } }
virtual void Stat( const SCXCoreLib::SCXFilePath & path, SCXCoreLib::SCXFileSystem::SCXStatStruct * pStat) { // warnings as errors, so deal with the unused params (void) path; switch (m_slaveIndex) { case 0: // plausible /hda5 devid SetupDevice(pStat, 3, 5); break; case 1: // plausible /hdb2 devid SetupDevice(pStat, 4, 2); break; case 2: // plausible /hdd2 devid SetupDevice(pStat, 5, 2); break; default: // shouldn't reach this point CPPUNIT_FAIL("The SCXLVMUtils external dependency ReadAllLinesAsUTF8 is not implemented for this device."); break; } }
virtual void Stat( const SCXCoreLib::SCXFilePath & path, SCXCoreLib::SCXFileSystem::SCXStatStruct * pStat) { // warnings as errors, so deal with the unused params (void) path; if ((m_count++ % 2) == 0) { SetupDevice(pStat, 10, 2); } else { SetupDevice(pStat, 253, 2); } }
Bool VIV2DGPUCtxInit(GALINFOPTR galInfo) { TRACE_ENTER(); static gctBOOL inited = gcvFALSE; gctBOOL ret = gcvFALSE; gctPOINTER mHandle = gcvNULL; VIVGPUPtr gpuctx = NULL; gceSTATUS status = gcvSTATUS_OK; if (inited) { TRACE_EXIT(TRUE); } if (galInfo->mGpu != NULL) { TRACE_ERROR("UNDEFINED GPU CTX\n"); TRACE_EXIT(FALSE); } status = gcoOS_Allocate(gcvNULL, sizeof (VIVGPU), &mHandle); if (status < 0) { TRACE_ERROR("Unable to allocate driver, status = %d\n", status); TRACE_EXIT(FALSE); } gpuctx = (VIVGPUPtr) (mHandle); ret = SetupDriver(&gpuctx->mDriver); if (ret != gcvTRUE) { TRACE_ERROR("GPU DRIVER FAILED\n"); TRACE_EXIT(FALSE); } ret = SetupDevice(&(gpuctx->mDevice), gpuctx->mDriver); if (ret != gcvTRUE) { TRACE_ERROR("GPU DEVICE INIT FAILED\n"); TRACE_EXIT(FALSE); } inited = gcvTRUE; galInfo->mGpu = gpuctx; TRACE_EXIT(TRUE); }
void CDevice::Process() { if (m_output.empty()) Log("%s: starting", m_name.c_str()); else Log("%s: starting with output \"%s\"", m_name.c_str(), m_output.c_str()); if (m_setpriority) { sched_param param = {}; param.sched_priority = m_threadpriority; int returnv = pthread_setschedparam(m_thread, SCHED_FIFO, ¶m); if (returnv == 0) Log("%s: successfully set thread priority to %i", m_name.c_str(), m_threadpriority); else LogError("%s: error setting thread priority to %i: %s", m_name.c_str(), m_threadpriority, GetErrno(returnv).c_str()); } int64_t setuptime; while(!m_stop) { //keep trying to set up the device every 10 seconds while(!m_stop) { Log("%s: setting up", m_name.c_str()); setuptime = GetTimeUs(); if (!SetupDevice()) { CloseDevice(); LogError("%s: setting up failed, retrying in 10 seconds", m_name.c_str()); USleep(10000000LL, &m_stop); } else { Log("%s: setup succeeded", m_name.c_str()); break; } } //keep calling writeoutput until we're asked to stop or writeoutput fails while(!m_stop) { if (!WriteOutput()) { //make sure to wait at least one second before trying to set up again Log("%s: io operation failed, retry to setup", m_name.c_str()); USleep(Max(1000000LL - (GetTimeUs() - setuptime), 0)); break; } } CloseDevice(); Log("%s: closed", m_name.c_str()); } Log("%s: stopped", m_name.c_str()); }
virtual void Stat( const SCXCoreLib::SCXFilePath & path, SCXCoreLib::SCXFileSystem::SCXStatStruct * pStat) { // warnings as errors, so deal with the unused params (void) path; SetupDevice(pStat, 253, 2); }
void DevicesConfigPanel::OnSetupDeviceBClicked(WndButton &button) { SetupDevice(); // this is a hack to get the dialog to retain focus because // the progress dialog in the vario configuration somehow causes // focus problems button.set_focus(); }
//---------------------------------------------------------------------------- bool MediaFoundationVideoDevice::SetupDevice(unsigned int streamIndex, unsigned int w, unsigned int h, unsigned int idealFramerate, GUID subtype) { unsigned int formatIndex = 0; if(!FindType(formatIndex, streamIndex, w, h, idealFramerate, subtype)) { LOG_ERROR("MediaFoundationVideoDevice::SetupDevice failed: device " << this->DeviceIndex << ": Cannot find the requested type"); return false; } return SetupDevice(streamIndex, formatIndex); }
void XText::GetTextBox(XGraphicDevice * dev, XRect * r) { POINTL ptl[TXTBOX_COUNT]; SetupDevice(dev); GpiQueryTextBox(dev->hps, text.GetLength(), (PSZ) (char*) text, TXTBOX_COUNT, ptl); r->SetX(ptl[TXTBOX_BOTTOMLEFT].x); r->SetWidth(ptl[TXTBOX_BOTTOMRIGHT].x - ptl[TXTBOX_BOTTOMLEFT].x); r->SetY(ptl[TXTBOX_BOTTOMLEFT].y); r->SetWidth(ptl[TXTBOX_TOPLEFT].y - ptl[TXTBOX_BOTTOMLEFT].y); }
/* * Find all the devices connected and setup ports for them. */ bool Dmx4LinuxPlugin::SetupDevices() { struct dmx_capabilities cap; struct dmx_info info; if (ioctl(m_in_descriptor->ReadDescriptor(), DMX_IOCTL_GET_INFO, &info) < 0) { OLA_WARN << "failed to fetch universe list"; return false; } if (info.max_in_universes > 0) { m_in_devices_count = info.max_in_universes; try { m_in_buffer = new uint8_t[DMX_UNIVERSE_SIZE * info.max_in_universes]; } catch(std::bad_alloc& ex) { m_in_buffer = NULL; } } for (int i = 0; i < info.max_in_universes; i++) { cap.direction = DMX_DIRECTION_INPUT; cap.universe = i; if (ioctl(m_in_descriptor->ReadDescriptor(), DMX_IOCTL_GET_CAP, &cap) >= 0) { if (cap.maxSlots > 0) { SetupDevice(cap.family, cap.universe, cap.direction); } } } for (int i = 0; i < info.max_out_universes; i++) { cap.direction = DMX_DIRECTION_OUTPUT; cap.universe = i; if (ioctl(m_in_descriptor->ReadDescriptor(), DMX_IOCTL_GET_CAP, &cap) >= 0) { if (cap.maxSlots > 0) { SetupDevice(cap.family, cap.universe, cap.direction); } } } return true; }
void XMarker::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { SetupDevice(dev); POINTL po; po.x = p.x; po.y = p.y; GpiMove(dev->hps, &po); GpiMarker(dev->hps, &po); } }
void EnableVulkan( xcb_connection_t *connection, xcb_window_t *window, struct display_camera *camera ) #endif { VkPhysicalDevice useDevice; struct SwapChain chain; SetupDevice(); useDevice = vl.physicalDevices[0]; CreateDevice( useDevice ); swapChainConnect( &chain ); swapChainPlatformConnect( &chain, hInstance, camera->hWndInstance ); }
/** This implementation of Stat will return a good device on the first call and throw on the second. \param[in] path path to file/directory to perform stat on. \param[out] pStat Pointer to a stat structure that should be filled. */ void Stat(const SCXCoreLib::SCXFilePath & path, SCXCoreLib::SCXFileSystem::SCXStatStruct * pStat) { if ((m_count++ % 2) == 0) { // even calls (0, 2, 4, etc...) get a device setup SetupDevice(pStat, m_major, m_minor); } else { // for odd calls, the behavior is for an invalid path ThrowFileNotFound(path.Get()); } }
void CDevice::Process() { if (m_output.empty()) Log("%s: starting", m_name.c_str()); else Log("%s: starting with output \"%s\"", m_name.c_str(), m_output.c_str()); int64_t setuptime; while(!m_stop) { //keep trying to set up the device every 10 seconds while(!m_stop) { Log("%s: setting up", m_name.c_str()); setuptime = GetTimeUs(); if (!SetupDevice()) { CloseDevice(); LogError("%s: setting up failed, retrying in 10 seconds", m_name.c_str()); USleep(10000000LL, &m_stop); } else { Log("%s: setup succeeded", m_name.c_str()); break; } } //keep calling writeoutput until we're asked to stop or writeoutput fails while(!m_stop) { if (!WriteOutput()) { //make sure to wait at least one second before trying to set up again USleep(Max(1000000LL - (GetTimeUs() - setuptime), 0)); break; } } CloseDevice(); Log("%s: closed", m_name.c_str()); } Log("%s: stopped", m_name.c_str()); }
void XArc::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { SetupDevice(dev); POINTL po; po.x = p.x; po.y = p.y; GpiMove(dev->hps, &po); ARCPARAMS a; a.lQ = w; a.lP = h; a.lR = x; a.lS = y; GpiSetArcParams(dev->hps, &a); if (vis) { GpiBeginPath(dev->hps, 1); GpiPartialArc(dev->hps, &po, MAKEFIXED(1, 0), MAKEFIXED(st, 0), MAKEFIXED(en, 0)); GpiLine(dev->hps, &po); GpiEndPath(dev->hps); if (filled) GpiFillPath(dev->hps, 1, FPATH_WINDING); else GpiOutlinePath(dev->hps, 1, 0); } else { POINTL pt[3]; //berechnen! pt[0].x = pt[0].y = 0; GpiMove(dev->hps, &pt[0]); pt[1].x = pt[1].y = 100; pt[2].x = 200; pt[2].y = 0; GpiPointArc(dev->hps, &pt[1]); } } }
void XLine::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { POINTL po; po.x = p.x; po.y = p.y; SetupDevice(dev); GpiBeginPath(dev->hps, 1); GpiMove(dev->hps, &po); //POINTL ptl;// = po; po.x = p.x + width; po.y = p.y + height; GpiLine(dev->hps, &po); GpiEndPath(dev->hps); GpiOutlinePath(dev->hps, 1, 0); } }
void XText::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { SetupDevice(dev); if (p2.GetX() == 0) { POINTL pnt; pnt.x = p.GetX(); pnt.y = p.GetY(); GpiCharStringAt(dev->hps, &pnt, text.GetLength(), (PSZ) (char*) text); } else { RECTL rc; rc.yBottom = p.y + dev->yOffset; rc.yTop = p2.y + dev->yOffset; rc.xLeft = p.x + dev->xOffset; rc.xRight = p2.x + dev->xOffset; char *t = text; if (style & DT_WORDBREAK) { int drawn = 0, totalDrawn, length = text.GetLength(); for (totalDrawn = 0; totalDrawn < length; rc.yTop -= (LONG) (font->realSize)) { drawn = WinDrawText(dev->hps, length - totalDrawn, (PSZ) t + totalDrawn, &rc, color.GetColor(), 0, style); if (drawn) totalDrawn += drawn; else break; } } else WinDrawText(dev->hps, text.GetLength(), (PCH) t, &rc, color.GetColor(), 0, style); } return; } }
Listener :: Listener ( QWidget * parent ) : QMenu ( parent ) , UMonitor ( UdevContext ) { MIcon = QIcon ( Opt . toStr ( kMountPix ) ) ; UIcon = QIcon ( Opt . toStr ( kUnmntPix ) ) ; EIcon = QIcon ( Opt . toStr ( kEjectPix ) ) ; RIcon = QIcon ( Opt . toStr ( kRemovePix ) ) ; DIcon = QIcon ( Opt . toStr ( kUnlockPix ) ) ; LIcon = QIcon ( Opt . toStr ( kLockPix ) ) ; CIcon = QIcon ( Opt . toStr ( kUnrecPix ) ) ; TIcon = QIcon ( Opt . toStr ( kTMntPix ) ) ; setWindowIcon ( TIcon ) ; TPref = Opt . AppName ( ) + " - " ; Env = QProcessEnvironment :: systemEnvironment ( ) ; Suppl = reqNoAct ; HDevs = QRegExp ( Opt . toStr ( kHideDevs ) ) ; FDevs = QRegExp ( Opt . toStr ( kForceDevs ) ) ; Verb = Opt . toBool ( kVerbose ) ; const bool TryMount = Opt . toBool ( kMntStart ) , Show = Opt . toBool ( kStartShow ) ; UMonitor . AddMatch ( Subsys_Block , NULL ) ; UMonitor . EnableReceiving ( ) ; connect ( & UMonitor , SIGNAL ( Changed ( ) ) , this , SLOT ( DeviceAction ( ) ) ) ; connect ( & MInfo , SIGNAL ( Changed ( ) ) , this , SLOT ( MountAction ( ) ) ) ; connect ( & Opt , SIGNAL ( Changed ( ) ) , this , SLOT ( OptChanged ( ) ) ) ; UdevEnum En ( UdevContext ) ; En . MatchSubsys ( Subsys_Block ) ; En . ScanDevs ( ) ; foreach ( const UdevPair P , En . GetList ( ) ) { SetupDevice ( UdevDev ( UdevContext , P . first ) , TryMount , Show ) ; }//done }// Listener
status_t DavicomDevice::CompareAndReattach(usb_device device) { const usb_device_descriptor *deviceDescriptor = gUSBModule->get_device_descriptor(device); if (deviceDescriptor == NULL) { TRACE_ALWAYS("Error getting USB device descriptor.\n"); return B_ERROR; } if (deviceDescriptor->vendor_id != fVendorID && deviceDescriptor->product_id != fProductID) { // this certainly isn't the same device return B_BAD_VALUE; } // this is the same device that was replugged - clear the removed state, // re-setup the endpoints and transfers and open the device if it was // previously opened fDevice = device; fRemoved = false; status_t result = _SetupEndpoints(); if (result != B_OK) { fRemoved = true; return result; } // we need to setup hardware on device replug result = SetupDevice(true); if (result != B_OK) { return result; } if (fOpen) { fOpen = false; result = Open(fNonBlocking ? O_NONBLOCK : 0); } return result; }
void XCircle::Draw( XGraphicDevice * dev) { if (!(settings & GO_HIDE)) { // SHORT modify = ( w> 10 ? 10 : 1); SetupDevice(dev); POINTL po; po.x = p.x; po.y = p.y; GpiMove(dev->hps, &po); ARCPARAMS a; a.lQ = w / 10; a.lP = h / 10; a.lR = x / 10; a.lS = y / 10; GpiSetArcParams(dev->hps, &a); GpiFullArc(dev->hps, (filled == FALSE ? DRO_OUTLINE : DRO_FILL), MAKEFIXED(10, 0)); } }
Device::Device(bool Debug, int PinNumber, bool Digital, bool Input, int MinValue, int MaxValue, int InitialValue, int StepValue, bool StepDirectionUp, int DelayToChange) { SetupDevice(Debug, PinNumber, Digital, Input, MinValue, MaxValue, InitialValue, StepValue, StepDirectionUp, DelayToChange); }
WxIrrMainWindow::WxIrrMainWindow(const wxString& title, void (*draw)(WxIrrViewportManager*), void (*update)(void), bool (*irrlichtLeftMouseDown)(bool controlDown, bool shiftDown, int x, int y), bool (*irrlichtLeftMouseUp)(bool controlDown, bool shiftDown, int x, int y), bool (*irrlichtLeftMouseDoubleClick)(bool controlDown, bool shiftDown, int x, int y), bool (*irrlichtMouseMove)(bool controlDown, bool shiftDown, int x, int y, int moveX, int moveY), void (*irrlichtCameraMouseMove)(int moveX, int moveY, WxIrrViewport* selectedViewport), void (*irrlichtCameraKeyDown)(int id, WxIrrViewport* selectedViewport), void (*irrlichtCameraKeyUp)(int id), void (*irrlichtCameraKeyboardReset)(void), void (*simulationMouseMove)(wxPoint mousePos, bool isShiftDown, WxIrrViewport* mouseOverViewport), bool (*simulationMouseClick)(bool isShiftDown, bool isControlDown), bool (*simulationMouseDoubleClick)(void), void (*SimulationStartMouseChecking)(void), void (*onSimulationShowAxesFunctionPointer)(bool), void (*onSimulationShowObjectNameFunctionPointer)(bool), SColor (*onSimulationXAxisGetColorFunctionPointer)(void), SColor (*onSimulationYAxisGetColorFunctionPointer)(void), SColor (*onSimulationZAxisGetColorFunctionPointer)(void), void (*onSimulationXAxisChangeColorFunctionPointer)(wxColour& color), void (*onSimulationYAxisChangeColorFunctionPointer)(wxColour& color), void (*onSimulationZAxisChangeColorFunctionPointer)(wxColour& color), void (*onSimulationShowXYGridFunctionPointer)(bool), void (*onSimulationShowXZGridFunctionPointer)(bool), void (*onSimulationShowYZGridFunctionPointer)(bool)) : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(800, 600)) { OnSimulationShowAxesFunctionPointer = onSimulationShowAxesFunctionPointer; OnSimulationShowObjectNameFunctionPointer = onSimulationShowObjectNameFunctionPointer; OnSimulationXAxisGetColorFunctionPointer = onSimulationXAxisGetColorFunctionPointer; OnSimulationYAxisGetColorFunctionPointer = onSimulationYAxisGetColorFunctionPointer; OnSimulationZAxisGetColorFunctionPointer = onSimulationZAxisGetColorFunctionPointer; OnSimulationXAxisChangeColorFunctionPointer = onSimulationXAxisChangeColorFunctionPointer; OnSimulationYAxisChangeColorFunctionPointer = onSimulationYAxisChangeColorFunctionPointer; OnSimulationZAxisChangeColorFunctionPointer = onSimulationZAxisChangeColorFunctionPointer; OnSimulationShowXYGridFunctionPointer = onSimulationShowXYGridFunctionPointer; OnSimulationShowXZGridFunctionPointer = onSimulationShowXZGridFunctionPointer; OnSimulationShowYZGridFunctionPointer = onSimulationShowYZGridFunctionPointer; leftPanel = new WxIrrViewportWindow(this, 1000); leftPanel->SetBackgroundColour(wxColour(wxT("Black"))); irr::SIrrlichtCreationParameters param; #if defined _WX_IRR_WINDOWS param.DriverType = EDT_DIRECT3D9; param.AntiAlias = false; param.WindowId = reinterpret_cast<void*>(GetLeftPanelHandle()); #elif defined _WX_IRR_LINUX param.DriverType = EDT_OPENGL; param.AntiAlias = false; GtkWidget* handle = (GtkWidget*)GetLeftPanelHandle(); gtk_widget_realize(handle); Window xHandle = GDK_WINDOW_XWINDOW(handle->window); param.WindowId = (void*)(xHandle); #elif defined _WX_IRR_MACOS //param.DriverType = EDT_OPENGL; #else //return false; Close(); #endif leftPanel->InitalizeViewportManager(); SetupDevice(param, draw, update, irrlichtLeftMouseDown, irrlichtLeftMouseUp, irrlichtLeftMouseDoubleClick, irrlichtMouseMove, irrlichtCameraMouseMove, irrlichtCameraKeyDown, irrlichtCameraKeyUp, irrlichtCameraKeyboardReset, simulationMouseMove, simulationMouseClick, simulationMouseDoubleClick, SimulationStartMouseChecking); //Main camera ICameraSceneNode* camera = GetDevice()->getSceneManager()->addCameraSceneNode(); camera->setPosition(Vector3(30,-10,30)); //camera->bindTargetAndRotation(true); //camera->setTarget(Vector3(0,0,0)); Vector3 currentCameraRot = camera->getRotation(); Vector3 rot = currentCameraRot.rotationToDirection(); Vector3 pos = camera->getPosition(); camera->setTarget(rot + pos); camera->setFarValue(100000); SetCamera(camera); rightPanel = new SimulationPanel(this, 1001, wxDefaultPosition, wxDefaultSize); rightPanel->SetBackgroundColour(wxColour(wxT("Black"))); m_mgr.SetManagedWindow(this); //Create Main Menu menuBar = new wxMenuBar(); menuBarManager = new PhysicsHelperMenuBar(menuBar); SetMenuBar( menuBar ); //Status bar CreateStatusBar(); SetStatusText( wxT("PhysicsHelper") ); statusBarText = wxT("PhysicsHelper"); toolBarsManager = new PhysicsHelperToolbars(this, m_mgr); //add the normal panes m_mgr.AddPane(leftPanel, wxAuiPaneInfo().CenterPane().Name(wxT("leftPanel"))); m_mgr.AddPane(rightPanel, wxAuiPaneInfo().CloseButton(false).Right().PinButton(true).MinimizeButton(true).Name(wxT("rightPanel"))); m_mgr.Update(); //Centre(); }
// MouseInputStreamImpl(IDirectInputDevice2* pdid, HWND hwnd) : MouseInputStreamImpl(IDirectInputDevice7* pdid, HWND hwnd) : // mdvalley: DInput7 m_pdid(pdid), m_rect(0, 0, 0, 0), m_point(0, 0), m_vvalueObject(3), m_bEnabled(false), m_bBuffered(true), m_pbuttonEventSource(ButtonEvent::Source::Create()) { // // Are we running on NT // /*!!! OSVERSIONINFO osvi = { sizeof(osvi) }; ZVerify(GetVersionEx(&osvi)); if ((VER_PLATFORM_WIN32_NT & osvi.dwPlatformId) != 0) { m_bBuffered = false; } */ // // Enumerate the buttons and values // DDCall(m_pdid->EnumObjects(StaticEnumObjectsCallback, this, DIDFT_ALL)); // // Setup the device // SetupDevice(); // // We only need mouse input when we are in the foreground // DDCall(m_pdid->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND)); // // Get the mouse acceleration values // int pvalue[3]; ZVerify(SystemParametersInfo(SPI_GETMOUSE, 0, pvalue, 0)); m_threshold1 = pvalue[0]; m_threshold2 = pvalue[1]; m_acceleration = pvalue[2]; m_sensitivity = 1.0f; /* !!! this only works on NT50 int speed; ZVerify(SystemParametersInfo(SPI_GETMOUSESPEED, 0, &speed, 0)); if (speed <= 2) { m_sensitivity = float(speed) / 32.0f; } else if(speed >= 3 && speed <= 10 ) { m_sensitivity = float(speed-2) / 8.0f; } else { m_sensitivity = float(speed-6) / 4.0f; } */ }