예제 #1
0
void startConsole()
{	
	//intptr_t serverId = _spawnl(_P_NOWAIT, "TiGaServ.exe", "TiGaServ.exe", "15600" ); 
	//intptr_t clientId = _spawnl(_P_NOWAIT, "TiGaClient.exe", "TiGaServ.exe", "localhost", "15600" );
	bool exit = false;
	KeyMap keyMap;

	MENU_BEGIN('1',"Print menu")
		printMenu(keyMap);
	MENU_END();
	MENU_BEGIN('2',"Start server")
		system("start TiGaServ.exe 15600" ); 
		//if( serverId == 0 )
		//	serverId = _spawnl(_P_NOWAITO, "TiGaServ.exe", "TiGaServ.exe", "15600" ); 
	MENU_END();

	MENU_BEGIN('3',"Start client")
		system("start TiGaClient.exe 127.0.0.1 15600" ); 
		//size_t id = spawnClient();
		//printf("Client %d spawned\n",id);
	MENU_END();

	MENU_BEGIN(' ',"Exit")
		exit = true;
	MENU_END();
	printMenu(keyMap);
	while(exit != true)
	{
		int ch = getch();		
		KeyMap::iterator it = keyMap.find(ch);
		if( it != keyMap.end() )
			it->second.second();
	}
}
예제 #2
0
void printMenu(KeyMap & keyMap)
{
	for( auto it = keyMap.begin(); it != keyMap.end(); ++it)
	{
		printf("%c.\t%s\n",it->first, it->second.first);
	}
}
예제 #3
0
  static rinteger make_key(Env* env, Method* meth, KeyMap& keys) {
    KeyMap::iterator iter = keys.find(meth);

    if(iter == keys.end()) {
      rinteger key = env->integer_new(keys.size());
      keys[meth] = key;
      return key;
    }

    return iter->second;
  }
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() );
    }
}
예제 #5
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;
}