Example #1
0
//-----------------------------------------------------------------------------
// name: main_mouse()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleWindow::main_mouse( int button, int state, int x, int y)
{

    assert( this == AudicleWindow::main() );
    set_mouse_coords( x, y );


    //fetch pick stack
    main_pick();
    t_CKUINT * temp_stack = (t_CKUINT*) malloc ( m_pick_size * sizeof(t_CKUINT) );
    memcpy ( (void*)temp_stack, (void*)m_pick_top, m_pick_size * sizeof(t_CKUINT) );

    // create mouse input event
    InputEvent* ev = new InputEvent ( ae_input_MOUSE, m_cur_pt, button, state );
    ev->setMods( glutGetModifiers() );
    ev->setStack( temp_stack , m_pick_size );
    ev->time = get_current_time();

    InputEvent sub = *ev;

    //START AN AUDICLE EVENT 
    //make_mouse_event( m_cur_pt,  button, state );

    AudicleEvent event;
    event.type = ae_event_INPUT;
    event.message = 2;
    event.param1 = button;
    event.param2 = state;
    event.data = (void *) ev;

    Audicle::instance()->face()->on_event( event );

    sub.popStack();

//    if( m_console )
//    {
//        m_console->handleMouse( sub );
//        m_console->handleMouseAlerts( sub ); 
//    }

    free (temp_stack);
    delete ev; //XXX assumes unqueued...

    //    if ( wm ) wm->handleMouse(button, state, cur_pt);

    //    if ( DragManager::instance()->object() ) { } 

}
Example #2
0
//-----------------------------------------------------------------------------
// name: main_special_keys()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleWindow::main_special_keys( int key, int x, int y )
{
    assert( this == AudicleWindow::main() );
    set_mouse_coords(x,y);
    
    InputEvent * ev = new InputEvent ( ae_input_SPEC, m_cur_pt, key ); 
    ev->setMods( glutGetModifiers() );
    ev->time = get_current_time();

    AudicleEvent event;
    event.type = ae_event_INPUT;
    event.message = 2;
    event.data = (void *) ev;

    bool handled = false;
    if ( ev->mods & ae_input_CTRL ) { 
        handled = true;
        switch ( key ) { 
        case KEY_LEFTARROW:
            Audicle::instance()->move( Audicle::LEFT );
//            if( m_console ) m_console->setCubes();
            break;    
        case KEY_RIGHTARROW:
            Audicle::instance()->move( Audicle::RIGHT );
//            if( m_console ) m_console->setCubes();
            break;
        case KEY_UPARROW:
            Audicle::instance()->move( Audicle::UP );
//            if( m_console ) m_console->setCubes();
            break;
        case KEY_DOWNARROW:
            Audicle::instance()->move( Audicle::DOWN );
//            if( m_console ) m_console->setCubes();
            break;
        default:
            handled = false; 
            break;
        }
    }
    else { 
        static float volume = 1.0f;
        handled = true;
        switch ( key ) { 
        case KEY_LEFTARROW:
            break;    
        case KEY_RIGHTARROW:
            break;
        case KEY_UPARROW:
            volume *= 1.05f;
            AudioCentral::instance()->set_gain( volume );
            fprintf( stderr, "[volume]: %f\n", AudioCentral::instance()->get_gain() );
            break;
        case KEY_DOWNARROW:
            volume *= 1.0f/1.1f;
            AudioCentral::instance()->set_gain( volume );
            fprintf( stderr, "[volume]: %f\n", AudioCentral::instance()->get_gain() );
            break;
        default:
            handled = false; 
            break;
        }
    }
    
    if ( !handled ) { 
//        if ( m_console && m_console->active()  && m_console->selected() ) 
//        { 
//            m_console->handleSpec ( *ev ) ;
//        }
//        else 
//        { 
            Audicle::instance()->face()->on_event( event );
//        }
    }

    delete ev; //XXX assumes unqueued...


//   if ( wm ) wm->handleSpec( key, cur_pt);  
}
Example #3
0
//-----------------------------------------------------------------------------
// name: main_keyboard()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleWindow::main_keyboard( unsigned char c, int x, int y )
{
    assert( this == AudicleWindow::main() );
    set_mouse_coords(x,y);
    static int w = 1024, h = 768;


    InputEvent * ev = new InputEvent ( ae_input_KEY, m_cur_pt, c ); 
    ev->setMods( glutGetModifiers() );
    ev->time = get_current_time();

    AudicleEvent event;
    event.type = ae_event_INPUT;
    event.message = 2;
    event.data = (void *) ev;
    
    bool handled = false;

    if( ev->mods & ae_input_CTRL ) 
    {
        switch( c )
        {   
        case KEY_CTRL_G:
            our_fullscreen = !our_fullscreen;
            if( our_fullscreen )
            {
                w = m_w;
                h = m_h;
                glutFullScreen();
            }
            else
                glutReshapeWindow( w, h );
            handled = true;
            break;
        case KEY_CTRL_Q:
            handled = true;
            exit( 0 );
            break;
        }
    }
    else { 
        switch ( c ) { 
        case '`':
            if ( ev->mods & ae_input_ALT ) {
                m_antialiased = !m_antialiased;
            }
//            else if( m_console ) { 
//                if ( m_console->active() ) m_console->deactivate();
//                else m_console->activate();
//            }
            handled = true;
            break;
        }

    }
    
    if ( !handled ) { 

//        if ( m_console && m_console->active() && m_console->selected() ) { 
//            m_console->handleKey( *ev );
//        }
//        else { 
            Audicle::instance()->face()->on_event( event );
//        }


    }
    delete ev; //XXX assumes unqueued...


//   if ( wm ) wm->handleKey( c, cur_pt );
}