//
// Open Service Platform
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+// Copyright (c) 2013 Samsung Electronics Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the License);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
-// http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
_UiEventManager* _pEventManager;
}; // _Event
-struct _EvasConvertKeys
+struct _UiKeys
{
+
_KeyCode code;
const char* pName;
};
-const _EvasConvertKeys keyTable[] =
+const _UiKeys keyTable[] =
{
- { _KEY_SIDE_UP, "XF86AudioRaiseVolume" },
- { _KEY_SIDE_DOWN, "XF86AudioLowerVolume" },
- { _KEY_END, "XF86Stop" },
- { _KEY_ENTER, "Return" },
+ { _KEY_ESC, "Escape" },
+ { _KEY_GRAVE, "grave" },
+ { _KEY_1, "1" },
+ { _KEY_2, "2" },
+ { _KEY_3, "3" },
+ { _KEY_4, "4" },
+ { _KEY_5, "5" },
+ { _KEY_6, "6" },
+ { _KEY_7, "7" },
+ { _KEY_8, "8" },
+ { _KEY_9, "9" },
+ { _KEY_0, "0" },
+ { _KEY_MINUS, "minus" },
+ { _KEY_EQUAL, "equal" },
+ { _KEY_BACKSLASH, "backslash" },
{ _KEY_BACKSPACE, "BackSpace" },
- { _KEY_LEFT, "KP_Left"},
- { _KEY_UP, "KP_Up"},
- { _KEY_DOWN, "KP_Down"},
- { _KEY_RIGHT, "KP_Right"},
+ { _KEY_TAB, "Tab" },
+ { _KEY_Q, "q" },
+ { _KEY_W, "w" },
+ { _KEY_E, "e" },
+ { _KEY_R, "r" },
+ { _KEY_T, "t" },
+ { _KEY_Y, "y" },
+ { _KEY_U, "u" },
+ { _KEY_I, "i" },
+ { _KEY_O, "o" },
+ { _KEY_P, "p" },
+ { _KEY_LBRACKET, "bracketleft" },
+ { _KEY_RBRACKET, "bracketright" },
+ { _KEY_ENTER, "Return" },
+ { _KEY_CAPSLOCK, "Caps_Lock" },
+ { _KEY_A, "a" },
+ { _KEY_S, "s" },
+ { _KEY_D, "d" },
+ { _KEY_F, "f" },
+ { _KEY_G, "g" },
+ { _KEY_H, "h" },
+ { _KEY_J, "j" },
+ { _KEY_K, "k" },
+ { _KEY_L, "l" },
+ { _KEY_SEMICOLON, "semicolon" },
+ { _KEY_APOSTROPHE, "apostrophe" },
+ { _KEY_SHIFT_L, "Shift_L" },
+ { _KEY_Z, "z" },
+ { _KEY_X, "x" },
+ { _KEY_C, "c" },
+ { _KEY_V, "v" },
+ { _KEY_B, "b" },
+ { _KEY_N, "n" },
+ { _KEY_M, "m" },
+ { _KEY_COMMA, "comma" },
+ { _KEY_DOT, "period" },
+ { _KEY_SLASH, "slash" },
+ { _KEY_SHIFT_R, "Shift_R" },
+ { _KEY_CTRL_L, "Control_L" },
+ { _KEY_LALT, "Alt_L" },
+ { _KEY_SPACE, "space" },
+ { _KEY_RALT, "Alt_R" },
+ { _KEY_CTRL_R, "Control_R" },
+ { _KEY_FN_1, "F1" },
+ { _KEY_FN_2, "F2" },
+ { _KEY_FN_3, "F3" },
+ { _KEY_FN_4, "F4" },
+ { _KEY_FN_5, "F5" },
+ { _KEY_FN_6, "F6" },
+ { _KEY_FN_7, "F7" },
+ { _KEY_FN_8, "F8" },
+ { _KEY_FN_9, "F9" },
+ { _KEY_FN_10, "F10" },
+ { _KEY_FN_11, "F11" },
+ { _KEY_FN_12, "F12" },
+ { _KEY_NUM_LOCK, "Num_Lock" },
+ { _KEY_NUMPAD_DIVIDE, "KP_Divide" },
+ { _KEY_NUMPAD_MULTIPLY, "KP_Multiply" },
+ { _KEY_NUMPAD_SUBTRACT, "KP_Subtract" },
+ { _KEY_NUMPAD_7, "KP_Home" },
+ { _KEY_NUMPAD_8, "KP_Up" },
+ { _KEY_NUMPAD_9, "KP_Prior" },
+ { _KEY_NUMPAD_4, "KP_Left" },
+ { _KEY_NUMPAD_5, "KP_Begin" },
+ { _KEY_NUMPAD_6, "KP_Right" },
+ { _KEY_NUMPAD_ADD, "KP_Add" },
+ { _KEY_NUMPAD_1, "KP_End" },
+ { _KEY_NUMPAD_2, "KP_Down" },
+ { _KEY_NUMPAD_3, "KP_Next" },
+ { _KEY_NUMPAD_0, "KP_Insert" },
+ { _KEY_NUMPAD_DOT, "KP_Delete" },
+ { _KEY_NUMPAD_ENTER, "KP_Enter" },
+ { _KEY_PRINT, "Print" },
+ { _KEY_SCROLL_LOCK, "Scroll_Lock" },
+ { _KEY_PAUSEBREAK, "Pause" },
+ { _KEY_INSERT, "Insert" },
+ { _KEY_HOME_BUTTON, "Home" },
+ { _KEY_PAGE_UP, "Prior" },
+ { _KEY_DELETE, "Delete" },
+ { _KEY_END_BUTTON, "End" },
+ { _KEY_PAGE_DOWN, "Next" },
+ { _KEY_UP, "Up" },
{ _KEY_LEFT, "Left" },
- { _KEY_UP, "Up"},
- { _KEY_DOWN, "Down"},
- { _KEY_RIGHT, "Right"},
- { _KEY_0, "0"},
- { _KEY_1, "1"},
- { _KEY_2, "2"},
- { _KEY_3, "3"},
- { _KEY_4, "4"},
- { _KEY_5, "5"},
- { _KEY_6, "6"},
- { _KEY_7, "7"},
- { _KEY_8, "8"},
- { _KEY_9, "9"},
- { _KEY_A, "a"},
- { _KEY_B, "b"},
- { _KEY_C, "c"},
- { _KEY_D, "d"},
- { _KEY_E, "e"},
- { _KEY_F, "f"},
- { _KEY_G, "g"},
- { _KEY_H, "h"},
- { _KEY_I, "i"},
- { _KEY_J, "j"},
- { _KEY_K, "k"},
- { _KEY_L, "l"},
- { _KEY_M, "m"},
- { _KEY_N, "n"},
- { _KEY_O, "o"},
- { _KEY_P, "p"},
- { _KEY_Q, "q"},
- { _KEY_R, "r"},
- { _KEY_S, "s"},
- { _KEY_T, "t"},
- { _KEY_U, "u"},
- { _KEY_V, "v"},
- { _KEY_W, "w"},
- { _KEY_X, "x"},
- { _KEY_Y, "y"},
- { _KEY_Z, "z"},
- { _KEY_COMMA, "comma"},
- { _KEY_CAPSLOCK, "Caps_Lock"},
- { _KEY_ALT, "Alt_L"},
- { _KEY_ALT, "Alt_R"},
- { _KEY_SPACE, "space"},
- { _KEY_FN_1, "F1"},
- { _KEY_FN_2, "F2"},
- { _KEY_FN_3, "F3"},
- { _KEY_FN_4, "F4"},
- { _KEY_FN_5, "F5"},
- { _KEY_CLEAR, "BackSpace"},
- { _KEY_POWER_HOLD, "XF86PowerOff"},
- { _KEY_DELETE, "Delete"},
- { _KEY_DELETE, "KP_Delete"},
- { _KEY_CTRL_L, "XK_Control_L"},
- { _KEY_CTRL_L, "Control_L"},
- { _KEY_CTRL_R, "XK_Control_R"},
- { _KEY_CTRL_R, "Control_R"},
- { _KEY_SHIFT_L, "XK_Shift_L"},
- { _KEY_SHIFT_L, "Shift_L"},
- { _KEY_SHIFT_R, "XK_Shift_R"},
- { _KEY_SHIFT_R, "Shift_R"},
+ { _KEY_DOWN, "Down" },
+ { _KEY_RIGHT, "Right" },
+ { _KEY_CONTEXT_MENU, "Menu" },
+ { _KEY_MENU, "XF86Send" },
+
+ { _KEY_COMMA, "less" }, /*virtual keypad <*/
+ { _KEY_9, "parenleft" }, /*virtual keypad (*/
+ { _KEY_0, "parenright" }, /*virtual keypad )*/
+
+ { _KEY_BACK, "XF86Stop" },
+// { _KEY_HOME, "XF86Phone" },
+ { _KEY_WEB_PAGE, "XF86WWW" },
+ { _KEY_MAIL, "XF86Mail" },
+ { _KEY_SCREEN_SAVER, "XF86ScreenSaver" },
+ { _KEY_BRIGHTNESS_DOWN, "XF86MonBrightnessDown" },
+ { _KEY_BRIGHTNESS_UP, "XF86MonBrightnessUp" },
+ { _KEY_MUTE, "XF86AudioMute" },
+// { _KEY_VOLUME_DOWN, "XF86AudioLowerVolume" },
+// { _KEY_VOLUME_UP, "XF86AudioRaiseVolume" },
+ { _KEY_PLAY_PAUSE, "XF86AudioPlay" },
+ { _KEY_NEXT_SONG, "XF86AudioNext" },
+ { _KEY_PREVIOUS_SONG, "XF86AudioPrev" },
+ { _KEY_APPS, "XF86Launch0" },
+ { _KEY_MENU, "XF86Send" },
+ { _KEY_SOFT_KEYBOARD, "XF86MenuKB" },
+ { _KEY_SEARCH, "XF86Search" },
+ { _KEY_VOICE, "XF86Launch2" },
+ { _KEY_QUICK_PANEL, "XF86Tools" }
};
-#if 0
+
class _KeyEvent
: public _Event
{
public:
- _KeyEvent(KeyState keyState, _ keyCode, int keyModifier, void* pUserData)
+ _KeyEvent(KeyState keyState, _KeyCode keyCode, int keyModifier, void* pUserData)
: __pTarget(null)
, __keyInfo(keyState, keyCode, keyModifier, pUserData)
{
SysTryReturn(NID_UI, pKeyName, _KEY_INVALID, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
- for (unsigned int i = 0; i < sizeof(keyTable) / sizeof(_EvasConvertKeys); ++i)
+ for (unsigned int i = 0; i < sizeof(keyTable) / sizeof(_UiKeys); ++i)
{
if (strcmp(keyTable[i].pName, pKeyName) == 0)
{
return _KEY_INVALID;
}
+ static _KeyCode GetKeyCode(unsigned int sym)
+ {
+ ClearLastResult();
+ char* pKeyName = XKeysymToString(sym);
+
+ SysTryReturn(NID_UI, pKeyName, _KEY_INVALID, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid.");
+
+ return GetKeyCode(pKeyName);
+ }
+
static int GetKeyModifier(const int keyModifier)
{
ClearLastResult();
unsigned int modifier = _KEY_MODIFIER_NONE;
- if(ECORE_EVENT_MODIFIER_SHIFT & keyModifier)
- {
- modifier |= _KEY_MODIFIER_SHIFT;
- }
- if(ECORE_EVENT_MODIFIER_CTRL & keyModifier)
- {
- modifier |= _KEY_MODIFIER_CTRL;
- }
- if(ECORE_EVENT_MODIFIER_ALT & keyModifier)
- {
- modifier |= _KEY_MODIFIER_ALT;
- }
- if(ECORE_EVENT_MODIFIER_WIN & keyModifier)
- {
- modifier |= _KEY_MODIFIER_WIN;
- }
- if(ECORE_EVENT_MODIFIER_SCROLL & keyModifier)
- {
- modifier |= _KEY_MODIFIER_SCROLL;
- }
- if(ECORE_EVENT_MODIFIER_NUM & keyModifier)
- {
- modifier |= _KEY_MODIFIER_NUM;
- }
- if(ECORE_EVENT_MODIFIER_CAPS & keyModifier)
- {
- modifier |= _KEY_MODIFIER_CAPS;
- }
- if(ECORE_EVENT_LOCK_SCROLL & keyModifier)
- {
- modifier |= _KEY_LOCK_SCROLL;
- }
- if(ECORE_EVENT_LOCK_NUM & keyModifier)
- {
- modifier |= _KEY_LOCK_NUM;
- }
- if(ECORE_EVENT_LOCK_CAPS & keyModifier)
- {
- modifier |= _KEY_LOCK_CAPS;
- }
- if(ECORE_EVENT_LOCK_SHIFT & keyModifier)
- {
- modifier |= _KEY_LOCK_SHIFT;
- }
- if(ECORE_EVENT_MODIFIER_ALTGR & keyModifier)
- {
- modifier |= _KEY_MODIFIER_ALTGR;
- }
+// if(ECORE_EVENT_MODIFIER_SHIFT & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_SHIFT;
+// }
+// if(ECORE_EVENT_MODIFIER_CTRL & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_CTRL;
+// }
+// if(ECORE_EVENT_MODIFIER_ALT & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_ALT;
+// }
+// if(ECORE_EVENT_MODIFIER_WIN & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_WIN;
+// }
+// if(ECORE_EVENT_MODIFIER_SCROLL & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_SCROLL;
+// }
+// if(ECORE_EVENT_MODIFIER_NUM & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_NUM;
+// }
+// if(ECORE_EVENT_MODIFIER_CAPS & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_CAPS;
+// }
+// if(ECORE_EVENT_LOCK_SCROLL & keyModifier)
+// {
+// modifier |= _KEY_LOCK_SCROLL;
+// }
+// if(ECORE_EVENT_LOCK_NUM & keyModifier)
+// {
+// modifier |= _KEY_LOCK_NUM;
+// }
+// if(ECORE_EVENT_LOCK_CAPS & keyModifier)
+// {
+// modifier |= _KEY_LOCK_CAPS;
+// }
+// if(ECORE_EVENT_LOCK_SHIFT & keyModifier)
+// {
+// modifier |= _KEY_LOCK_SHIFT;
+// }
+// if(ECORE_EVENT_MODIFIER_ALTGR & keyModifier)
+// {
+// modifier |= _KEY_MODIFIER_ALTGR;
+// }
return modifier;
}
_Control* GetTarget(_KeyCode keyCode) const
{
_KeyEventManager* pKeyEventManager = _KeyEventManager::GetInstance();
- SysAssert(pKeyEventManager != null);
-
- _Control* pControl = pKeyEventManager->GetCapturingControl(keyCode);
-
- if (pControl == null)
- {
- _ControlManager* pControlManager = _ControlManager::GetInstance();
- SysAssert(pControlManager != null);
-
- pControl = pControlManager->GetFocusedControl();
+ SysTryReturn(NID_UI, pKeyEventManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
- if (!pControl)
- {
- pControl = pControlManager->GetCurrentFrame();
- }
- SysTryReturn(NID_UI, pControl, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
- }
-
_ControlManager* pControlManager = _ControlManager::GetInstance();
SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
- pControl = pControlManager->GetFocusedControl();
+ _Control* pControl = pControlManager->GetFocusControl();
if (!pControl)
{
- pControl = pControlManager->GetCurrentFrame();
+ _Window * pWindow = pControlManager->GetCurrentFrame();
+ pControl = pWindow->GetCurrentFocusControl();
+ pControlManager->SetFocusControl(*pControl);
+
}
SysTryReturn(NID_UI, pControl, null, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
_KeyInfo __keyInfo;
}; // _KeyEvent
-#endif
class _TouchEventManager
{
break;
}
-// case _RawEvent::RAWEVENT_KEYPRESS:
-// {
-// _KeyEvent event(KEY_PRESSED, _KeyEvent::GetKeyCode(pEv->keyname), _KeyEvent::GetKeyModifier(pEv->modifiers), pEv);
-// event.Send();
-// break;
-// }
-// case _RawEvent::RAWEVENT_KEYRELEASE:
-// {
-// _KeyEvent event(KEY_RELEASED, _KeyEvent::GetKeyCode(pEv->keyname), _KeyEvent::GetKeyModifier(pEv->modifiers), pEv);
-// event.Send();
-// break;
-// }
+ case _RawEvent::RAWEVENT_KEYPRESS:
+ {
+
+ _KeyCode keyCode = _KeyEvent::GetKeyCode(rawEvent.data.key.keySymbol);
+
+ if (keyCode == _KEY_INVALID)
+ {
+ SysLog(NID_UI, "KeyCode is Invalid");
+ return false;
+ }
+ _KeyEvent event(KEY_PRESSED, keyCode, _KeyEvent::GetKeyModifier(0), null);
+ event.Send();
+ break;
+ }
+ case _RawEvent::RAWEVENT_KEYRELEASE:
+ {
+ _KeyCode keyCode = _KeyEvent::GetKeyCode(rawEvent.data.key.keySymbol);
+
+ if (keyCode == _KEY_INVALID)
+ {
+ SysLog(NID_UI, "KeyCode is Invalid");
+ return false;
+ }
+ _KeyEvent event(KEY_RELEASED, keyCode, _KeyEvent::GetKeyModifier(0), null);
+ event.Send();
+ break;
+ }
}
return true;