// Loops and runs the callback method void* KeyboardThread(void* parent) { Keyboard_NDK *pParent = static_cast<Keyboard_NDK *>(parent); sleep(1); // 1. Start the library bps_initialize(); // 2. Request events to flow into the event queue virtualkeyboard_request_events(0); sleep(3); // 3. Use any service at any time //virtualkeyboard_show(); // Show the virtual keyboard // 4. Listen for events for (;;) { // get an event bps_event_t *event; bps_get_event(&event, -1); // blocking // handle the event pParent->event(event); } return NULL; }
static void initialize(void *p) { virtualkeyboard_request_events(0); virtualkeyboard_show(); unsigned int surface_width, surface_height; glview_get_size(&surface_width, &surface_height); glShadeModel(GL_SMOOTH); glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glViewport(0, 0, surface_width, surface_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrthof(0.0f, (float) (surface_width) / (float) (surface_height), 0.0f, 1.0f, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef((float) (surface_width) / (float) (surface_height) / 2, 0.5f, 0.0f); }
BPSEventListener::BPSEventListener() : _isKeyboardVisible(false) { subscribe(virtualkeyboard_get_domain()); subscribe(netstatus_get_domain()); bps_initialize(); virtualkeyboard_request_events(0); netstatus_request_events(0); }
QT_BEGIN_NAMESPACE QQnxVirtualKeyboardBps::QQnxVirtualKeyboardBps(QObject *parent) : QQnxAbstractVirtualKeyboard(parent) { if (locale_request_events(0) != BPS_SUCCESS) qWarning("QQNX: Failed to register for locale events"); if (virtualkeyboard_request_events(0) != BPS_SUCCESS) qWarning("QQNX: Failed to register for virtual keyboard events"); int height = 0; if (virtualkeyboard_get_height(&height) != BPS_SUCCESS) qWarning("QQNX: Failed to get virtual keyboard height"); setHeight(height); }
Keyboard_NDK::Keyboard_NDK(Keyboard_JS *parent): m_pParent(parent), keyboardProperty(50), keyboardThreadCount(1), threadHalt(true), m_thread(0) { pthread_cond_t cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; bps_initialize(); virtualkeyboard_request_events(0); virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_EMAIL,VIRTUALKEYBOARD_ENTER_DEFAULT); m_pParent->getLog()->info("Keyboard Created"); }
void fgPlatformMainLoopPreliminaryWork ( void ) { LOGI("fgPlatformMainLoopPreliminaryWork"); /* Request navigator events */ navigator_request_events(0); /* Allow rotation */ navigator_rotation_lock(false); #ifdef __PLAYBOOK__ /* Request keyboard events */ virtualkeyboard_request_events(0); #endif /* Request window events */ screen_request_events(fgDisplay.pDisplay.screenContext); }
void OSBB10::initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver) { data_dir = getenv("HOME"); //Create a screen context that will be used to create an EGL surface to to receive libscreen events screen_create_context(&screen_cxt,0); //Initialize BPS library bps_initialize(); //Use utility code to initialize EGL for 2D rendering with GL ES 1.1 enum RENDERING_API api = GL_ES_2; #ifdef BB10_LGLES_OVERRIDE api = GL_ES_1; #endif if (EXIT_SUCCESS != bbutil_init(screen_cxt, api)) { bbutil_terminate(); screen_destroy_context(screen_cxt); return; }; EGLint surface_width, surface_height; eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width); eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height); printf("screen size: %ix%i\n", surface_width, surface_height); VideoMode mode; mode.width = surface_width; mode.height = surface_height; mode.fullscreen = true; mode.resizable = false; set_video_mode(mode); //Signal BPS library that navigator and screen events will be requested screen_request_events(screen_cxt); navigator_request_events(0); virtualkeyboard_request_events(0); audiodevice_request_events(0); #ifdef DEBUG_ENABLED bps_set_verbosity(3); #endif accel_supported = accelerometer_is_supported(); if (accel_supported) accelerometer_set_update_frequency(FREQ_40_HZ); pitch = 0; roll = 0; #ifdef BB10_LGLES_OVERRIDE rasterizer = memnew( RasterizerGLES1(false) ); #else rasterizer = memnew( RasterizerGLES2(false, false) ); #endif visual_server = memnew( VisualServerRaster(rasterizer) ); visual_server->init(); visual_server->cursor_set_visible(false, 0); audio_driver = memnew(AudioDriverBB10); audio_driver->set_singleton(); audio_driver->init(NULL); physics_server = memnew( PhysicsServerSW ); physics_server->init(); physics_2d_server = memnew( Physics2DServerSW ); physics_2d_server->init(); input = memnew( InputDefault ); #ifdef PAYMENT_SERVICE_ENABLED payment_service = memnew(PaymentService); Globals::get_singleton()->add_singleton(Globals::Singleton("InAppStore", payment_service)); #endif }
int main(int argc, char *argv[]) { // Let's search for programs first in our own 'app' folder QString oldPath = qgetenv("PATH"); QString newPath = "app/native:"+oldPath; qputenv("PATH", newPath.toAscii().data()); // We need to store our working folder somewhere, it is needed for ssh later int res = system ("echo -n `pwd`\"/data/\" > data/.myhome"); if (res == -1){ fprintf(stderr, "Can't determine my home folder location, terminating"); exit(-1); } // Init file descriptors opening proper devices masterFdG = ::open("/dev/ptyp1", O_RDWR); slaveFdG = ::open("/dev/ttyp1", O_RDWR | O_NOCTTY); // And here is where magic begins pidG_ = fork(); if (pidG_ == 0) { dup2(slaveFdG, STDIN_FILENO); dup2(slaveFdG, STDOUT_FILENO); dup2(slaveFdG, STDERR_FILENO); // reset all signal handlers struct sigaction act; sigemptyset(&act.sa_mask); act.sa_handler = SIG_DFL; act.sa_flags = 0; for (int sig = 1; sig < NSIG; sig++) sigaction(sig, &act, 0L); // All we want in child process is to have sh running const char *arglist[] = {"/bin/sh", "-l", NULL}; execvp(arglist[0], (char**)arglist); } else if (pidG_ == -1) { // fork() failed qDebug() << "fork() failed:"; pidG_ = 0; return false; } // Drop garbage that is shown when you start the app char cGarbage[72]; read(masterFdG, cGarbage, 72); // needed for correct QT initialization //qputenv("QT_QPA_FONTDIR", "/usr/fonts/font_repository/dejavu-ttf-2.17"); // needed for correct QT initialization qputenv("QT_QPA_PLATFORM_PLUGIN_PATH", "/usr/lib/qt4/plugins/platforms"); //QCoreApplication::addLibraryPath("app/native/lib"); // blackberry plugin does not load without this line QApplication app(argc, argv); mainWindow = new CMyMainWindow(); QRect r = QApplication::desktop()->screenGeometry(0); mainWindow->resize(r.width()+1, r.height()+1); console = new QTermWidget(1, mainWindow); font = QFont(QString("Courier New"), 6); font.setPixelSize(mainWindow->nFontSize); font.setStyle(QFont::StyleNormal); font.setWeight(QFont::Normal); console->setTerminalFont(font); #ifndef BBQ10 // We start the app with shown keyboard virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_DEFAULT, VIRTUALKEYBOARD_ENTER_DEFAULT); if (r.width() > 800){ // Landscape virtualkeyboard_get_height(&nKBHeight); console->setGeometry(0, 0, r.width()-73, r.height()-nKBHeight); }else{ // Portrait - keyboard is higher virtualkeyboard_get_height(&nKBHeight); console->setGeometry(0, 103, r.width()+1, r.height()-nKBHeight-102); } #else console->setGeometry(0, 0, r.width()+1, r.height()-103); #endif console->setScrollBarPosition(QTermWidget::ScrollBarRight); // Our 'soft buttons' menu Menu = new CMyMenu(mainWindow); Menu->MenuInit(); // Our system menu SystemMenu = new CMySystemMenu(mainWindow); SystemMenu->MenuInit(); QObject::connect(console, SIGNAL(finished()), mainWindow, SLOT(close())); mainWindow->show(); #ifndef BBQ10 // Install event filter mainEventFilter = QAbstractEventDispatcher::instance()->setEventFilter(myEventFilter); // Show virtual keyboard QEvent event(QEvent::RequestSoftwareInputPanel); QApplication::sendEvent(console, &event); virtualkeyboard_get_height(&nMaxKBHeight); // Init maximum VK height virtualkeyboard_request_events(0); // To catch show/hide VK events #endif #ifdef BBQ10 virtualKeyboard = new CMyVirtualKeyboard(mainWindow); #endif return app.exec(); }
int main(int argc, char *argv[]) { int exit_application = 0; screen_context_t screen_cxt; //Create a screen context that will be used to create an EGL surface to to receive libscreen events screen_create_context(&screen_cxt,0); //Use utility code to initialize EGL for 2D rendering with GL ES 1.1 if (EXIT_SUCCESS != bbutil_init(screen_cxt, GL_ES_1)) { bbutil_terminate(); screen_destroy_context(screen_cxt); return 0; } //Initialize app data initialize(); //Initialize BPS library bps_initialize(); //Signal BPS library that navigator, screen, and keyboard events will be requested screen_request_events(screen_cxt); navigator_request_events(0); virtualkeyboard_request_events(0); virtualkeyboard_show(); for (;;) { //Request and process BPS next available event bps_event_t *event = NULL; if (bps_get_event(&event, 0) != BPS_SUCCESS) return EXIT_FAILURE; if (event) { int domain = bps_event_get_domain(event); if (domain == screen_get_domain()) { handleScreenEvent(event); } else if ((domain == navigator_get_domain()) && (NAVIGATOR_EXIT == bps_event_get_code(event))) { exit_application = 1; } } if (exit_application) { break; } render(); } //Stop requesting events from libscreen screen_stop_events(screen_cxt); //Shut down BPS library for this process bps_shutdown(); //Use utility code to terminate EGL setup bbutil_terminate(); //Destroy libscreen context screen_destroy_context(screen_cxt); return 0; }
int InitQNX(const char *Title,int Width,int Height) { /* Initialize variables */ AppTitle = Title; XSize = Width; YSize = Height; TimerON = 0; TimerReady = 0; JoyState = 0; LastKey = 0; KeyModes = 0; FrameCount = 0; FrameRate = 0; /* Get initial timestamp */ gettimeofday(&TimeStamp,0); screen_create_context(&ctxt, SCREEN_APPLICATION_CONTEXT); int dispCount; screen_get_context_property_iv(ctxt, SCREEN_PROPERTY_DISPLAY_COUNT, &dispCount); screen_display_t* displays = new screen_display_t[dispCount]; screen_get_context_property_pv(ctxt, SCREEN_PROPERTY_DISPLAYS, (void**)displays); int resolution[2] = { 0, 0 }; screen_get_display_property_iv(displays[0], SCREEN_PROPERTY_SIZE, resolution); delete[] displays; actualSize_x = resolution[0]; actualSize_y = resolution[1]; double scaleY; if (isPhysicalKeyboardDevice) scaleY = ((double)resolution[1]) / 600.0; else scaleY = ((double)resolution[1]) / 1024.0; double scaleX = ((double)resolution[0]) / 600.0; scaleTouchMap(scaleX, scaleY); if (BPS_SUCCESS != screen_request_events(ctxt)) { screen_destroy_context(ctxt); return 0; } #ifdef __BBTEN__ screen_create_window_type(&window, ctxt, SCREEN_CHILD_WINDOW); screen_join_window_group(window, windowGroup); screen_set_window_property_cv(window, SCREEN_PROPERTY_ID_STRING, windowIdLength, "AlmostTIAppID"); int vis = 1; screen_set_window_property_iv(window, SCREEN_PROPERTY_VISIBLE, &vis); int z = -5; screen_set_window_property_iv(window, SCREEN_PROPERTY_ZORDER, &z); if (isPhysicalKeyboardDevice) virtualkeyboard_request_events(0); #else screen_create_window(&window, ctxt); int usage = SCREEN_USAGE_WRITE | SCREEN_USAGE_NATIVE; screen_set_window_property_iv(window, SCREEN_PROPERTY_USAGE, &usage); #endif screen_create_window_buffers(window, 1); screen_get_window_property_iv(window, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); /* Done */ return(1); }