本文整理汇总了C++中CKey::GetButtonCode方法的典型用法代码示例。如果您正苦于以下问题:C++ CKey::GetButtonCode方法的具体用法?C++ CKey::GetButtonCode怎么用?C++ CKey::GetButtonCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKey
的用法示例。
在下文中一共展示了CKey::GetButtonCode方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetActionCode
int CButtonTranslator::GetActionCode(int window, const CKey &key, CStdString &strAction) const
{
uint32_t code = key.GetButtonCode();
const std::map<int, buttonMap> &deviceMap = GetDeviceMap();
map<int, buttonMap>::const_iterator it = deviceMap.find(window);
if (it == deviceMap.end())
return 0;
buttonMap::const_iterator it2 = (*it).second.find(code);
int action = 0;
while (it2 != (*it).second.end())
{
action = (*it2).second.id;
strAction = (*it2).second.strID;
it2 = (*it).second.end();
}
#ifdef _LINUX
// Some buttoncodes changed in Hardy
if (action == 0 && (code & KEY_VKEY) == KEY_VKEY && (code & 0x0F00))
{
CLog::Log(LOGDEBUG, "%s: Trying Hardy keycode for %#04x", __FUNCTION__, code);
code &= ~0x0F00;
buttonMap::const_iterator it2 = (*it).second.find(code);
while (it2 != (*it).second.end())
{
action = (*it2).second.id;
strAction = (*it2).second.strID;
it2 = (*it).second.end();
}
}
#endif
return action;
}
示例2: OnKeyPress
bool CGameClientKeyboard::OnKeyPress(const CKey& key)
{
// Only allow activated input in fullscreen game
if (!m_gameClient->AcceptsInput())
{
CLog::Log(LOGDEBUG, "GAME: key press ignored, not in fullscreen game");
return false;
}
bool bHandled = false;
game_input_event event;
event.type = GAME_INPUT_EVENT_KEY;
event.port = GAME_INPUT_PORT_KEYBOARD;
event.controller_id = ""; //! @todo
event.feature_name = ""; //! @todo
event.key.pressed = true;
event.key.character = static_cast<XBMCVKey>(key.GetButtonCode() & BUTTON_INDEX_MASK);
event.key.modifiers = CGameClientTranslator::GetModifiers(static_cast<CKey::Modifier>(key.GetModifiers()));
if (event.key.character != 0)
{
try
{
bHandled = m_dllStruct->InputEvent(&event);
}
catch (...)
{
CLog::Log(LOGERROR, "GAME: %s: exception caught in InputEvent()", m_gameClient->ID().c_str());
}
}
return bHandled;
}
示例3: GetActionCode
WORD CButtonTranslator::GetActionCode(WORD wWindow, const CKey &key, CStdString &strAction)
{
WORD wKey = (WORD)key.GetButtonCode();
map<WORD, buttonMap>::iterator it = translatorMap.find(wWindow);
if (it == translatorMap.end())
return 0;
buttonMap::iterator it2 = (*it).second.find(wKey);
WORD wAction = 0;
while (it2 != (*it).second.end())
{
wAction = (*it2).second.wID;
strAction = (*it2).second.strID;
it2 = (*it).second.end();
}
#ifdef _LINUX
// Some buttoncodes changed in Hardy
if (wAction == 0 && (wKey & KEY_VKEY) == KEY_VKEY && (wKey & (DWORD)0x0F00)) {
CLog::Log(LOGDEBUG, "%s: Trying Hardy keycode for %#04x", __FUNCTION__, wKey);
wKey &= ~(DWORD)0x0F00;
buttonMap::iterator it2 = (*it).second.find(wKey);
while (it2 != (*it).second.end())
{
wAction = (*it2).second.wID;
strAction = (*it2).second.strID;
it2 = (*it).second.end();
}
}
#endif
return wAction;
}
示例4: GetActionCode
WORD CButtonTranslator::GetActionCode(WORD wWindow, const CKey &key, CStdString &strAction)
{
WORD wKey = (WORD)key.GetButtonCode();
map<WORD, buttonMap>::iterator it = translatorMap.find(wWindow);
if (it == translatorMap.end())
return 0;
buttonMap::iterator it2 = (*it).second.find(wKey);
WORD wAction = 0;
while (it2 != (*it).second.end())
{
wAction = (*it2).second.wID;
strAction = (*it2).second.strID;
it2 = (*it).second.end();
}
return wAction;
}
示例5: GetActionCode
unsigned int CButtonTranslator::GetActionCode(int window, const CKey &key, std::string &strAction) const
{
uint32_t code = key.GetButtonCode();
std::map<int, buttonMap>::const_iterator it = m_translatorMap.find(window);
if (it == m_translatorMap.end())
return ACTION_NONE;
buttonMap::const_iterator it2 = (*it).second.find(code);
unsigned int action = ACTION_NONE;
if (it2 == (*it).second.end() && code & CKey::MODIFIER_LONG) // If long action not found, try short one
{
code &= ~CKey::MODIFIER_LONG;
it2 = (*it).second.find(code);
}
if (it2 != (*it).second.end())
{
action = (*it2).second.id;
strAction = (*it2).second.strID;
}
#ifdef TARGET_POSIX
// Some buttoncodes changed in Hardy
if (action == ACTION_NONE && (code & KEY_VKEY) == KEY_VKEY && (code & 0x0F00))
{
CLog::Log(LOGDEBUG, "%s: Trying Hardy keycode for %#04x", __FUNCTION__, code);
code &= ~0x0F00;
it2 = (*it).second.find(code);
if (it2 != (*it).second.end())
{
action = (*it2).second.id;
strAction = (*it2).second.strID;
}
}
#endif
return action;
}
示例6: HasLongpressMapping
bool CButtonTranslator::HasLongpressMapping(int window, const CKey &key)
{
std::map<int, buttonMap>::const_iterator it = m_translatorMap.find(window);
if (it != m_translatorMap.end())
{
uint32_t code = key.GetButtonCode();
code |= CKey::MODIFIER_LONG;
buttonMap::const_iterator it2 = (*it).second.find(code);
if (it2 != (*it).second.end())
return it2->second.id != ACTION_NOOP;
#ifdef TARGET_POSIX
// Some buttoncodes changed in Hardy
if ((code & KEY_VKEY) == KEY_VKEY && (code & 0x0F00))
{
code &= ~0x0F00;
it2 = (*it).second.find(code);
if (it2 != (*it).second.end())
return true;
}
#endif
}
// no key mapping found for the current window do the fallback handling
if (window > -1)
{
// first check if we have a fallback for the window
int fallbackWindow = CWindowTranslator::GetFallbackWindow(window);
if (fallbackWindow > -1 && HasLongpressMapping(fallbackWindow, key))
return true;
// fallback to default section
return HasLongpressMapping(-1, key);
}
return false;
}
示例7: OnKeyRelease
void CGameClientKeyboard::OnKeyRelease(const CKey& key)
{
game_input_event event;
event.type = GAME_INPUT_EVENT_KEY;
event.port = GAME_INPUT_PORT_KEYBOARD;
event.controller_id = ""; //! @todo
event.feature_name = ""; //! @todo
event.key.pressed = false;
event.key.character = static_cast<XBMCVKey>(key.GetButtonCode() & BUTTON_INDEX_MASK);
event.key.modifiers = CGameClientTranslator::GetModifiers(static_cast<CKey::Modifier>(key.GetModifiers()));
if (event.key.character != 0)
{
try
{
m_dllStruct->InputEvent(&event);
}
catch (...)
{
CLog::Log(LOGERROR, "GAME: %s: exception caught in InputEvent()", m_gameClient->ID().c_str());
}
}
}
示例8: GetAction
void CButtonTranslator::GetAction(WORD wWindow, const CKey &key, CAction &action)
{
CStdString strAction;
// try to get the action from the current window
WORD wAction = GetActionCode(wWindow, key, strAction);
// if it's invalid, try to get it from the global map
if (wAction == 0)
wAction = GetActionCode( (WORD) -1, key, strAction);
// Now fill our action structure
action.wID = wAction;
action.strAction = strAction;
action.fAmount1 = 1; // digital button (could change this for repeat acceleration)
action.fAmount2 = 0;
action.fRepeat = key.GetRepeat();
action.m_dwButtonCode = key.GetButtonCode();
// get the action amounts of the analog buttons
if (key.GetButtonCode() == KEY_BUTTON_LEFT_ANALOG_TRIGGER)
{
action.fAmount1 = (float)key.GetLeftTrigger() / 255.0f;
}
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_ANALOG_TRIGGER)
{
action.fAmount1 = (float)key.GetRightTrigger() / 255.0f;
}
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK)
{
action.fAmount1 = key.GetLeftThumbX();
action.fAmount2 = key.GetLeftThumbY();
}
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK)
{
action.fAmount1 = key.GetRightThumbX();
action.fAmount2 = key.GetRightThumbY();
}
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_UP)
action.fAmount1 = key.GetLeftThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_DOWN)
action.fAmount1 = -key.GetLeftThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_LEFT)
action.fAmount1 = -key.GetLeftThumbX();
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_RIGHT)
action.fAmount1 = key.GetLeftThumbX();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_UP)
action.fAmount1 = key.GetRightThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_DOWN)
action.fAmount1 = -key.GetRightThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_LEFT)
action.fAmount1 = -key.GetRightThumbX();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT)
action.fAmount1 = key.GetRightThumbX();
}
示例9: if
CAction::CAction(int actionID, const CStdString &name, const CKey &key)
{
m_id = actionID;
m_name = name;
m_amount[0] = 1; // digital button (could change this for repeat acceleration)
for (unsigned int i = 1; i < max_amounts; i++)
m_amount[i] = 0;
m_repeat = key.GetRepeat();
m_buttonCode = key.GetButtonCode();
m_unicode = 0;
m_holdTime = key.GetHeld();
// get the action amounts of the analog buttons
if (key.GetButtonCode() == KEY_BUTTON_LEFT_ANALOG_TRIGGER)
m_amount[0] = (float)key.GetLeftTrigger() / 255.0f;
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_ANALOG_TRIGGER)
m_amount[0] = (float)key.GetRightTrigger() / 255.0f;
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK)
{
m_amount[0] = key.GetLeftThumbX();
m_amount[1] = key.GetLeftThumbY();
}
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK)
{
m_amount[0] = key.GetRightThumbX();
m_amount[1] = key.GetRightThumbY();
}
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_UP)
m_amount[0] = key.GetLeftThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_DOWN)
m_amount[0] = -key.GetLeftThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_LEFT)
m_amount[0] = -key.GetLeftThumbX();
else if (key.GetButtonCode() == KEY_BUTTON_LEFT_THUMB_STICK_RIGHT)
m_amount[0] = key.GetLeftThumbX();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_UP)
m_amount[0] = key.GetRightThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_DOWN)
m_amount[0] = -key.GetRightThumbY();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_LEFT)
m_amount[0] = -key.GetRightThumbX();
else if (key.GetButtonCode() == KEY_BUTTON_RIGHT_THUMB_STICK_RIGHT)
m_amount[0] = key.GetRightThumbX();
}
示例10: OnKey
bool CInputManager::OnKey(const CKey& key)
{
for (std::vector<KEYBOARD::IKeyboardHandler*>::iterator it = m_keyboardHandlers.begin(); it != m_keyboardHandlers.end(); ++it)
{
if ((*it)->OnKeyPress(key))
return true;
}
// Turn the mouse off, as we've just got a keypress from controller or remote
m_Mouse.SetActive(false);
// get the current active window
int iWin = g_windowManager.GetActiveWindowID();
// this will be checked for certain keycodes that need
// special handling if the screensaver is active
CAction action = m_buttonTranslator->GetAction(iWin, key);
// a key has been pressed.
// reset Idle Timer
g_application.ResetSystemIdleTimer();
bool processKey = AlwaysProcess(action);
if (StringUtils::StartsWithNoCase(action.GetName(), "CECToggleState") || StringUtils::StartsWithNoCase(action.GetName(), "CECStandby"))
{
// do not wake up the screensaver right after switching off the playing device
if (StringUtils::StartsWithNoCase(action.GetName(), "CECToggleState"))
{
CLog::LogF(LOGDEBUG, "action %s [%d], toggling state of playing device", action.GetName().c_str(), action.GetID());
bool result;
CApplicationMessenger::GetInstance().SendMsg(TMSG_CECTOGGLESTATE, 0, 0, static_cast<void*>(&result));
if (!result)
return true;
}
else
{
CApplicationMessenger::GetInstance().PostMsg(TMSG_CECSTANDBY);
return true;
}
}
g_application.ResetScreenSaver();
// allow some keys to be processed while the screensaver is active
if (g_application.WakeUpScreenSaverAndDPMS(processKey) && !processKey)
{
CLog::LogF(LOGDEBUG, "%s pressed, screen saver/dpms woken up", m_Keyboard.GetKeyName((int)key.GetButtonCode()).c_str());
return true;
}
if (iWin != WINDOW_FULLSCREEN_VIDEO)
{
// current active window isnt the fullscreen window
// just use corresponding section from keymap.xml
// to map key->action
// first determine if we should use keyboard input directly
bool useKeyboard = key.FromKeyboard() && (iWin == WINDOW_DIALOG_KEYBOARD || iWin == WINDOW_DIALOG_NUMERIC);
CGUIWindow *window = g_windowManager.GetWindow(iWin);
if (window)
{
CGUIControl *control = window->GetFocusedControl();
if (control)
{
// If this is an edit control set usekeyboard to true. This causes the
// keypress to be processed directly not through the key mappings.
if (control->GetControlType() == CGUIControl::GUICONTROL_EDIT)
useKeyboard = true;
// If the key pressed is shift-A to shift-Z set usekeyboard to true.
// This causes the keypress to be used for list navigation.
if (control->IsContainer() && key.GetModifiers() == CKey::MODIFIER_SHIFT && key.GetVKey() >= XBMCVK_A && key.GetVKey() <= XBMCVK_Z)
useKeyboard = true;
}
}
if (useKeyboard)
{
// use the virtualkeyboard section of the keymap, and send keyboard-specific or navigation
// actions through if that's what they are
CAction action = m_buttonTranslator->GetAction(WINDOW_DIALOG_KEYBOARD, key);
if (!(action.GetID() == ACTION_MOVE_LEFT ||
action.GetID() == ACTION_MOVE_RIGHT ||
action.GetID() == ACTION_MOVE_UP ||
action.GetID() == ACTION_MOVE_DOWN ||
action.GetID() == ACTION_SELECT_ITEM ||
action.GetID() == ACTION_ENTER ||
action.GetID() == ACTION_PREVIOUS_MENU ||
action.GetID() == ACTION_NAV_BACK ||
action.GetID() == ACTION_VOICE_RECOGNIZE))
{
// the action isn't plain navigation - check for a keyboard-specific keymap
action = m_buttonTranslator->GetAction(WINDOW_DIALOG_KEYBOARD, key, false);
if (!(action.GetID() >= REMOTE_0 && action.GetID() <= REMOTE_9) ||
action.GetID() == ACTION_BACKSPACE ||
action.GetID() == ACTION_SHIFT ||
action.GetID() == ACTION_SYMBOLS ||
action.GetID() == ACTION_CURSOR_LEFT ||
action.GetID() == ACTION_CURSOR_RIGHT)
action = CAction(0); // don't bother with this action
}
//.........这里部分代码省略.........
示例11: OnEvent
bool CInputManager::OnEvent(XBMC_Event& newEvent)
{
switch (newEvent.type)
{
case XBMC_KEYDOWN:
{
m_Keyboard.ProcessKeyDown(newEvent.key.keysym);
CKey key = m_Keyboard.TranslateKey(newEvent.key.keysym);
if (key.GetButtonCode() == m_LastKey.GetButtonCode() && (m_LastKey.GetButtonCode() & CKey::MODIFIER_LONG))
{
// Do not repeat long presses
break;
}
if (!m_buttonTranslator->HasLongpressMapping(g_windowManager.GetActiveWindowID(), key))
{
m_LastKey.Reset();
OnKey(key);
}
else
{
if (key.GetButtonCode() != m_LastKey.GetButtonCode() && (key.GetButtonCode() & CKey::MODIFIER_LONG))
{
m_LastKey = key; // OnKey is reentrant; need to do this before entering
OnKey(key);
}
m_LastKey = key;
}
break;
}
case XBMC_KEYUP:
m_Keyboard.ProcessKeyUp();
if (m_LastKey.GetButtonCode() != KEY_INVALID && !(m_LastKey.GetButtonCode() & CKey::MODIFIER_LONG))
{
CKey key = m_LastKey;
m_LastKey.Reset(); // OnKey is reentrant; need to do this before entering
OnKey(key);
}
else
m_LastKey.Reset();
OnKeyUp(m_Keyboard.TranslateKey(newEvent.key.keysym));
break;
case XBMC_MOUSEBUTTONDOWN:
case XBMC_MOUSEBUTTONUP:
case XBMC_MOUSEMOTION:
{
bool handled = false;
for (auto it = m_mouseHandlers.begin(); it != m_mouseHandlers.end(); ++it)
{
if (newEvent.type == XBMC_MOUSEMOTION)
{
if (it->driverHandler->OnPosition(newEvent.motion.x, newEvent.motion.y))
handled = true;
}
else
{
if (newEvent.type == XBMC_MOUSEBUTTONDOWN)
{
if (it->driverHandler->OnButtonPress(newEvent.button.button))
handled = true;
}
else if (newEvent.type == XBMC_MOUSEBUTTONUP)
{
it->driverHandler->OnButtonRelease(newEvent.button.button);
}
}
if (handled)
break;
}
if (!handled)
{
m_Mouse.HandleEvent(newEvent);
ProcessMouse(g_windowManager.GetActiveWindowID());
}
break;
}
case XBMC_TOUCH:
{
if (newEvent.touch.action == ACTION_TOUCH_TAP)
{ // Send a mouse motion event with no dx,dy for getting the current guiitem selected
g_application.OnAction(CAction(ACTION_MOUSE_MOVE, 0, newEvent.touch.x, newEvent.touch.y, 0, 0));
}
int actionId = 0;
std::string actionString;
if (newEvent.touch.action == ACTION_GESTURE_BEGIN || newEvent.touch.action == ACTION_GESTURE_END || newEvent.touch.action == ACTION_GESTURE_ABORT)
actionId = newEvent.touch.action;
else
{
int iWin = g_windowManager.GetActiveWindowID();
m_touchTranslator->TranslateTouchAction(iWin, newEvent.touch.action, newEvent.touch.pointers, actionId, actionString);
}
if (actionId <= 0)
return false;
if ((actionId >= ACTION_TOUCH_TAP && actionId <= ACTION_GESTURE_END)
|| (actionId >= ACTION_MOUSE_START && actionId <= ACTION_MOUSE_END))
{
//.........这里部分代码省略.........