示例#1
0
void printMenu(KeyMap & keyMap)
{
	for( auto it = keyMap.begin(); it != keyMap.end(); ++it)
	{
		printf("%c.\t%s\n",it->first, it->second.first);
	}
}
void DirectInputRegistry::updateState( osgGA::EventQueue* eventQueue )
{
    HRESULT hr;
    if ( !_supportDirectInput || !eventQueue ) return;
    
    if ( _keyboard )
    {
        pollDevice( _keyboard );
        
        char buffer[256] = {0};
        hr = _keyboard->GetDeviceState( sizeof(buffer), &buffer );
        if ( SUCCEEDED(hr) )
        {
            for ( KeyMap::iterator itr=g_keyMap.begin(); itr!=g_keyMap.end(); ++itr )
            {
                KeyValue& key = itr->second;
                char value = buffer[itr->first];
                if ( key.second==value ) continue;
                
                key.second = value;
                if ( value&0x80 )
                    eventQueue->keyPress( key.first );
                else
                    eventQueue->keyRelease( key.first );
            }
        }
    }
    
    if ( _mouse )
    {
        pollDevice( _mouse );
        
        DIMOUSESTATE2 mouseState;
        hr = _mouse->GetDeviceState( sizeof(DIMOUSESTATE2), &mouseState );
        
        // TODO: add mouse handlers
    }
    
    if ( _joystick )
    {
        pollDevice( _joystick );
        
        osg::ref_ptr<JoystickEvent> event = new JoystickEvent;
        hr = _joystick->GetDeviceState( sizeof(DIJOYSTATE2), &(event->_js) );
        if ( SUCCEEDED(hr) ) eventQueue->userEvent( event.get() );
    }
}
示例#3
0
// Only for debug
void
ClefKeyContext::dumpKeyContext()
{
    KeyMaps::iterator i;
    KeyMap::iterator j;

    std::cout << "Begin of key context dump =================" << std::endl;

    for (i = m_keyMaps.begin(); i != m_keyMaps.end(); ++i) {
        std::cout << "    Track = " << (*i).first << std::endl;
        KeyMap *m = (*i).second;

        for (j = m->begin(); j != m->end(); ++j) {
            std::cout << "        Time = " << (*j).first
                      << " Key = " << (*j).second.getName() << std::endl;
        }
    }

    std::cout << "End of key context dump =================" << std::endl;
}