xbmc从onEvent到onkey创建CKey对象的过程
来源:互联网 发布:女生帆布鞋淘宝 编辑:程序博客网 时间:2024/06/07 04:04
注我们以遥控器音量加键为说明例子
//xbmc/Application.cppbool CApplication::OnEvent(XBMC_Event& newEvent){ switch(newEvent.type) { case XBMC_QUIT: //退出xbmc ... CApplicationMessenger::Get().Quit(); break; case XBMC_KEYDOWN: g_application.OnKey(g_Keyboard.ProcessKeyDown(newEvent.key.keysym)); break; }}
/*xbmc/input/KeyboardStat.cpp*/const CKey CKeyboardStat::ProcessKeyDown(XBMC_keysym& keysym){ uint8_t vkey; wchar_t unicode; char ascii; uint32_t modifiers; unsigned int held; XBMCKEYTABLE keytable; ... //这里一句输出了:Keyboard: scancode: 0x18, sym: 0x002b, unicode: 0x0000, modifier: 0x0 CLog::Log(LOGDEBUG, "Keyboard: scancode: 0x%02x, sym: 0x%04x, unicode: 0x%04x, modifier: 0x%x", keysym.scancode, keysym.sym, keysym.unicode, keysym.mod); if (LookupSymAndUnicodePeripherals(keysym, &vkey, &ascii)) { CLog::Log(LOGDEBUG, "%s - keypress translated by a HID peripheral", __FUNCTION__); } // Continue by trying to match both the sym and unicode. This will identify else if (KeyTableLookupSymAndUnicode(keysym.sym, keysym.unicode, &keytable)) { vkey = keytable.vkey; ascii = keytable.ascii; } // If we failed to match the sym and unicode try just the unicode. This else if (KeyTableLookupUnicode(keysym.unicode, &keytable)) { vkey = keytable.vkey; ascii = keytable.ascii; } // If there is still no match try the sym我们按音量加进入了这里 else if (KeyTableLookupSym(keysym.sym, &keytable)) { vkey = keytable.vkey; if (keytable.unicode == 0 && unicode != 0) unicode = 0; else if (keysym.unicode > 32 && keysym.unicode < 128) ascii = unicode & 0x7f; } ... //我们点击遥控器音量加到这里是 vkey:+, unicode:0x0000, ascii:null, modifiers:0x0000, held:0 CKey key(vkey, unicode, ascii, modifiers, held); return key;}
/*xbmc/input/XBMC_keytable.cpp*/bool KeyTableLookupSym(uint16_t sym, XBMCKEYTABLE* keytable){ ... // Look up the sym in XBMCKeyTable for (int i = 0; i < XBMCKeyTableSize; i++) { if (sym == XBMCKeyTable[i].sym) { *keytable = XBMCKeyTable[i]; return true; } } return false;}
这里会查找XBMCKeyTable这个数组,以找到sym号相同的的数组。我们知道sym为0x002b,这个
值是在AndroidKey.cpp将键盘scancode转化为sym而来。
/*xbmc/input/XBMC_keytable.h*/typedef struct struct_XBMCKEYTABLE{ uint16_t sym; uint16_t unicode; char ascii; uint32_t vkey; const char* keyname;}static const XBMCKEYTABLE XBMCKeyTable[] ={ ... // Misc printing characters { XBMCK_PLUS, '+', '+', XBMCVK_PLUS, "plus" } ...}
到此,我们就解析完了CKey对象的创建过程,然后它被传递给了
//xbmc/Application.cppbool CApplication::OnKey(const CKey& key){ // get the current active window int iWin = GetActiveWindowID(); // this will be checked for certain keycodes that need // special handling if the screensaver is active 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);}
0 0
- xbmc从onEvent到onkey创建CKey对象的过程
- xbmc从onKey到onAction创建CAction对象的过程
- 从过程到对象
- 从Java类到对象的创建过程都做了些啥以及内存中的对象是啥样的
- 应用窗口的从创建到显示的过程
- iOS 一个应用程序从创建到销毁的过程
- 线程(从创建到消亡的过程)
- 类从加载到对象实例化的过程顺序
- 从面向过程到面向对象的转变----C++
- 原型链的从对象创建到原理详解
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- 对象的创建过程
- Linux进程间通信_IPC方法综述
- .htaccess技巧: URL重写(Rewrite)与重定向(Redirect)
- GUID与MD5加密
- PDF转换成TXT的疑惑
- VB.NET 创建打印机选择列表
- xbmc从onEvent到onkey创建CKey对象的过程
- java 工厂模式
- OV7725+广州创龙OMAPL138开发板调试(从选型到出图像)
- 中科院大牛博士是如何进行文献检索和阅读(好习惯受益终生)(转载)
- Android系统架构之微服务架构
- extjs3.4集成ueditor将ueditor封装
- 报班学习PHP多少钱呢?
- Android Dialog使用举例 7种形式的
- 均方根值(RMS)+ 均方根误差(RMSE)+标准差(Standard Deviation)