Пример #1
0
	void
KeyboardHandler::exec (  )
{
	//The event structure that will be used
	SDL_Event event;
	while (!m_stopRequested)
	{
		while(SDL_PollEvent( &event ))
		{
			switch (event.type)
			{
				case SDL_QUIT:
					{
						m_stopRequested = true;
					}
					break;
				case SDL_KEYDOWN:
					{
						handleKeyPressed(event.key.keysym.sym );
					}
					break;
			}
		}
		boost::posix_time::millisec exeTime(40);
		boost::this_thread::sleep(exeTime);
	}
	m_running = false;
	return ;
}
Пример #2
0
	void update( float dt )
	{
		if( dt == 0 )
		{
			return;
		}

	    //! Read all events from the view and keyboard
		while ( m_view.readEvent( m_viewEvent ) )
	    {
	    	 switch( m_viewEvent.type )
	    	 {
	    	 case ::sf::Event::Closed:
	    		 shutdown();
	    	 break;

	    	 case ::sf::Event::KeyPressed:
	    		 handleKeyPressed( m_viewEvent.key.code );
	    	 break;

	    	 case ::sf::Event::KeyReleased:
	    		 handleKeyReleased( m_viewEvent.key.code );
	    	 break;

	    	 default:
	    	 break;
	    	 }
	    }

		m_model.update( dt );

		m_view.update();
	}
Пример #3
0
bool GameController::eventFilter(QObject *object, QEvent *event)
{
    if (event->type() == QEvent::KeyPress)
    {
        handleKeyPressed ( (QKeyEvent *)event);
        return true;
    }
    else
    {
        return QObject::eventFilter(object, event);
    }
}
Пример #4
0
/* Key repeat timer timeout. Re-handle key pressed, if key still pressed.
 */
void Tohkbd::repeatTimerTimeout()
{
    if (!keyRepeat)
    {
        /* Check is the interrupt stuck down on first repeat timer timeout*/
        if (readOneLineFromFile("/sys/class/gpio/gpio" GPIO_INT "/value") == "0")
        {
            printf("repeatTimerTimeout: interrupt is active, trying to handle it now.\n");
            handleGpioInterrupt();
            return;
        }
    }

    keyRepeat = true;
    handleKeyPressed(lastKeyCode);

    /* Keep backlight on when repeating if it was turned on when key pressed first time */
    if (backlightTimer->isActive())
        backlightTimer->start();
}
Пример #5
0
/* Key repeat timer timeout. Re-handle key pressed, if key still pressed.
 */
void Tohkbd::repeatTimerTimeout()
{
    keyRepeat = true;
    handleKeyPressed(lastKeyCode);
}
Пример #6
0
/* Main
 */
Tohkbd::Tohkbd(QObject *parent) :
       QObject(parent)
{
    dbusRegistered = false;
    interruptsEnabled = false;
    vddEnabled = false;
    capsLockSeq = 0;
    vkbLayoutIsTohkbd = false;
    currentActiveLayout = QString();
    currentOrientationLock = QString();
    keypadIsPresent = false;
    gpio_fd = -1;
    displayIsOn = false;
    keyIsPressed = false;
    keyRepeat = false;
    slideEventEmitted = false;
    taskSwitcherVisible = false;
    ssNotifyReplacesId = 0;
    ssFilename = QString();

    tohkbd2user = new QDBusInterface("com.kimmoli.tohkbd2user", "/", "com.kimmoli.tohkbd2user", QDBusConnection::sessionBus(), this);
    tohkbd2user->setTimeout(2000);

    thread = new QThread();
    worker = new Worker();

    worker->moveToThread(thread);
    connect(worker, SIGNAL(gpioInterruptCaptured()), this, SLOT(handleGpioInterrupt()));
    connect(worker, SIGNAL(workRequested()), thread, SLOT(start()));
    connect(thread, SIGNAL(started()), worker, SLOT(doWork()));
    connect(worker, SIGNAL(finished()), thread, SLOT(quit()), Qt::DirectConnection);

    backlightTimer = new QTimer(this);
    backlightTimer->setSingleShot(true);
    connect(backlightTimer, SIGNAL(timeout()), this, SLOT(backlightTimerTimeout()));

    presenceTimer = new QTimer(this);
    presenceTimer->setInterval(2000);
    presenceTimer->setSingleShot(true);
    connect(presenceTimer, SIGNAL(timeout()), this, SLOT(presenceTimerTimeout()));

    repeatTimer = new QTimer(this);
    repeatTimer->setSingleShot(true);
    connect(repeatTimer, SIGNAL(timeout()), this, SLOT(repeatTimerTimeout()));

    /* do this automatically at startup */
    setVddState(true);
    setInterruptEnable(true);

    uinputif = new UinputIf();
    uinputif->openUinputDevice();

    tca8424 = new tca8424driver(0x3b);
    keymap = new keymapping();

    FKEYS.clear();
    FKEYS.append(KEY_F1);
    FKEYS.append(KEY_F2);
    FKEYS.append(KEY_F3);
    FKEYS.append(KEY_F4);
    FKEYS.append(KEY_F5);
    FKEYS.append(KEY_F6);
    FKEYS.append(KEY_F7);
    FKEYS.append(KEY_F8);
    FKEYS.append(KEY_F9);
    FKEYS.append(KEY_F10);
    FKEYS.append(KEY_F11);
    FKEYS.append(KEY_F12);

    reloadSettings();

    if (currentActiveLayout.isEmpty())
        changeActiveLayout(true);

    if (currentOrientationLock.isEmpty())
    {
        changeOrientationLock(true);
        saveOrientation();
    }

    checkKeypadPresence();

    connect(keymap, SIGNAL(shiftChanged()), this, SLOT(handleShiftChanged()));
    connect(keymap, SIGNAL(ctrlChanged()), this, SLOT(handleCtrlChanged()));
    connect(keymap, SIGNAL(altChanged()), this, SLOT(handleAltChanged()));
    connect(keymap, SIGNAL(symChanged()), this, SLOT(handleSymChanged()));
    connect(keymap, SIGNAL(keyPressed(QList< QPair<int, int> >)), this, SLOT(handleKeyPressed(QList< QPair<int, int> >)));
    connect(keymap, SIGNAL(keyReleased()), this, SLOT(handleKeyReleased()));

}
Пример #7
0
/* Main
 */
