static void process_input(struct android_app* app, struct android_poll_source* source) { AInputEvent* event = NULL; if (AInputQueue_getEvent(app->inputQueue, &event) >= 0) { // HACK: Override back buttom to show / hide keyboard. int type = AInputEvent_getType(event); if(type == AINPUT_EVENT_TYPE_KEY) { if(AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_DOWN) { static bool keyboard_shown = false; if( AKeyEvent_getKeyCode(event) == AKEYCODE_BACK ) { displayKeyboard(app,!keyboard_shown); keyboard_shown = !keyboard_shown; AInputQueue_finishEvent(app->inputQueue, event, 1); return; } } } if (AInputQueue_preDispatchEvent(app->inputQueue, event)) { return; } int32_t handled = 0; if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event); AInputQueue_finishEvent(app->inputQueue, event, handled); } else { LOGE("Failure reading next input event: %s\n", strerror(errno)); } }
void MainWindow::makeConnects() { connect(gridButton, SIGNAL(triggered(bool)), information, SLOT(changeGridState())); connect(information, SIGNAL(gridStateChange()), this, SLOT(updateGridButtonIcon())); connect(scene, SIGNAL(sizeChanged(int,int)), imageExportWin, SLOT(setSize(int,int))); connect(inputWin, SIGNAL(displayKeyboard()), keyboard, SLOT(show())); }
void hide_keyboard( void ) { #ifdef DEBUG_KEY_INPUT LOGI( "HideSoftInput" ); #endif displayKeyboard( 0 ); //ANativeActivity_hideSoftInput( engine.app->activity, ANATIVEACTIVITY_HIDE_SOFT_INPUT_IMPLICIT_ONLY ); }
void InputSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex) { TouchPoint* tp = NULL; // Not optimal, however we expect the list size to be very small (<10) for (std::list<TouchPoint>::iterator it = _touchPoints.begin(); it != _touchPoints.end(); ++it) { if (it->_id == contactIndex) { tp = &(*it); // (seems redundant, however due to STD) break; } } // Add a new touch point if not found above if (!tp) { tp = new TouchPoint(); tp->_id = contactIndex; _touchPoints.push_back(*tp); } // Update the touch point tp->_coord.x = x; tp->_coord.y = y; tp->_isStale = false; // (could be overwritten below) switch (evt) { case Touch::TOUCH_PRESS: // Purge all stale touch points for (std::list<TouchPoint>::iterator it = _touchPoints.begin(); it != _touchPoints.end(); ) { if (it->_isStale) { it = _touchPoints.erase(it); } else { ++it; } } if (x < 30 && y < 30) { displayKeyboard(true); } break; case Touch::TOUCH_RELEASE: // Mark the current touch point as stale if (tp) { tp->_isStale = true; } break; case Touch::TOUCH_MOVE: break; }; }
void show_keyboard( void ) { #ifdef DEBUG_KEY_INPUT LOGI( "ShowSoftInput" ); #endif displayKeyboard( 1 ); //ANativeActivity_showSoftInput( engine.app->activity, ANATIVEACTIVITY_SHOW_SOFT_INPUT_IMPLICIT ); }
void InputSample::controlEvent(Control* control, EventType evt) { if (strcmp(control->getId(), "showKeyboardButton") == 0) { _keyboardState = !_keyboardState; displayKeyboard(_keyboardState); static_cast<Button*>(_inputSampleControls->getControl("showKeyboardButton"))->setText(_keyboardState ? "Hide virtual keyboard" : "Show virtual keyboard"); } else if (strcmp(control->getId(), "captureMouseButton") == 0 && hasMouse()) { setCaptured(true); } }
void InputSample::finalize() { setMouseCaptured(false); if (_keyboardState) { displayKeyboard(false); } SAFE_RELEASE(_scene); SAFE_RELEASE(_formNode); SAFE_RELEASE(_inputSampleControls); SAFE_DELETE(_crosshair); SAFE_RELEASE(_font); }
void GestureSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex) { switch (evt) { case Touch::TOUCH_PRESS: if (x < 30 && y < 30) { displayKeyboard(true); } break; case Touch::TOUCH_RELEASE: break; case Touch::TOUCH_MOVE: break; }; }
// Returns the char that is currently highlighted if the pushBotton is pressed. char getHighlightedChar() { int isCharReturned = FALSE; if(buttonPressed == TRUE) { buttonPressed = FALSE; if(KeyBoard.CursorPosition == MOVE_LEFT) { KeyBoard.ArrayRow -= 1; if(KeyBoard.ArrayRow < KEYBOARD_INDEX_MIN) { KeyBoard.ArrayRow = KEYBOARD_INDEX_MAX; } } else if(KeyBoard.CursorPosition == MOVE_RIGHT) { KeyBoard.ArrayRow += 1; if(KeyBoard.ArrayRow > KEYBOARD_INDEX_MAX) { KeyBoard.ArrayRow = KEYBOARD_INDEX_MIN; } } else { displayKeyboard(DISPLAY_ROW); buttonPressed = FALSE; isCharReturned = TRUE; } } if(isCharReturned == TRUE) { return(KeyBoard.Characters[KeyBoard.ArrayRow][KeyBoard.CursorPosition]); } else { return(NULL); } }