Esempio n. 1
0
void RocketModule::keyEvent( int key, bool pressed )
{
	KeyConverter keyconv;
	int mod;

	// DEBUG
#if 0
	if( key >= 32 && key <= 126 )
		Com_Printf("**KEYEVENT CHAR %c\n", key & 0xff );
	else
		Com_Printf("**KEYEVENT KEY %d\n", key );
#endif

	mod = keyconv.getModifiers();

	// warsow sends mousebuttons as keys
	if( key >= K_MOUSE1 && key <= K_MOUSE8 )
	{
		if( pressed )
			context->ProcessMouseButtonDown( key-K_MOUSE1, mod );
		else
			context->ProcessMouseButtonUp( key-K_MOUSE1, mod );
	}
	// and ditto for wheel
	else if( key == K_MWHEELDOWN )
	{
		context->ProcessMouseWheel( KI_MWHEELDOWN, mod );
	}
	else if( key == K_MWHEELUP )
	{
		context->ProcessMouseWheel( KI_MWHEELUP, mod );
	}
	else
	{
		// send the blur event, to the current focused element,
		// when ESC key is pressed
		if( key == K_ESCAPE )
		{
			Element* element = context->GetFocusElement();
			if( element )
				element->Blur();
		}

		int rkey = keyconv.toRocketKey( key );

		if( rkey != 0 )
		{
			if( pressed )
				context->ProcessKeyDown( Rocket::Core::Input::KeyIdentifier( rkey ), keyconv.getModifiers() );
			else
				context->ProcessKeyUp( Rocket::Core::Input::KeyIdentifier( rkey ), keyconv.getModifiers() );
		}
	}
}
Esempio n. 2
0
bool KeyBindConfig::ConvertKey(std::string& ret, const char key) const
{
	KeyConverter kc;


	//Identify the key
	if(kc.CheckCommonKeys(ret, key))
		return true;
	if(kc.CheckNumPad(ret,key))
		return true;
	if(kc.CheckFKeys(ret,key))
		return true;
	if (kc.CheckUncommonKeys(ret,key))
		return true;
		
	
	return false;
	
}
Esempio n. 3
0
bool KeyBindConfig::ReadFromFile(const std::string path, char* data)
{
	KeyConverter kc;
	int count = 0;
	int index = 0;

	std::ifstream read;
	read.open(path);

	if(!read.is_open())
		return false;

	while(!read.eof() && count < KEY_CAP)
	{
		std::string line;

		char key[52];
		char command[52];

		std::getline(read, line);
		TrimAndSet(line);
		sscanf_s(line.c_str(), "%s = ", key, sizeof(key));
		sscanf_s(line.c_str(), (std::string(key) + " = %s").c_str(), &command, sizeof(command));

		index = GetKeyValue(command);

		char keyAdd = kc.ConvertToChar(key);

		if(keyAdd == '\0')
			keyAdd = key[0];
		
		if(index != -1)
			data[index] = keyAdd;

		count++;
	}

	read.close();

	return true;
}
Esempio n. 4
0
void RocketModule::mouseMove( int mousex, int mousey )
{
	KeyConverter keyconv;
	context->ProcessMouseMove( mousex, mousey, keyconv.getModifiers() );
}