Beispiel #1
0
bool Gesture::x11Event( XEvent* ev_P )
    {
/*		kdDebug(1217) << k_funcinfo  << "   ( type = " << ev_P->type << " )" << KeyRelease << " " << KeyPress  <<endl;
		if( ev_P->type == XKeyPress || ev_P->type == XKeyRelease )
		{
			return voice_handler->x11Event( ev_P );
	}*/
		
    if( ev_P->type == ButtonPress && ev_P->xbutton.button == button )
        {
        kdDebug( 1217 ) << "GESTURE: mouse press" << endl;
        stroke.reset();
        stroke.record( ev_P->xbutton.x, ev_P->xbutton.y );
        nostroke_timer.start( timeout, true );
        recording = true;
        start_x = ev_P->xbutton.x_root;
        start_y = ev_P->xbutton.y_root;
        return true;
        }
    else if( ev_P->type == ButtonRelease && ev_P->xbutton.button == button
        && recording )
        {
        recording = false;
        nostroke_timer.stop();
        stroke.record( ev_P->xbutton.x, ev_P->xbutton.y );
        QString gesture( stroke.translate());
        if( gesture.isEmpty())
            {
            kdDebug( 1217 ) << "GESTURE: replay" << endl;
            XAllowEvents( qt_xdisplay(), AsyncPointer, CurrentTime );
            XUngrabPointer( qt_xdisplay(), CurrentTime );
            mouse_replay( true );
            return true;
            }
        kdDebug( 1217 ) << "GESTURE: got: " << gesture << endl;
        emit handle_gesture( gesture, windows_handler->window_at_position( start_x, start_y ));
        return true;
        }
    else if( ev_P->type == MotionNotify && recording )
        { // ignore small initial movement
        if( nostroke_timer.isActive()
            && abs( start_x - ev_P->xmotion.x_root ) < 10
            && abs( start_y - ev_P->xmotion.y_root ) < 10 )
            return true;
        nostroke_timer.stop();
        stroke.record( ev_P->xmotion.x, ev_P->xmotion.y );
        }
    return false;
    }
Beispiel #2
0
void Gesture::unregister_handler( QObject* receiver_P, const char* slot_P )
{
    if( !handlers.contains( receiver_P ))
        return;
    handlers.remove( receiver_P );

    disconnect( this, SIGNAL(handle_gesture(StrokePoints)),
                receiver_P, slot_P
              );
    disconnect( receiver_P, SIGNAL(gotScore(ActionData*const,qreal)),
                this, SLOT(handleScore(ActionData*const,qreal))
              );
    if( handlers.count() == 0 )
        update_grab();
}
Beispiel #3
0
void Gesture::register_handler( QObject* receiver_P, const char* slot_P )
{
    if( handlers.contains( receiver_P ))
        return;
    handlers[ receiver_P ] = true;
    // connect directly because we want to be sure that all triggers submitted
    // their scores back to this object before executing the best match we
    // could find.
    connect( this, SIGNAL(handle_gesture(StrokePoints)),
             receiver_P, slot_P,
             Qt::DirectConnection
           );
    connect( receiver_P, SIGNAL(gotScore(ActionData*const,qreal)),
             this, SLOT(handleScore(ActionData*const,qreal)),
             Qt::DirectConnection
           );
    if( handlers.count() == 1 )
        update_grab();
}
/******************************************************************************
* Public Function Definitions
*******************************************************************************/
void main()
{
    if( system_init() )
        return;
    DisableInterrupts();
    OLED_WriteText("Initialization", 20, 75);
    delay_ms(2000);
    OLED_DrawImage( irgesturen_bmp, 0, 0 );
    EnableInterrupts();
    while(1)
    {
        if( gesture_flag )
        {
            DisableInterrupts();
            handle_gesture();
            delay_ms(1000);
            OLED_DrawImage( irgesturen_bmp, 0, 0 );
            gesture_flag = false;
            EnableInterrupts();
        }
    }
}
Beispiel #5
0
bool Gesture::x11Event( XEvent* ev_P )
{
    /*      kDebug() << "   ( type = " << ev_P->type << " )" << KeyRelease << " " << KeyPress ;
            if( ev_P->type == XKeyPress || ev_P->type == XKeyRelease )
            {
                return voice_handler->x11Event( ev_P );
        }*/

    if( ev_P->type == ButtonPress && ev_P->xbutton.button == button )
    {
        kDebug() << "GESTURE: mouse press";
        stroke.reset();
        stroke.record( ev_P->xbutton.x, ev_P->xbutton.y );
        nostroke_timer.start( timeout );
        recording = true;
        start_x = ev_P->xbutton.x_root;
        start_y = ev_P->xbutton.y_root;
        return true;
    }
    // if stroke is finished... postprocess the data and send a signal.
    // then wait for incoming matching scores and execute the best fit.
    else if( ev_P->type == ButtonRelease && ev_P->xbutton.button == button
             && recording )
    {
        recording = false;
        nostroke_timer.stop();
        stroke.record( ev_P->xbutton.x, ev_P->xbutton.y );
        StrokePoints gesture( stroke.processData() );
        if( gesture.isEmpty() )
        {
            kDebug() << "GESTURE: replay";
            XAllowEvents( QX11Info::display(), AsyncPointer, CurrentTime );
            XUngrabPointer( QX11Info::display(), CurrentTime );
            mouse_replay( true );
            return true;
        }

        // prepare for the incoming scores from different triggers
        maxScore = 0.0;
        bestFit = NULL;

        emit handle_gesture( gesture );
        // the signal is emitted directly, so we get all trigger scores before
        // the next lines are executed. bestFit should now contain
        // a pointer to the ActionData with the best-matching gesture.

        if( bestFit != NULL )
        {
            // set up the windows_handler
            WId window = windows_handler->window_at_position( start_x, start_y );
            windows_handler->set_action_window( window );
            // then execute the action associated with the best match.
            bestFit->execute();
        }

        return true;
    }
    else if( ev_P->type == MotionNotify && recording )
    {   // ignore small initial movement
        if( nostroke_timer.isActive()
                && abs( start_x - ev_P->xmotion.x_root ) < 10
                && abs( start_y - ev_P->xmotion.y_root ) < 10
          )
            return true;
        nostroke_timer.stop();

        stroke.record( ev_P->xmotion.x, ev_P->xmotion.y );
    }
    return false;
}