Ejemplo n.º 1
0
void handleScreenEvent(bps_event_t *event)
{
	screen_event_t screen_event = screen_event_get_event(event);

	int screen_val;
	screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val);

	switch (screen_val) {
	case SCREEN_EVENT_KEYBOARD:
		screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &screen_val);

		if (screen_val & KEY_DOWN) {
			screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM,&screen_val);

			printf("The '%c' key was pressed\n", (char)screen_val);
			fflush(stdout);

			switch (screen_val) {
			case KEYCODE_I:
				// Display the email layout with "Send" enter key
				virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_EMAIL, VIRTUALKEYBOARD_ENTER_SEND);
				break;
			case KEYCODE_O:
				// Display the phone layout with "Connect" enter key
				virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_PHONE, VIRTUALKEYBOARD_ENTER_CONNECT);
				break;
			case KEYCODE_P:
				// Display the default layout with default enter key
				virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_DEFAULT, VIRTUALKEYBOARD_ENTER_DEFAULT);
				break;
			case KEYCODE_H:
				// Hide the keyboard
				virtualkeyboard_hide();
				break;
			case KEYCODE_A:
				// Increment rotation angle
				angle = fmod(angle + ANGLE_INCREMENT, CIRCLE_DEGREES );
				break;
			case KEYCODE_Z:
				// Decrement rotation angle
				angle = fmod(angle - ANGLE_INCREMENT, CIRCLE_DEGREES );
				break;
			default:
				break;
			}
		}
		break;
	}
}
void QQnxVirtualKeyboardBps::applyKeyboardOptions()
{
    virtualkeyboard_layout_t layout = keyboardLayout();
    virtualkeyboard_enter_t enter = enterKey();

    qVirtualKeyboardDebug() << Q_FUNC_INFO << "mode=" << keyboardMode() << "enterKey=" << enterKeyType();

    virtualkeyboard_change_options(layout, enter);
}
void QBBVirtualKeyboardBps::applyKeyboardMode(KeyboardMode mode)
{
    virtualkeyboard_layout_t layout = VIRTUALKEYBOARD_LAYOUT_DEFAULT;

    switch (mode) {
    case Url:
        layout = VIRTUALKEYBOARD_LAYOUT_URL;
        break;

    case Email:
        layout = VIRTUALKEYBOARD_LAYOUT_EMAIL;
        break;

    case Web:
        layout = VIRTUALKEYBOARD_LAYOUT_WEB;
        break;

    case NumPunc:
        layout = VIRTUALKEYBOARD_LAYOUT_NUM_PUNC;
        break;

    case Symbol:
        layout = VIRTUALKEYBOARD_LAYOUT_SYMBOL;
        break;

    case Phone:
        layout = VIRTUALKEYBOARD_LAYOUT_PHONE;
        break;

    case Pin:
        layout = VIRTUALKEYBOARD_LAYOUT_PIN;
        break;

    case Default: // fall through
    default:
        layout = VIRTUALKEYBOARD_LAYOUT_DEFAULT;
        break;
    }

#if defined(QBBVIRTUALKEYBOARD_DEBUG)
    qDebug() << Q_FUNC_INFO << "mode=" << mode;
#endif

    virtualkeyboard_change_options(layout, VIRTUALKEYBOARD_ENTER_DEFAULT);
}
Ejemplo n.º 4
0
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");


}
Ejemplo n.º 5
0
bool myEventFilter(void *message) {
	// here we should have all requested bps events (no Qt events here)
    bps_event_t *event = (bps_event_t*)message;
    if (event) {
    	int domain = bps_event_get_domain(event);
    	if (domain == virtualkeyboard_get_domain()) {
    		unsigned int ec = bps_event_get_code(event);
    		 if (!bKBhidden && ec == VIRTUALKEYBOARD_EVENT_INFO){
    			int nNewKBHeight = virtualkeyboard_event_get_height(event);
    			virtualkeyboard_get_height(&nNewKBHeight);
    			if ( nNewKBHeight != nKBHeight){
    				nKBHeight = nNewKBHeight;
    				QRect r = QApplication::desktop()->screenGeometry(0);
    				if (r.width() > 800){
    					// Landscape
    					console->setGeometry(0, 0, r.width()-73, r.height()-nKBHeight);
    				}else{
    					// Portrait - keyboard is taller
    					console->setGeometry(0, 53, r.width(), r.height()-nKBHeight-53);
    				}
    			}
    		}
    		QRect r = QApplication::desktop()->screenGeometry(0);
    		if (ec == VIRTUALKEYBOARD_EVENT_VISIBLE){
				bKBhidden = false;
				nKBHeight = nMaxKBHeight;
				virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_DEFAULT, VIRTUALKEYBOARD_ENTER_DEFAULT);
    		}else if (ec == VIRTUALKEYBOARD_EVENT_HIDDEN){
				bKBhidden = true;
				nKBHeight = 0;
    		}
			if (r.width() > 800) console->setGeometry(0, 0, r.width()-73, r.height()-nKBHeight); // Landscape
			else console->setGeometry(0, 103, r.width(), r.height()-nKBHeight-103); // Portrait

			//font = QFont(QString("Courier New"), 6);
			font.setPixelSize(mainWindow->nFontSize);
		    font.setStyle(QFont::StyleNormal);
		    font.setWeight(QFont::Normal);
			console->setTerminalFont(font);
    	}
   	}
 	mainEventFilter(message); // Call replaced event filter so we deliever everything to Qt that runs in background
	return false;
}
Ejemplo n.º 6
0
void Keyboard_NDK::callKeyboardNumber(){

    virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_NUMBER,VIRTUALKEYBOARD_ENTER_SEND);
    virtualkeyboard_show();
}
Ejemplo n.º 7
0
void Keyboard_NDK::callKeyboardEmail(){
    virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_EMAIL,VIRTUALKEYBOARD_ENTER_SEND);
    virtualkeyboard_show();
}
Ejemplo n.º 8
0
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();
}
Ejemplo n.º 9
0
static void
event(bps_event_t *event, int domain, int code, void *p)
{
    if (virtualkeyboard_get_domain() == domain) {
        switch (code) {
        case VIRTUALKEYBOARD_EVENT_VISIBLE:
            keyboard_visible = true;
            break;
        case VIRTUALKEYBOARD_EVENT_HIDDEN:
            keyboard_visible = false;
            break;
        }
    } else if (screen_get_domain() == domain) {

        screen_event_t screen_event = screen_event_get_event(event);

        int screen_val;
        screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val);

        switch (screen_val) {
        case SCREEN_EVENT_MTOUCH_TOUCH:
            if (!keyboard_visible) {
                virtualkeyboard_show();
            }
            break;
        case SCREEN_EVENT_KEYBOARD:
            screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_FLAGS, &screen_val);

            if (screen_val & KEY_DOWN) {
                screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_KEY_SYM,&screen_val);

                fprintf(stderr, "The '%c' key was pressed\n", (char)screen_val);

                switch (screen_val) {
                case KEYCODE_I:
                    // Display the email layout with "Send" enter key
                    virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_EMAIL, VIRTUALKEYBOARD_ENTER_SEND);
                    break;
                case KEYCODE_O:
                    // Display the phone layout with "Connect" enter key
                    virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_PHONE, VIRTUALKEYBOARD_ENTER_CONNECT);
                    break;
                case KEYCODE_P:
                    // Display the default layout with default enter key
                    virtualkeyboard_change_options(VIRTUALKEYBOARD_LAYOUT_DEFAULT, VIRTUALKEYBOARD_ENTER_DEFAULT);
                    break;
                case KEYCODE_H:
                    // Hide the keyboard
                    virtualkeyboard_hide();
                    break;
                case KEYCODE_A:
                    // Increment rotation angle
                    angle = fmod(angle + ANGLE_INCREMENT, CIRCLE_DEGREES );
                    break;
                case KEYCODE_Z:
                    // Decrement rotation angle
                    angle = fmod(angle - ANGLE_INCREMENT, CIRCLE_DEGREES );
                    break;
                default:
                    break;
                }
            }
            break;
        }
    }
}