示例#1
0
	FOREACH_GameButtonInScheme( pInputs, i )
	{
		if( s == GameButtonToString(pInputs, i) )
			return i;
	}
示例#2
0
bool Screen::PassInputToLua(const InputEventPlus& input)
{
	if(m_InputCallbacks.empty())
	{
		return false;
	}
	m_CallingInputCallbacks= true;
	bool handled= false;
	Lua* L= LUA->Get();

	// Construct the table once, and reuse it.
	lua_createtable(L, 0, 7);
	{ // This block is meant to improve clarity.  A subtable is created for
		// storing the DeviceInput member.
		lua_createtable(L, 0, 8);
		Enum::Push(L, input.DeviceI.device);
		lua_setfield(L, -2, "device");
		Enum::Push(L, input.DeviceI.button);
		lua_setfield(L, -2, "button");
		lua_pushnumber(L, input.DeviceI.level);
		lua_setfield(L, -2, "level");
		lua_pushinteger(L, input.DeviceI.z);
		lua_setfield(L, -2, "z");
		lua_pushboolean(L, input.DeviceI.bDown);
		lua_setfield(L, -2, "down");
		lua_pushnumber(L, input.DeviceI.ts.Ago());
		lua_setfield(L, -2, "ago");
		lua_pushboolean(L, input.DeviceI.IsJoystick());
		lua_setfield(L, -2, "is_joystick");
		lua_pushboolean(L, input.DeviceI.IsMouse());
		lua_setfield(L, -2, "is_mouse");
	}
	lua_setfield(L, -2, "DeviceInput");
	Enum::Push(L, input.GameI.controller);
	lua_setfield(L, -2, "controller");
	LuaHelpers::Push(L, GameButtonToString(INPUTMAPPER->GetInputScheme(), input.GameI.button));
	lua_setfield(L, -2, "button");
	Enum::Push(L, input.type);
	lua_setfield(L, -2, "type");
	LuaHelpers::Push(L, GameButtonToString(INPUTMAPPER->GetInputScheme(), input.MenuI));
	lua_setfield(L, -2, "GameButton");
	Enum::Push(L, input.pn);
	lua_setfield(L, -2, "PlayerNumber");
	Enum::Push(L, input.mp);
	lua_setfield(L, -2, "MultiPlayer");
	for(map<callback_key_t, LuaReference>::iterator callback= m_InputCallbacks.begin();
			callback != m_InputCallbacks.end() && !handled; ++callback)
	{
		callback->second.PushSelf(L);
		lua_pushvalue(L, -2);
		RString error= "Error running input callback: ";
		LuaHelpers::RunScriptOnStack(L, error, 1, 1, true);
		handled= lua_toboolean(L, -1);
		lua_pop(L, 1);
	}
	lua_pop(L, 1);
	LUA->Release(L);
	m_CallingInputCallbacks= false;
	if(!m_DelayedCallbackRemovals.empty())
	{
		for(vector<callback_key_t>::iterator key= m_DelayedCallbackRemovals.begin();
				key != m_DelayedCallbackRemovals.end(); ++key)
		{
			InternalRemoveCallback(*key);
		}
	}
	return handled;
}
示例#3
0
RString GameButtonToLocalizedString( const InputScheme* pInputs, GameButton i )
{
	return THEME->GetString( "GameButton", GameButtonToString(pInputs,i) );
}