bool CNetworkServices::StopEventServer(bool bWait, bool promptuser) { #ifdef HAS_EVENT_SERVER if (!IsEventServerRunning()) return true; CEventServer* server = CEventServer::GetInstance(); if (!server) { CLog::Log(LOGERROR, "ES: Out of memory"); return false; } if (promptuser) { if (server->GetNumberOfClients() > 0) { bool cancelled = false; if (!CGUIDialogYesNo::ShowAndGetInput(13140, 13141, 13142, 20022, -1, -1, cancelled, 10000) || cancelled) { CLog::Log(LOGNOTICE, "ES: Not stopping event server"); return false; } } CLog::Log(LOGNOTICE, "ES: Stopping event server with confirmation"); CEventServer::GetInstance()->StopServer(true); } else { if (!bWait) CLog::Log(LOGNOTICE, "ES: Stopping event server"); CEventServer::GetInstance()->StopServer(bWait); } return true; #endif // HAS_EVENT_SERVER return false; }
bool CNetworkServices::StopEventServer(bool bWait, bool promptuser) { #ifdef HAS_EVENT_SERVER if (!IsEventServerRunning()) return true; CEventServer* server = CEventServer::GetInstance(); if (!server) { CLog::Log(LOGERROR, "ES: Out of memory"); return false; } if (promptuser) { if (server->GetNumberOfClients() > 0) { if (HELPERS::ShowYesNoDialogText(CVariant{13140}, CVariant{13141}, CVariant{""}, CVariant{""}, 10000) != DialogResponse::YES) { CLog::Log(LOGNOTICE, "ES: Not stopping event server"); return false; } } CLog::Log(LOGNOTICE, "ES: Stopping event server with confirmation"); CEventServer::GetInstance()->StopServer(true); } else { if (!bWait) CLog::Log(LOGNOTICE, "ES: Stopping event server"); CEventServer::GetInstance()->StopServer(bWait); } return true; #endif // HAS_EVENT_SERVER return false; }
bool CInputManager::ProcessEventServer(int windowId, float frameTime) { #ifdef HAS_EVENT_SERVER CEventServer* es = CEventServer::GetInstance(); if (!es || !es->Running() || es->GetNumberOfClients() == 0) return false; // process any queued up actions if (es->ExecuteNextAction()) { // reset idle timers g_application.ResetSystemIdleTimer(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); } // now handle any buttons or axis std::string strMapName; bool isAxis = false; float fAmount = 0.0; bool isJoystick = false; // es->ExecuteNextAction() invalidates the ref to the CEventServer instance // when the action exits XBMC es = CEventServer::GetInstance(); if (!es || !es->Running() || es->GetNumberOfClients() == 0) return false; unsigned int wKeyID = es->GetButtonCode(strMapName, isAxis, fAmount, isJoystick); if (wKeyID) { if (strMapName.length() > 0) { // joysticks are not supported via eventserver if (isJoystick) { return false; } else // it is a customcontroller { int actionID; std::string actionName; // Translate using custom controller translator. if (m_customControllerTranslator->TranslateCustomControllerString(windowId, strMapName, wKeyID, actionID, actionName)) { // break screensaver g_application.ResetSystemIdleTimer(); g_application.ResetScreenSaver(); // in case we wokeup the screensaver or screen - eat that action... if (g_application.WakeUpScreenSaverAndDPMS()) return true; m_Mouse.SetActive(false); return ExecuteInputAction(CAction(actionID, fAmount, 0.0f, actionName)); } else { CLog::Log(LOGDEBUG, "ERROR mapping customcontroller action. CustomController: %s %i", strMapName.c_str(), wKeyID); } } } else { CKey key; if (wKeyID & ES_FLAG_UNICODE) { key = CKey((uint8_t)0, wKeyID & ~ES_FLAG_UNICODE, 0, 0, 0); return OnKey(key); } if (wKeyID == KEY_BUTTON_LEFT_ANALOG_TRIGGER) key = CKey(wKeyID, (BYTE)(255 * fAmount), 0, 0.0, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_ANALOG_TRIGGER) key = CKey(wKeyID, 0, (BYTE)(255 * fAmount), 0.0, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_LEFT) key = CKey(wKeyID, 0, 0, -fAmount, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_RIGHT) key = CKey(wKeyID, 0, 0, fAmount, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_UP) key = CKey(wKeyID, 0, 0, 0.0, fAmount, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_DOWN) key = CKey(wKeyID, 0, 0, 0.0, -fAmount, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_LEFT) key = CKey(wKeyID, 0, 0, 0.0, 0.0, -fAmount, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT) key = CKey(wKeyID, 0, 0, 0.0, 0.0, fAmount, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_UP) key = CKey(wKeyID, 0, 0, 0.0, 0.0, 0.0, fAmount, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_DOWN) key = CKey(wKeyID, 0, 0, 0.0, 0.0, 0.0, -fAmount, frameTime); else key = CKey(wKeyID); key.SetFromService(true); return OnKey(key); } } { CPoint pos; if (es->GetMousePos(pos.x, pos.y) && m_Mouse.IsEnabled()) { XBMC_Event newEvent; newEvent.type = XBMC_MOUSEMOTION; newEvent.motion.x = (uint16_t)pos.x; newEvent.motion.y = (uint16_t)pos.y; g_application.OnEvent(newEvent); // had to call this to update g_Mouse position return g_application.OnAction(CAction(ACTION_MOUSE_MOVE, pos.x, pos.y)); } } #endif return false; }
bool CInputManager::ProcessEventServer(int windowId, float frameTime) { #ifdef HAS_EVENT_SERVER CEventServer* es = CEventServer::GetInstance(); if (!es || !es->Running() || es->GetNumberOfClients() == 0) return false; // process any queued up actions if (es->ExecuteNextAction()) { // reset idle timers g_application.ResetSystemIdleTimer(); g_application.ResetScreenSaver(); g_application.WakeUpScreenSaverAndDPMS(); } // now handle any buttons or axis std::string joystickName; bool isAxis = false; float fAmount = 0.0; // es->ExecuteNextAction() invalidates the ref to the CEventServer instance // when the action exits XBMC es = CEventServer::GetInstance(); if (!es || !es->Running() || es->GetNumberOfClients() == 0) return false; unsigned int wKeyID = es->GetButtonCode(joystickName, isAxis, fAmount); if (wKeyID) { if (joystickName.length() > 0) { if (isAxis == true) { if (fabs(fAmount) >= 0.08) m_lastAxisMap[joystickName][wKeyID] = fAmount; else m_lastAxisMap[joystickName].erase(wKeyID); } return ProcessJoystickEvent(windowId, joystickName, wKeyID, isAxis ? JACTIVE_AXIS : JACTIVE_BUTTON, fAmount); } else { CKey key; if (wKeyID & ES_FLAG_UNICODE) { key = CKey((uint8_t)0, wKeyID & ~ES_FLAG_UNICODE, 0, 0, 0); return OnKey(key); } if (wKeyID == KEY_BUTTON_LEFT_ANALOG_TRIGGER) key = CKey(wKeyID, (uint8_t)(255 * fAmount), 0, 0.0, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_ANALOG_TRIGGER) key = CKey(wKeyID, 0, (uint8_t)(255 * fAmount), 0.0, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_LEFT) key = CKey(wKeyID, 0, 0, -fAmount, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_RIGHT) key = CKey(wKeyID, 0, 0, fAmount, 0.0, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_UP) key = CKey(wKeyID, 0, 0, 0.0, fAmount, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_LEFT_THUMB_STICK_DOWN) key = CKey(wKeyID, 0, 0, 0.0, -fAmount, 0.0, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_LEFT) key = CKey(wKeyID, 0, 0, 0.0, 0.0, -fAmount, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT) key = CKey(wKeyID, 0, 0, 0.0, 0.0, fAmount, 0.0, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_UP) key = CKey(wKeyID, 0, 0, 0.0, 0.0, 0.0, fAmount, frameTime); else if (wKeyID == KEY_BUTTON_RIGHT_THUMB_STICK_DOWN) key = CKey(wKeyID, 0, 0, 0.0, 0.0, 0.0, -fAmount, frameTime); else key = CKey(wKeyID); key.SetFromService(true); return OnKey(key); } } if (!m_lastAxisMap.empty()) { // Process all the stored axis. for (std::map<std::string, std::map<int, float> >::iterator iter = m_lastAxisMap.begin(); iter != m_lastAxisMap.end(); ++iter) { for (std::map<int, float>::iterator iterAxis = (*iter).second.begin(); iterAxis != (*iter).second.end(); ++iterAxis) ProcessJoystickEvent(windowId, (*iter).first, (*iterAxis).first, JACTIVE_AXIS, (*iterAxis).second); } } { CPoint pos; if (es->GetMousePos(pos.x, pos.y) && m_Mouse.IsEnabled()) { XBMC_Event newEvent; newEvent.type = XBMC_MOUSEMOTION; newEvent.motion.xrel = 0; newEvent.motion.yrel = 0; newEvent.motion.state = 0; newEvent.motion.which = 0x10; // just a different value to distinguish between mouse and event client device. newEvent.motion.x = (uint16_t)pos.x; newEvent.motion.y = (uint16_t)pos.y; g_application.OnEvent(newEvent); // had to call this to update g_Mouse position return g_application.OnAction(CAction(ACTION_MOUSE_MOVE, pos.x, pos.y)); } } #endif return false; }