xbmc从onKey到onAction创建CAction对象的过程
来源:互联网 发布:女生帆布鞋淘宝 编辑:程序博客网 时间:2024/05/19 22:55
注我们以遥控器音量加键为说明例子
//xbmc/Application.cppbool CApplication::OnKey(const CKey& key){... int iWin = GetActiveWindowID(); CAction action = CButtonTranslator::GetInstance().GetAction(iWin, key);... if (!key.IsAnalogButton()) CLog::LogF(LOGDEBUG, "%s pressed, action is %s", g_Keyboard.GetKeyName((int) key.GetButtonCode()).c_str(), action.GetName().c_str()); return ExecuteInputAction(action);}
//xbmc/input/ButtonTranslator.cppCAction CButtonTranslator::GetAction(int window, const CKey &key, bool fallback){ std::string strAction; // try to get the action from the current window int actionID = GetActionCode(window, key, strAction); // if it's invalid, try to get it from the global map if (actionID == 0 && fallback) { int fallbackWindow = GetFallbackWindow(window); if (fallbackWindow > -1) actionID = GetActionCode(fallbackWindow, key, strAction); // still no valid action? use global map if (actionID == 0) actionID = GetActionCode( -1, key, strAction); } CAction action(actionID, strAction, key); return action;}
在此说明以下CAction的其一构造函数//xbmc/guilib/Key.h
CAction(int actionID, const CStdString &name, const CKey &key);
看样子我们要弄清楚actionID的由来
int CButtonTranslator::GetActionCode(int window, const CKey &key, std::string &strAction) const{ uint32_t code = key.GetButtonCode(); map<int, buttonMap>::const_iterator it = m_translatorMap.find(window); ... buttonMap::const_iterator it2 = (*it).second.find(code); int action = 0; if (it2 != (*it).second.end()) { action = (*it2).second.id; strAction = (*it2).second.strID; } return action;}
我们看看获取code的GetButtonCode代码
//xbmc/guilib/Key.h inline uint32_t GetButtonCode() const { return m_buttonCode; }
看来似乎又要回到从OnEvent方法的g_Keyboard.ProcessKeyDown(newEvent.key.keysym)返回的key对象入手了
CKey::CKey(uint8_t vkey, wchar_t unicode, char ascii, uint32_t modifiers, unsigned int held){ Reset(); if (vkey) // FIXME: This needs cleaning up - should we always use the unicode key where available? m_buttonCode = vkey | KEY_VKEY; else m_buttonCode = KEY_UNICODE; m_buttonCode |= modifiers; m_vkey = vkey; m_unicode = unicode; m_ascii = ascii; m_modifiers = modifiers; m_held = held;}
其中
#define KEY_VKEY 0xF000
至此,我们的m_buttonCode出来了,即0xF02b,从keyboard.xml等xml的读取过程中我们知道actionID 0xF02b对应的,
action为plus,strAction为ACTION_VOLUME_UP,至此key转化为action便完成。
actions的数组的内容如下
//xbmc/input/ButtonTranslator.cppstatic const ActionMapping actions[] ={ ... {"volumeup" , ACTION_VOLUME_UP}, //这是action名称和对应的值action.GetID()}
后续到Application.cpp的ExecuteInputAction(action);中处理
0 0
- xbmc从onKey到onAction创建CAction对象的过程
- xbmc从onEvent到onkey创建CKey对象的过程
- 从过程到对象
- 从Java类到对象的创建过程都做了些啥以及内存中的对象是啥样的
- 使用CAction类的事件
- 应用窗口的从创建到显示的过程
- iOS 一个应用程序从创建到销毁的过程
- 线程(从创建到消亡的过程)
- 类从加载到对象实例化的过程顺序
- 从面向过程到面向对象的转变----C++
- 原型链的从对象创建到原理详解
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 儿童节献给孩子的书单
- Python Show-Me-the-Code 第 0020题 统计通话时长
- iOS开发 -"ASI"使用实例
- IOS -- 获取WIFI信息API
- 32.图形上下文
- xbmc从onKey到onAction创建CAction对象的过程
- TeamViewer 四个版本的功能区别(远程连接黑屏问题解答)
- Windows 10 , 在路上 You are already an expert !;
- win8系统 ps不能直接拖入图片的问题!解决方法
- 携程崩溃:原因为何,谁该反思
- Android - 多语言自动适配
- centos 卸载自带的 java
- Linux进程间通信_IPC方法综述
- .htaccess技巧: URL重写(Rewrite)与重定向(Redirect)