Tohkbd::Tohkbd(QObject *parent) :
       QObject(parent)
{
    dbusRegistered = false;
    interruptsEnabled = false;
    vddEnabled = false;
    vkbLayoutIsTohkbd = false;
    currentActiveLayout = QString();
    currentOrientationLock = QString();
    keypadIsPresent = false;
    gpio_fd = -1;
    displayIsOn = false;
    keyIsPressed = false;
    keyRepeat = false;
    slideEventEmitted = false;
    taskSwitcherVisible = false;
    selfieLedOn = false;
    gpioInterruptCounter = 0;
    actualSailfishVersion = QString();

    fix_CapsLock = !checkSailfishVersion("1.1.7.0");
    capsLock = false;

    tohkbd2user = new ComKimmoliTohkbd2userInterface("com.kimmoli.tohkbd2user", "/", QDBusConnection::sessionBus(), this);
    tohkbd2user->setTimeout(2000);

    thread = new QThread();
    worker = new Worker();

    worker->moveToThread(thread);
    connect(worker, SIGNAL(gpioInterruptCaptured()), this, SLOT(handleGpioInterrupt()));
    connect(worker, SIGNAL(workRequested()), thread, SLOT(start()));
    connect(thread, SIGNAL(started()), worker, SLOT(doWork()));
    connect(worker, SIGNAL(finished()), thread, SLOT(quit()), Qt::DirectConnection);

    backlightTimer = new QTimer(this);
    backlightTimer->setSingleShot(true);
    connect(backlightTimer, SIGNAL(timeout()), this, SLOT(backlightTimerTimeout()));

    presenceTimer = new QTimer(this);
    presenceTimer->setInterval(2000);
    presenceTimer->setSingleShot(true);
    connect(presenceTimer, SIGNAL(timeout()), this, SLOT(presenceTimerTimeout()));

    repeatTimer = new QTimer(this);
    repeatTimer->setSingleShot(true);
    connect(repeatTimer, SIGNAL(timeout()), this, SLOT(repeatTimerTimeout()));

    /* do this automatically at startup */
    setVddState(true);
    setInterruptEnable(true);

    uinputif = new UinputIf();
    uinputif->openUinputDevice();

    uinputevpoll = new UinputEvPoll();
    evpollThread = new QThread();

    uinputevpoll->moveToThread(evpollThread);
    connect(uinputevpoll, SIGNAL(capsLockLedChanged(bool)), this, SLOT(capsLockLedState(bool)));
    connect(uinputevpoll, SIGNAL(pollingRequested()), evpollThread, SLOT(start()));
    connect(evpollThread, SIGNAL(started()), uinputevpoll, SLOT(doPoll()));
    connect(uinputevpoll, SIGNAL(finished()), evpollThread, SLOT(quit()), Qt::DirectConnection);

    uinputevpoll->requestPolling(uinputif->getFd());

    printf("uinputevpoll->requestPolling(uinputif->getFd());\n");

    tca8424 = new tca8424driver(0x3b);
    keymap = new keymapping();

    FKEYS.clear();
    FKEYS.append(KEY_F1);
    FKEYS.append(KEY_F2);
    FKEYS.append(KEY_F3);
    FKEYS.append(KEY_F4);
    FKEYS.append(KEY_F5);
    FKEYS.append(KEY_F6);
    FKEYS.append(KEY_F7);
    FKEYS.append(KEY_F8);
    FKEYS.append(KEY_F9);
    FKEYS.append(KEY_F10);
    FKEYS.append(KEY_F11);
    FKEYS.append(KEY_F12);

    reloadSettings();

    keymap->setLayout(masterLayout);

    if (currentActiveLayout.isEmpty())
        changeActiveLayout(true);

    if (currentOrientationLock.isEmpty())
    {
        changeOrientationLock(true);
        saveOrientation();
    }

    checkKeypadPresence();

    connect(keymap, SIGNAL(shiftChanged()), this, SLOT(handleShiftChanged()));
    connect(keymap, SIGNAL(ctrlChanged()), this, SLOT(handleCtrlChanged()));
    connect(keymap, SIGNAL(altChanged()), this, SLOT(handleAltChanged()));
    connect(keymap, SIGNAL(symChanged()), this, SLOT(handleSymChanged()));
    connect(keymap, SIGNAL(toggleCapsLock()), this, SLOT(toggleCapsLock()));
    connect(keymap, SIGNAL(keyPressed(QList< QPair<int, int> >)), this, SLOT(handleKeyPressed(QList< QPair<int, int> >)));
    connect(keymap, SIGNAL(keyReleased()), this, SLOT(handleKeyReleased()));
    connect(keymap, SIGNAL(bogusDetected()), tca8424, SLOT(reset()));
}