Exemplo n.º 1
0
std::vector<std::string> InputContext::active_binds() const {
	Engine &engine = Engine::get();
	InputManager &input_manager = engine.get_input_manager();

	std::vector<std::string> result;

	for (auto &action : this->by_type) {
		std::string action_type_str{
			action.first.info,
			action.first.info + strlen(action.first.info)
		};

		std::string keyboard_key;
		for (auto &key : input_manager.keys) {
			if (key.second.key == action.first.key) {
				keyboard_key = event_as_string(key.first);
				break;
			}
		}

		result.push_back(keyboard_key + " : " + action_type_str);
	}

	return result;
}
Exemplo n.º 2
0
std::vector<std::string> InputManager::active_binds(const std::unordered_map<action_t, action_func_t> &ctx_actions) const {

	std::vector<std::string> result;

	// TODO: this only checks the by_type mappings, the others are missing!
	for (auto &action : ctx_actions) {
		std::string keyboard_key;

		for (auto &key : this->keys) {
			if (key.first == action.first) {
				keyboard_key = event_as_string(key.second);
				break;
			}
		}

		// this is only possible if the action is registered,
		// then this->input_manager != nullptr.
		// TODO: try to purge the action manager access here.
		std::string action_type_str = this->get_action_manager()->get_name(action.first);

		result.push_back(keyboard_key + " : " + action_type_str);
	}

	return result;
}