本文整理汇总了C++中CEventServer::GetButtonCode方法的典型用法代码示例。如果您正苦于以下问题:C++ CEventServer::GetButtonCode方法的具体用法?C++ CEventServer::GetButtonCode怎么用?C++ CEventServer::GetButtonCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEventServer
的用法示例。
在下文中一共展示了CEventServer::GetButtonCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessEventServer
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);
}
}
//.........这里部分代码省略.........
示例2: ProcessEventServer
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;
//.........这里部分代码省略.........