//[-------------------------------------------------------] //[ Public virtual UpdateDevice functions ] //[-------------------------------------------------------] void AndroidKeyboardDevice::Update() { // Check if input device is valid if (m_pDevice) { // Get keyboard device Keyboard *pKeyboard = static_cast<Keyboard*>(m_pDevice); // Process delayed keys for (uint32 i=0; i<m_lstDelayedKeys.GetNumOfElements(); i++) { const KeyInfo &sKeyInfo = m_lstDelayedKeys[i]; // Get button Button *pButton = GetKeyboardKey(*pKeyboard, sKeyInfo.nKeyCode); if (pButton) { // Get button state const bool bPressed = sKeyInfo.bPressed; // Propagate changes if (pButton->IsPressed() != bPressed) pButton->SetPressed(bPressed); } } m_lstDelayedKeys.Clear(); m_lstProcessedKeys.Clear(); } }
/** * @brief * Call this to process the next key input event */ void AndroidKeyboardDevice::OnKeyInputEvent(const struct AInputEvent &cAKeyInputEvent) { // Check if input device is valid if (m_pDevice) { // Get Android key code const int32_t nKeyCode = AKeyEvent_getKeyCode(&cAKeyInputEvent); // Lookout! The virtual keyboard of Android sends "down" and "up" directly one after another // -> This is really a problem and we have to delay further keys... if (m_lstProcessedKeys.IsElement(nKeyCode)) { // Add key for later processing KeyInfo sKeyInfo; sKeyInfo.nKeyCode = nKeyCode; sKeyInfo.bPressed = (AKeyEvent_getAction(&cAKeyInputEvent) == AKEY_EVENT_ACTION_DOWN); m_lstDelayedKeys.Add(sKeyInfo); } else { // Get keyboard device Keyboard *pKeyboard = static_cast<Keyboard*>(m_pDevice); // Get button Button *pButton = GetKeyboardKey(*pKeyboard, nKeyCode); if (pButton) { // Get button state const bool bPressed = (AKeyEvent_getAction(&cAKeyInputEvent) == AKEY_EVENT_ACTION_DOWN); // Propagate changes if (pButton->IsPressed() != bPressed) pButton->SetPressed(bPressed); } // Add this key to the processed keys m_lstProcessedKeys.Add(nKeyCode); } } }
int IO5KeyPad::GetKey() { int result = GetJoystickKey(); if (result == 0) { result = GetKeyboardKey(); } return result; }