/** * Create and init 2 master devices (VCP + VCK) and two slave devices, one * default mouse, one default keyboard. */ struct devices init_devices(void) { ClientRec client; struct devices devices; client = init_client(0, NULL); AllocDevicePair(&client, "Virtual core", &devices.vcp, &devices.vck, CorePointerProc, CoreKeyboardProc, TRUE); inputInfo.pointer = devices.vcp; inputInfo.keyboard = devices.vck; ActivateDevice(devices.vcp, FALSE); ActivateDevice(devices.vck, FALSE); EnableDevice(devices.vcp, FALSE); EnableDevice(devices.vck, FALSE); AllocDevicePair(&client, "", &devices.mouse, &devices.kbd, CorePointerProc, CoreKeyboardProc, FALSE); ActivateDevice(devices.mouse, FALSE); ActivateDevice(devices.kbd, FALSE); EnableDevice(devices.mouse, FALSE); EnableDevice(devices.kbd, FALSE); devices.num_devices = 4; devices.num_master_devices = 2; fake_init_sprite(devices.mouse); fake_init_sprite(devices.vcp); return devices; }
/** * Create and init 2 master devices (VCP + VCK) and two slave devices, one * default mouse, one default keyboard. */ struct devices init_devices(void) { ClientRec client; struct devices local_devices; int ret; /* * Put a unique name in display pointer so that when tests are run in * parallel, their xkbcomp outputs to /tmp/server-<display>.xkm don't * stomp on each other. */ #ifdef HAVE_GETPROGNAME display = getprogname(); #elif HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME display = program_invocation_short_name; #endif client = init_client(0, NULL); AllocDevicePair(&client, "Virtual core", &local_devices.vcp, &local_devices.vck, CorePointerProc, CoreKeyboardProc, TRUE); inputInfo.pointer = local_devices.vcp; inputInfo.keyboard = local_devices.vck; ret = ActivateDevice(local_devices.vcp, FALSE); assert(ret == Success); /* This may fail if xkbcomp fails or xkb-config is not found. */ ret = ActivateDevice(local_devices.vck, FALSE); assert(ret == Success); EnableDevice(local_devices.vcp, FALSE); EnableDevice(local_devices.vck, FALSE); AllocDevicePair(&client, "", &local_devices.mouse, &local_devices.kbd, TestPointerProc, CoreKeyboardProc, FALSE); ret = ActivateDevice(local_devices.mouse, FALSE); assert(ret == Success); ret = ActivateDevice(local_devices.kbd, FALSE); assert(ret == Success); EnableDevice(local_devices.mouse, FALSE); EnableDevice(local_devices.kbd, FALSE); local_devices.num_devices = 4; local_devices.num_master_devices = 2; fake_init_sprite(local_devices.mouse); fake_init_sprite(local_devices.vcp); return local_devices; }
static void resume(pmEvent event, Bool undo) { int i; InputInfoPtr pInfo; xf86AccessEnter(); for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->PMEvent) xf86Screens[i]->PMEvent(xf86Screens[i], event, undo); else { xf86Screens[i]->vtSema = TRUE; xf86Screens[i]->EnterVT(xf86Screens[i]); } } OsReleaseSIGIO(); for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (xf86Screens[i], TRUE); } dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { EnableDevice(pInfo->dev, TRUE); pInfo = pInfo->next; } }
static void resume(pmEvent event, Bool undo) { int i; InputInfoPtr pInfo; xf86AccessEnter(); xf86EnterServerState(SETUP); for (i = 0; i < xf86NumScreens; i++) { xf86EnableAccess(xf86Screens[i]); if (xf86Screens[i]->PMEvent) xf86Screens[i]->PMEvent(i,event,undo); else { xf86Screens[i]->vtSema = TRUE; xf86Screens[i]->EnterVT(i, 0); } } xf86EnterServerState(OPERATING); for (i = 0; i < xf86NumScreens; i++) { xf86EnableAccess(xf86Screens[i]); if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); #if !defined(__EMX__) pInfo = xf86InputDevs; while (pInfo) { EnableDevice(pInfo->dev); pInfo = pInfo->next; } #endif xf86inSuspend = FALSE; }
void cOpenClHardware::EnableDevicesByHashList(const QString &list) { QStringList stringList = list.split("|"); // disable all devices for (int dev = 0; dev < clDeviceWorkers.size(); dev++) { DisableDevice(dev); } // enable only devices from list for (int i = 0; i < stringList.size(); i++) { QByteArray hashFromList = QByteArray::fromHex(stringList.at(i).toLocal8Bit()); for (int dev = 0; dev < clDeviceWorkers.size(); dev++) { QByteArray hashFromDevice = clDeviceWorkers[dev].getDeviceInformation().hash; if (hashFromDevice.left(3) == hashFromList.left(3)) { EnableDevice(dev); WriteLog( QString("Device ") + clDeviceWorkers[dev].getDeviceInformation().deviceName + " enabled", 3); } } } }
/** * Allocate an virtual slave device for xtest events, this * is a slave device to inputInfo master devices */ void InitXTestDevices(void) { if(AllocXTestDevice(serverClient, "Virtual core", &xtestpointer, &xtestkeyboard, inputInfo.pointer, inputInfo.keyboard) != Success) FatalError("Failed to allocate XTest devices"); if (ActivateDevice(xtestpointer, TRUE) != Success || ActivateDevice(xtestkeyboard, TRUE) != Success) FatalError("Failed to activate XTest core devices."); if (!EnableDevice(xtestpointer, TRUE) || !EnableDevice(xtestkeyboard, TRUE)) FatalError("Failed to enable XTest core devices."); AttachDevice(NULL, xtestpointer, inputInfo.pointer); AttachDevice(NULL, xtestkeyboard, inputInfo.keyboard); }
// called after costruction void GContactlessReaderManager::Initialize() { m_pCLRService = GContactlessReaderService::GetService(); if (m_pCLRService) { m_pCLRService->AttachManager(this); EnableDevice(); } memset(m_cMagStripeLegend, 0, sizeof(m_cMagStripeLegend)); }
static int add_master(ClientPtr client, xXIAddMasterInfo *c, int flags[MAXDEVICES]) { DeviceIntPtr ptr, keybd, XTestptr, XTestkeybd; char* name; int rc; name = calloc(c->name_len + 1, sizeof(char)); strncpy(name, (char*)&c[1], c->name_len); rc = AllocDevicePair(client, name, &ptr, &keybd, CorePointerProc, CoreKeyboardProc, TRUE); if (rc != Success) goto unwind; if (!c->send_core) ptr->coreEvents = keybd->coreEvents = FALSE; /* Allocate virtual slave devices for xtest events */ rc = AllocXTestDevice(client, name, &XTestptr, &XTestkeybd, ptr, keybd); if (rc != Success) { DeleteInputDeviceRequest(ptr); DeleteInputDeviceRequest(keybd); goto unwind; } ActivateDevice(ptr, FALSE); ActivateDevice(keybd, FALSE); flags[ptr->id] |= XIMasterAdded; flags[keybd->id] |= XIMasterAdded; ActivateDevice(XTestptr, FALSE); ActivateDevice(XTestkeybd, FALSE); flags[XTestptr->id] |= XISlaveAdded; flags[XTestkeybd->id] |= XISlaveAdded; if (c->enable) { EnableDevice(ptr, FALSE); EnableDevice(keybd, FALSE); flags[ptr->id] |= XIDeviceEnabled; flags[keybd->id] |= XIDeviceEnabled; EnableDevice(XTestptr, FALSE); EnableDevice(XTestkeybd, FALSE); flags[XTestptr->id] |= XIDeviceEnabled; flags[XTestkeybd->id] |= XIDeviceEnabled; } /* Attach the XTest virtual devices to the newly created master device */ AttachDevice(NULL, XTestptr, ptr); AttachDevice(NULL, XTestkeybd, keybd); flags[XTestptr->id] |= XISlaveAttached; flags[XTestkeybd->id] |= XISlaveAttached; unwind: free(name); return rc; }
void GContactlessReaderManager::ProcessEventReceived(eEvents e, sDataEvent* pDataEvent) { switch (m_Status) { //====================================================================================================== case eStatusInitial: { switch (e) { case eEventSoftKeyL4: { NextState(eEventSoftKeyL4, eStatusInitial); DisableDevice(); m_pCLRMenu->Quit(); } break; case eEventSoftKeyL3: { NextState(eEventSoftKeyR4, eSatusStatistics); DisableDevice(); GoToStatistics(); } break; case eEventSoftKeyL1: case eEventSoftKeyL2: case eEventSoftKeyR1: case eEventSoftKeyR2: case eEventSoftKeyR3: case eEventSoftKeyR4: LOG(eContactlessReader, eTrace, "IGNORED EVENT [%s] received in [%s].\n", mst_arypcEventLabel[e], mst_arypcStatusLabel[m_Status]); break; case eEventRead: { NextState(eEventRead, eStatusInitial); if(pDataEvent != NULL) { processData((GContactlessReaderServiceStatistics::eTypeStatistics)(pDataEvent->data)); } GoToTestResultScreen(); } break; case eEventError: { NextState(eEventError, eStatusInitial); } break; default: LOG(eContactlessReader, eError, "ERROR: INVALID EVENT [%s] received in [%s].\n", mst_arypcEventLabel[e], mst_arypcStatusLabel[m_Status]); break; } } break; //====================================================================================================== //====================================================================================================== case eSatusStatistics: { switch (e) { case eEventSoftKeyL4: { NextState(eEventSoftKeyL4, eStatusInitial); EnableDevice(); GoToTestResultScreen(); } break; case eEventError: { NextState(eEventError, eSatusStatistics); } break; default: LOG(eContactlessReader, eError, "ERROR: INVALID EVENT [%s] received in [%s].\n", mst_arypcEventLabel[e], mst_arypcStatusLabel[m_Status]); break; } } break; //====================================================================================================== case eStatusError: { switch (e) { default: LOG(eContactlessReader, eError, "ERROR: event [%s] received in eStatusError. The Display device is in unrecoverable state.\n", mst_arypcEventLabel[e]); NextState(e, eStatusError); break; } } break; //====================================================================================================== } if(pDataEvent != NULL) { delete pDataEvent; pDataEvent = NULL; } }
__attribute__((weak)) void vPortSuppressTicksAndSleep(TickType_t xExpectedIdleTime) { unsigned long ulReloadValue, ulCompleteTickPeriods, ulCompletedSysTickIncrements; TickCounter_t tmp; /* because of how we get the current tick counter */ bool tickISRfired; /* Make sure the tick timer reload value does not overflow the counter. */ if(xExpectedIdleTime>xMaximumPossibleSuppressedTicks) { xExpectedIdleTime = xMaximumPossibleSuppressedTicks; } /* Stop the tick timer momentarily. The time the counter is stopped for * is accounted for as best it can be, but using the tickless mode will * inevitably result in some tiny drift of the time maintained by the * kernel with respect to calendar time. */ DISABLE_TICK_COUNTER(); /* Calculate the reload value required to wait xExpectedIdleTime * tick periods. -1 is used because this code will execute part way * through one of the tick periods. */ GET_TICK_CURRENT_VAL(&tmp); ulReloadValue = tmp+(UL_TIMER_COUNTS_FOR_ONE_TICK*(xExpectedIdleTime-1UL)); if (ulReloadValue>ulStoppedTimerCompensation) { ulReloadValue -= ulStoppedTimerCompensation; } /* Enter a critical section but don't use the taskENTER_CRITICAL() * method as that will mask interrupts that should exit sleep mode. */ TICKLESS_DISABLE_INTERRUPTS(); /* If a context switch is pending or a task is waiting for the scheduler * to be unsuspended then abandon the low power entry. */ if (eTaskConfirmSleepModeStatus()==eAbortSleep) { ENABLE_TICK_COUNTER(); /* Restart SysTick. */ TICKLESS_ENABLE_INTERRUPTS(); } else { #if configUSE_LP_TIMER DisableDevice(); ClearInterruptFlag(); WriteCompareReg(xExpectedIdleTime-1); EnableDevice(); /* start timer */ #else SET_TICK_DURATION(ulReloadValue); /* Set the new reload value. */ RESET_TICK_COUNTER_VAL(); /* Reset the counter. */ ENABLE_TICK_COUNTER(); /* Restart tick timer. */ TICK_INTERRUPT_FLAG_RESET(); /* reset flag so we know later if it has fired */ #endif /* Sleep until something happens. configPRE_SLEEP_PROCESSING() can * set its parameter to 0 to indicate that its implementation contains * its own wait for interrupt or wait for event instruction, and so wfi * should not be executed again. However, the original expected idle * time variable must remain unmodified, so a copy is taken. */ /* CPU *HAS TO WAIT* in the sequence below for an interrupt. If vOnPreSleepProcessing() is not used, a default implementation is provided */ /* default wait/sleep code */ __asm volatile("dsb"); __asm volatile("wfi"); __asm volatile("isb"); /* ---------------------------------------------------------------------------- * Here the CPU *HAS TO BE* low power mode, waiting to wake up by an interrupt * ----------------------------------------------------------------------------*/ /* Stop tick counter. Again, the time the tick counter is stopped for is * accounted for as best it can be, but using the tickless mode will * inevitably result in some tiny drift of the time maintained by the * kernel with respect to calendar time. */ tickISRfired = TICK_INTERRUPT_HAS_FIRED(); /* need to check Interrupt flag here, as might be modified below */ DISABLE_TICK_COUNTER(); TICKLESS_ENABLE_INTERRUPTS();/* Re-enable interrupts */ if (tickISRfired) { /* The tick interrupt has already executed, and the timer * count reloaded with the modulo/match value. * Reset the counter register with whatever remains of * this tick period. */ GET_TICK_CURRENT_VAL(&tmp); #if COUNTS_UP SET_TICK_DURATION((UL_TIMER_COUNTS_FOR_ONE_TICK-1UL)-tmp); #else SET_TICK_DURATION((UL_TIMER_COUNTS_FOR_ONE_TICK-1UL)-(ulReloadValue-tmp)); #endif /* The tick interrupt handler will already have pended the tick * processing in the kernel. As the pending tick will be * processed as soon as this function exits, the tick value * maintained by the tick is stepped forward by one less than the * time spent waiting. */ ulCompleteTickPeriods = xExpectedIdleTime-1UL; } else { /* Something other than the tick interrupt ended the sleep. * Work out how long the sleep lasted rounded to complete tick * periods (not the ulReload value which accounted for part ticks). */ GET_TICK_CURRENT_VAL(&tmp); ulCompletedSysTickIncrements = (xExpectedIdleTime*UL_TIMER_COUNTS_FOR_ONE_TICK)-tmp; /* How many complete tick periods passed while the processor was waiting? */ ulCompleteTickPeriods = ulCompletedSysTickIncrements/UL_TIMER_COUNTS_FOR_ONE_TICK; /* The reload value is set to whatever fraction of a single tick period remains. */ SET_TICK_DURATION(((ulCompleteTickPeriods+1)*UL_TIMER_COUNTS_FOR_ONE_TICK)-ulCompletedSysTickIncrements); } /* Restart SysTick so it runs from portNVIC_SYSTICK_LOAD_REG again, then set portNVIC_SYSTICK_LOAD_REG back to its standard value. The critical section is used to ensure the tick interrupt can only execute once in the case that the reload register is near zero. */ RESET_TICK_COUNTER_VAL(); portENTER_CRITICAL(); { ENABLE_TICK_COUNTER(); vTaskStepTick(ulCompleteTickPeriods); SET_TICK_DURATION(UL_TIMER_COUNTS_FOR_ONE_TICK-1UL); } portEXIT_CRITICAL(); } }
/* * xf86VTSwitch -- * Handle requests for switching the vt. */ static void xf86VTSwitch(void) { int i; static int prevSIGIO; InputInfoPtr pInfo; IHPtr ih; DebugF("xf86VTSwitch()\n"); #ifdef XFreeXDGA if(!DGAVTSwitch()) return; #endif /* * Since all screens are currently all in the same state it is sufficient * check the first. This might change in future. */ if (xf86Screens[0]->vtSema) { DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n", BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE)); #ifdef DPMSExtension if (DPMSPowerLevel != DPMSModeOn) DPMSSet(serverClient, DPMSModeOn); #endif for (i = 0; i < xf86NumScreens; i++) { if (!(dispatchException & DE_TERMINATE)) if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE); } /* * Keep the order: Disable Device > LeaveVT * EnterVT > EnableDevice */ for (ih = InputHandlers; ih; ih = ih->next) xf86DisableInputHandler(ih); for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) { if (pInfo->dev) { xf86ReleaseKeys(pInfo->dev); ProcessInputEvents(); DisableDevice(pInfo->dev, TRUE); } } prevSIGIO = xf86BlockSIGIO(); for (i = 0; i < xf86NumScreens; i++) xf86Screens[i]->LeaveVT(i, 0); xf86AccessLeave(); /* We need this here, otherwise */ if (!xf86VTSwitchAway()) { /* * switch failed */ DebugF("xf86VTSwitch: Leave failed\n"); xf86AccessEnter(); for (i = 0; i < xf86NumScreens; i++) { if (!xf86Screens[i]->EnterVT(i, 0)) FatalError("EnterVT failed for screen %d\n", i); } if (!(dispatchException & DE_TERMINATE)) { for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); } } dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { if (pInfo->dev) EnableDevice(pInfo->dev, TRUE); pInfo = pInfo->next; } for (ih = InputHandlers; ih; ih = ih->next) xf86EnableInputHandler(ih); xf86UnblockSIGIO(prevSIGIO); } else { #ifdef XF86PM if (xf86OSPMClose) xf86OSPMClose(); xf86OSPMClose = NULL; #endif for (i = 0; i < xf86NumScreens; i++) { /* * zero all access functions to * trap calls when switched away. */ xf86Screens[i]->vtSema = FALSE; } if (xorgHWAccess) xf86DisableIO(); } } else { DebugF("xf86VTSwitch: Entering\n"); if (!xf86VTSwitchTo()) return; #ifdef XF86PM xf86OSPMClose = xf86OSPMOpen(); #endif if (xorgHWAccess) xf86EnableIO(); xf86AccessEnter(); for (i = 0; i < xf86NumScreens; i++) { xf86Screens[i]->vtSema = TRUE; if (!xf86Screens[i]->EnterVT(i, 0)) FatalError("EnterVT failed for screen %d\n", i); } for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE); } /* Turn screen saver off when switching back */ dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); pInfo = xf86InputDevs; while (pInfo) { if (pInfo->dev) EnableDevice(pInfo->dev, TRUE); pInfo = pInfo->next; } for (ih = InputHandlers; ih; ih = ih->next) xf86EnableInputHandler(ih); xf86UnblockSIGIO(prevSIGIO); } }
//---------------------------------------------------------------------------------------------- // SetPower //---------------------------------------------------------------------------------------------- NTSTATUS SetPower( IN PDEVICE_OBJECT DeviceObject ,IN PDEVICE_EXTENSION DeviceExtension ,IN PIRP Irp ,IN PIO_STACK_LOCATION CurrentIrpStack ) { // 変数宣言 NTSTATUS Status; // デバイスの電源状態が変更された場合にデバイスの状態を変更する #if (NTDDI_VERSION < NTDDI_LONGHORN) switch( CurrentIrpStack->Parameters.Power.Type ) { case SystemPowerState: if( CurrentIrpStack->Parameters.Power.State.SystemState == PowerSystemWorking ) { // デバイスをリセットする DeviceExtension->ResetDevice = TRUE; } break; } // IRP_MJ_POWER 要求を下位ドライバに送る Status = SendPowerRequest( DeviceObject, Irp ); #else if( CurrentIrpStack->Parameters.Power.Type == DevicePowerState ) { switch( CurrentIrpStack->Parameters.Power.State.DeviceState ) { case PowerDeviceD0: // 先に IRP_MN_SET_POWER 要求を下位ドライバに送る Status = SendAndWaitPowerRequest( DeviceObject, Irp ); if( !NT_SUCCESS( Status ) ) { CompleteRequest( Irp, Status, 0 ); return( Status ); } // デバイスを有効にする Status = EnableDevice( DeviceExtension ); // IRP_MN_SET_POWER 要求を完了させる CompleteRequest( Irp, Status, 0 ); break; case PowerDeviceD1: case PowerDeviceD2: case PowerDeviceD3: // デバイスを無効にする DisableDevice( DeviceExtension ); // IRP_MJ_POWER 要求を下位ドライバに送る Status = SendPowerRequest( DeviceObject, Irp ); break; default: // IRP_MJ_POWER 要求を下位ドライバに送る Status = SendPowerRequest( DeviceObject, Irp ); break; } } else { // IRP_MJ_POWER 要求を下位ドライバに送る Status = SendPowerRequest( DeviceObject, Irp ); } #endif return( Status ); }
void EventListenerManager::AddEventListenerInternal( const EventListenerHolder& aListenerHolder, uint32_t aType, nsIAtom* aTypeAtom, const nsAString& aTypeString, const EventListenerFlags& aFlags, bool aHandler, bool aAllEvents) { MOZ_ASSERT((NS_IsMainThread() && aType && aTypeAtom) || // Main thread (!NS_IsMainThread() && aType && !aTypeString.IsEmpty()) || // non-main-thread aAllEvents, "Missing type"); // all-events listener if (!aListenerHolder || mClearingListeners) { return; } // Since there is no public API to call us with an EventListenerHolder, we // know that there's an EventListenerHolder on the stack holding a strong ref // to the listener. Listener* listener; uint32_t count = mListeners.Length(); for (uint32_t i = 0; i < count; i++) { listener = &mListeners.ElementAt(i); // mListener == aListenerHolder is the last one, since it can be a bit slow. if (listener->mListenerIsHandler == aHandler && listener->mFlags == aFlags && EVENT_TYPE_EQUALS(listener, aType, aTypeAtom, aTypeString, aAllEvents) && listener->mListener == aListenerHolder) { return; } } mNoListenerForEvent = NS_EVENT_NULL; mNoListenerForEventAtom = nullptr; listener = aAllEvents ? mListeners.InsertElementAt(0) : mListeners.AppendElement(); listener->mListener = aListenerHolder; MOZ_ASSERT(aType < PR_UINT16_MAX); listener->mEventType = aType; listener->mTypeString = aTypeString; listener->mTypeAtom = aTypeAtom; listener->mFlags = aFlags; listener->mListenerIsHandler = aHandler; listener->mHandlerIsString = false; listener->mAllEvents = aAllEvents; // Detect the type of event listener. nsCOMPtr<nsIXPConnectWrappedJS> wjs; if (aFlags.mListenerIsJSListener) { MOZ_ASSERT(!aListenerHolder.HasWebIDLCallback()); listener->mListenerType = Listener::eJSEventListener; } else if (aListenerHolder.HasWebIDLCallback()) { listener->mListenerType = Listener::eWebIDLListener; } else if ((wjs = do_QueryInterface(aListenerHolder.GetXPCOMCallback()))) { listener->mListenerType = Listener::eWrappedJSListener; } else { listener->mListenerType = Listener::eNativeListener; } if (aFlags.mInSystemGroup) { mMayHaveSystemGroupListeners = true; } if (aFlags.mCapture) { mMayHaveCapturingListeners = true; } if (aType == NS_AFTERPAINT) { mMayHavePaintEventListener = true; nsPIDOMWindow* window = GetInnerWindowForTarget(); if (window) { window->SetHasPaintEventListeners(); } } else if (aType == NS_MOZAUDIOAVAILABLE) { mMayHaveAudioAvailableEventListener = true; nsPIDOMWindow* window = GetInnerWindowForTarget(); if (window) { window->SetHasAudioAvailableEventListeners(); } } else if (aType >= NS_MUTATION_START && aType <= NS_MUTATION_END) { // For mutation listeners, we need to update the global bit on the DOM window. // Otherwise we won't actually fire the mutation event. mMayHaveMutationListeners = true; // Go from our target to the nearest enclosing DOM window. nsPIDOMWindow* window = GetInnerWindowForTarget(); if (window) { nsCOMPtr<nsIDocument> doc = window->GetExtantDoc(); if (doc) { doc->WarnOnceAbout(nsIDocument::eMutationEvent); } // If aType is NS_MUTATION_SUBTREEMODIFIED, we need to listen all // mutations. nsContentUtils::HasMutationListeners relies on this. window->SetMutationListeners((aType == NS_MUTATION_SUBTREEMODIFIED) ? kAllMutationBits : MutationBitForEventType(aType)); } } else if (aTypeAtom == nsGkAtoms::ondeviceorientation) { EnableDevice(NS_DEVICE_ORIENTATION); } else if (aTypeAtom == nsGkAtoms::ondeviceproximity || aTypeAtom == nsGkAtoms::onuserproximity) { EnableDevice(NS_DEVICE_PROXIMITY); } else if (aTypeAtom == nsGkAtoms::ondevicelight) { EnableDevice(NS_DEVICE_LIGHT); } else if (aTypeAtom == nsGkAtoms::ondevicemotion) { EnableDevice(NS_DEVICE_MOTION); #ifdef MOZ_B2G } else if (aTypeAtom == nsGkAtoms::onmoztimechange) { nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow(); if (window) { window->EnableTimeChangeNotifications(); } } else if (aTypeAtom == nsGkAtoms::onmoznetworkupload) { nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow(); if (window) { window->EnableNetworkEvent(NS_NETWORK_UPLOAD_EVENT); } } else if (aTypeAtom == nsGkAtoms::onmoznetworkdownload) { nsCOMPtr<nsPIDOMWindow> window = GetTargetAsInnerWindow(); if (window) { window->EnableNetworkEvent(NS_NETWORK_DOWNLOAD_EVENT); } #endif // MOZ_B2G } else if (aTypeAtom == nsGkAtoms::ontouchstart || aTypeAtom == nsGkAtoms::ontouchend || aTypeAtom == nsGkAtoms::ontouchmove || aTypeAtom == nsGkAtoms::ontouchenter || aTypeAtom == nsGkAtoms::ontouchleave || aTypeAtom == nsGkAtoms::ontouchcancel) { mMayHaveTouchEventListener = true; nsPIDOMWindow* window = GetInnerWindowForTarget(); // we don't want touchevent listeners added by scrollbars to flip this flag // so we ignore listeners created with system event flag if (window && !aFlags.mInSystemGroup) { window->SetHasTouchEventListeners(); } } else if (aType >= NS_POINTER_EVENT_START && aType <= NS_POINTER_LOST_CAPTURE) { nsPIDOMWindow* window = GetInnerWindowForTarget(); if (aTypeAtom == nsGkAtoms::onpointerenter || aTypeAtom == nsGkAtoms::onpointerleave) { mMayHavePointerEnterLeaveEventListener = true; if (window) { #ifdef DEBUG nsCOMPtr<nsIDocument> d = window->GetExtantDoc(); NS_WARN_IF_FALSE(!nsContentUtils::IsChromeDoc(d), "Please do not use pointerenter/leave events in chrome. " "They are slower than pointerover/out!"); #endif window->SetHasPointerEnterLeaveEventListeners(); } } } else if (aTypeAtom == nsGkAtoms::onmouseenter || aTypeAtom == nsGkAtoms::onmouseleave) { mMayHaveMouseEnterLeaveEventListener = true; nsPIDOMWindow* window = GetInnerWindowForTarget(); if (window) { #ifdef DEBUG nsCOMPtr<nsIDocument> d = window->GetExtantDoc(); NS_WARN_IF_FALSE(!nsContentUtils::IsChromeDoc(d), "Please do not use mouseenter/leave events in chrome. " "They are slower than mouseover/out!"); #endif window->SetHasMouseEnterLeaveEventListeners(); } #ifdef MOZ_GAMEPAD } else if (aType >= NS_GAMEPAD_START && aType <= NS_GAMEPAD_END) { nsPIDOMWindow* window = GetInnerWindowForTarget(); if (window) { window->SetHasGamepadEventListener(); } #endif } if (aTypeAtom && mTarget) { mTarget->EventListenerAdded(aTypeAtom); } }
int ProcXChangeDeviceControl(ClientPtr client) { unsigned len; int i, status, ret = BadValue; DeviceIntPtr dev; xDeviceResolutionCtl *r; xChangeDeviceControlReply rep; AxisInfoPtr a; CARD32 *resolution; xDeviceEnableCtl *e; REQUEST(xChangeDeviceControlReq); REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq); len = stuff->length - bytes_to_int32(sizeof(xChangeDeviceControlReq)); ret = dixLookupDevice(&dev, stuff->deviceid, client, DixManageAccess); if (ret != Success) goto out; rep = (xChangeDeviceControlReply) { .repType = X_Reply, .RepType = X_ChangeDeviceControl, .sequenceNumber = client->sequence, .length = 0 }; switch (stuff->control) { case DEVICE_RESOLUTION: r = (xDeviceResolutionCtl *) &stuff[1]; if ((len < bytes_to_int32(sizeof(xDeviceResolutionCtl))) || (len != bytes_to_int32(sizeof(xDeviceResolutionCtl)) + r->num_valuators)) { ret = BadLength; goto out; } if (!dev->valuator) { ret = BadMatch; goto out; } if ((dev->deviceGrab.grab) && !SameClient(dev->deviceGrab.grab, client)) { rep.status = AlreadyGrabbed; ret = Success; goto out; } resolution = (CARD32 *) (r + 1); if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) { ret = BadValue; goto out; } status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r); if (status == Success) { a = &dev->valuator->axes[r->first_valuator]; for (i = 0; i < r->num_valuators; i++) if (*(resolution + i) < (a + i)->min_resolution || *(resolution + i) > (a + i)->max_resolution) return BadValue; for (i = 0; i < r->num_valuators; i++) (a++)->resolution = *resolution++; ret = Success; } else if (status == DeviceBusy) { rep.status = DeviceBusy; ret = Success; } else { ret = BadMatch; } break; case DEVICE_ABS_CALIB: case DEVICE_ABS_AREA: /* Calibration is now done through properties, and never had any effect * on anything (in the open-source world). Thus, be honest. */ ret = BadMatch; break; case DEVICE_CORE: /* Sorry, no device core switching no more. If you want a device to * send core events, attach it to a master device */ ret = BadMatch; break; case DEVICE_ENABLE: e = (xDeviceEnableCtl *) &stuff[1]; status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e); if (status == Success) { if (e->enable) EnableDevice(dev, TRUE); else DisableDevice(dev, TRUE); ret = Success; } else if (status == DeviceBusy) { rep.status = DeviceBusy; ret = Success; } else { ret = BadMatch; } break; default: ret = BadValue; } out: if (ret == Success) { devicePresenceNotify dpn = { .type = DevicePresenceNotify, .time = currentTime.milliseconds, .devchange = DeviceControlChanged, .deviceid = dev->id, .control = stuff->control }; SendEventToAllWindows(dev, DevicePresenceNotifyMask, (xEvent *) &dpn, 1); WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep); } return ret; } /*********************************************************************** * * This procedure writes the reply for the xChangeDeviceControl function, * if the client and server have a different byte ordering. * */ void SRepXChangeDeviceControl(ClientPtr client, int size, xChangeDeviceControlReply * rep) { swaps(&rep->sequenceNumber); swapl(&rep->length); WriteToClient(client, size, rep); }
/// \brief Lock or unlock the motor based on the input boolean parameter (defaults to lock) /// \details Use the kill command ("DI") followed by the enable command ("EN") to lock the motor /// \pre MCDC is still connected on the given COM port /// \post Motor is locked in its current position or unlocked depending on value of boolean "lock" void MotionController::LockMotor(bool lock/*=true*/) { if(!lock) DisableDevice(); else EnableDevice(); }